]> git.proxmox.com Git - mirror_ovs.git/blob - tests/atlocal.in
Revert "Test the Python C JSON extension"
[mirror_ovs.git] / tests / atlocal.in
1 # -*- shell-script -*-
2 HAVE_OPENSSL='@HAVE_OPENSSL@'
3 HAVE_PYTHON='@HAVE_PYTHON@'
4 HAVE_PYTHON2='@HAVE_PYTHON2@'
5 HAVE_PYTHON3='@HAVE_PYTHON3@'
6 EGREP='@EGREP@'
7
8 if test x"$PYTHON" = x; then
9 PYTHON='@PYTHON@'
10 fi
11
12 if test x"$PYTHON2" = x; then
13 PYTHON2='@PYTHON2@'
14 fi
15
16 if test x"$PYTHON3" = x; then
17 PYTHON3='@PYTHON3@'
18
19 # PYTHONCOERCECLOCALE=0 disables the Unicode compatibility warning on
20 # stderr that breaks almost any Python3 test (PEP 0538)
21 PYTHONCOERCECLOCALE=0
22 export PYTHONCOERCECLOCALE
23 fi
24
25 PYTHONPATH=$abs_top_srcdir/python:$abs_top_builddir/tests:$PYTHONPATH
26 export PYTHONPATH
27
28 PYTHONIOENCODING=utf_8
29 export PYTHONIOENCODING
30
31 # PYTHONDONTWRITEBYTECODE=yes keeps Python from creating .pyc and .pyo
32 # files. Creating .py[co] works OK for any given version of Open
33 # vSwitch, but it causes trouble if you switch from a version with
34 # foo/__init__.py into an (older) version with plain foo.py, since
35 # foo/__init__.pyc will cause Python to ignore foo.py.
36 PYTHONDONTWRITEBYTECODE=yes
37 export PYTHONDONTWRITEBYTECODE
38
39 # Test whether the current working directory name is all ASCII
40 # characters. Some Python code doesn't tolerate non-ASCII characters
41 # in filenames very well, so if the current working directory is
42 # non-ASCII then we skip the tests that run those programs.
43 #
44 # This would be just papering over a real problem, except that the
45 # tests that we skip are launched from initscripts and thus normally
46 # run in system directories with ASCII names. (This problem only came
47 # up at all because the Debian autobuilders do build in a top-level
48 # directory named /«BUILDDIR».)
49 case `pwd | tr -d ' -~'` in
50 '') non_ascii_cwd=false ;;
51 *) non_ascii_cwd=true
52 esac
53
54 # Enable malloc debugging features.
55 case `uname` in
56 Linux)
57 MALLOC_PERTURB_=165; export MALLOC_PERTURB_
58
59 # Before glibc 2.11, the feature enabled by MALLOC_CHECK_ was not
60 # thread-safe. See https://bugzilla.redhat.com/show_bug.cgi?id=585674 and
61 # in particular the patch attached there, which was applied to glibc CVS as
62 # "Restore locking in free_check." between 1.11 and 1.11.1.
63 vswitchd=$abs_top_builddir/vswitchd/ovs-vswitchd
64 glibc=`ldd $vswitchd | sed -n 's/^ libc\.[^ ]* => \([^ ]*\) .*/\1/p'`
65 glibc_version=`$glibc | sed -n '1s/.*version \([0-9]\{1,\}\.[0-9]\{1,\}\).*/\1/p'`
66 case $glibc_version in
67 2.[0-9] | 2.1[01]) mcheck=disabled ;;
68 *) mcheck=enabled ;;
69 esac
70 if test $mcheck = enabled; then
71 MALLOC_CHECK_=2; export MALLOC_CHECK_
72 else
73 echo >&2 "glibc $glibc_version detected, disabling memory checking"
74 fi
75 ;;
76 FreeBSD)
77 case `uname -r` in
78 [789].*)
79 MALLOC_CONF=AJ
80 ;;
81 *)
82 MALLOC_CONF=abort:true,junk:true,redzone:true
83 ;;
84 esac
85 export MALLOC_CONF
86 esac
87
88 # The name of loopback interface
89 case `uname` in
90 Linux)
91 LOOPBACK_INTERFACE=lo
92 ;;
93 FreeBSD|NetBSD)
94 LOOPBACK_INTERFACE=lo0
95 ;;
96 esac
97
98 # Check for platform.
99 case `uname` in
100 MINGW*)
101 IS_WIN32="yes"
102 IS_BSD="no"
103 ;;
104 FreeBSD|NetBSD)
105 IS_WIN32="no"
106 IS_BSD="yes"
107 ;;
108 *)
109 IS_WIN32="no"
110 IS_BSD="no"
111 ;;
112 esac
113
114 if test x"$PYTHON3" != x && test "$IS_WIN32" = yes; then
115 # enables legacy windows unicode printing needed for Python3 compatibility
116 # with the Python2 tests
117 PYTHONLEGACYWINDOWSFSENCODING=true
118 export PYTHONLEGACYWINDOWSFSENCODING
119 PYTHONLEGACYWINDOWSSTDIO=true
120 export PYTHONLEGACYWINDOWSSTDIO
121 fi
122
123 # Check whether to run IPv6 tests.
124 $PYTHON -c '
125 import errno
126 import socket
127 import sys
128 try:
129 socket.socket(family=socket.AF_INET6).bind(("::1", 0, 0, 0))
130 except socket.error as e:
131 if e.errno == errno.EAFNOSUPPORT or errno.EADDRNOTAVAIL:
132 sys.exit(2)
133 raise
134 '
135 case $? in
136 0) HAVE_IPV6=yes ;;
137 2) HAVE_IPV6=no ;;
138 *) echo "$0: unexpected error probing $PYTHON for IPv6 support" >&2 ;;
139 esac
140
141 # Look for a python L7 library 'LIB' in the system. If it is found, defines
142 # HAVE_LIB="yes", otherwise HAVE_LIB="no"
143 find_l7_lib()
144 {
145 set +x
146 var=HAVE_`echo "$1" | tr '[a-z]' '[A-Z]'`
147 if test "$HAVE_PYTHON" = "yes"; then
148 result=$($PYTHON $abs_top_srcdir/tests/test-l7.py --help | grep "$1")
149 if test "x${result}" != x; then
150 eval ${var}="yes"
151 else
152 eval ${var}="no"
153 fi
154 else
155 eval ${var}="no"
156 fi
157 }
158
159 # HAVE_FTP
160 find_l7_lib ftp
161 # HAVE_TFTP
162 find_l7_lib tftp
163
164 # Look for a commnand in the system. If it is found, defines
165 # HAVE_COMMAND="yes", otherwise HAVE_COMMAND="no".
166 find_command()
167 {
168 which $1 > /dev/null 2>&1
169 status=$?
170 var=HAVE_`echo "$1" | tr '[a-z]' '[A-Z]'`
171 if test "$status" = "0"; then
172 eval ${var}="yes"
173 else
174 eval ${var}="no"
175 fi
176 }
177
178 # Set HAVE_NC
179 find_command nc
180
181 # Determine correct netcat option to quit on stdin EOF
182 if nc --version 2>&1 | grep -q nmap.org; then
183 # Nmap netcat
184 NC_EOF_OPT="--send-only -w 5"
185 else
186 # BSD netcat
187 NC_EOF_OPT="-q 1 -w 5"
188 fi
189
190 # Set HAVE_TCPDUMP
191 find_command tcpdump
192
193 CURL_OPT="-g -v --max-time 1 --retry 2 --retry-delay 1 --connect-timeout 1"
194
195 # Determine whether "diff" supports "normal" diffs. (busybox diff does not.)
196 if echo xyzzy | diff /dev/null - | grep '^>' >/dev/null; then
197 DIFF_SUPPORTS_NORMAL_FORMAT=yes
198 else
199 DIFF_SUPPORTS_NORMAL_FORMAT=no
200 fi
201
202 # Turn off proxies.
203 unset http_proxy
204 unset https_proxy
205 unset ftp_proxy
206 unset no_proxy
207 unset HTTP_PROXY
208 unset HTTPS_PROXY
209 unset FTP_PROXY
210 unset NO_PROXY
211
212 # Avoid OVN environment variables leaking in from external environment.
213 unset OVN_NB_DB
214 unset OVN_SB_DB
215
216 # Prevent logging to syslog during tests.
217 OVS_SYSLOG_METHOD=null
218 export OVS_SYSLOG_METHOD
219
220 # Set default timeout for control utils
221 OVS_CTL_TIMEOUT=30
222 export OVS_CTL_TIMEOUT