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