tests: Disable glibc memory checking under glibc <= 2.11.
[cascardo/ovs.git] / tests / atlocal.in
1 # -*- shell-script -*-
2 HAVE_OPENSSL='@HAVE_OPENSSL@'
3 HAVE_PYTHON='@HAVE_PYTHON@'
4 EGREP='@EGREP@'
5 PERL='@PERL@'
6
7 if test x"$PYTHON" = x; then
8     PYTHON='@PYTHON@'
9 fi
10
11 PYTHONPATH=$abs_top_srcdir/python:$abs_top_builddir/tests:$PYTHONPATH
12 export PYTHONPATH
13
14 PYTHONIOENCODING=utf_8
15 export PYTHONIOENCODING
16
17 # PYTHONDONTWRITEBYTECODE=yes keeps Python 2.6+ from creating .pyc and .pyo
18 # files.  Creating .py[co] works OK for any given version of Open
19 # vSwitch, but it causes trouble if you switch from a version with
20 # foo/__init__.py into an (older) version with plain foo.py, since
21 # foo/__init__.pyc will cause Python to ignore foo.py.
22 #
23 # Python before version 2.6 always creates .pyc files, so if you develop
24 # with such an older version then you're out of luck.
25 PYTHONDONTWRITEBYTECODE=yes
26 export PYTHONDONTWRITEBYTECODE
27
28 if test $HAVE_PYTHON = yes; then
29     if python -m argparse 2>/dev/null; then
30         :
31     else
32         PYTHONPATH=$PYTHONPATH:$abs_top_srcdir/python/compat
33         export PYTHONPATH
34     fi
35 fi
36
37 # Enable malloc debugging features.
38 case `uname` in
39 Linux)
40     MALLOC_PERTURB_=165; export MALLOC_PERTURB_
41
42     # Before glibc 2.11, the feature enabled by MALLOC_CHECK_ was not
43     # thread-safe.  See https://bugzilla.redhat.com/show_bug.cgi?id=585674 and
44     # in particular the patch attached there, which was applied to glibc CVS as
45     # "Restore locking in free_check." between 1.11 and 1.11.1.
46     vswitchd=$abs_top_builddir/vswitchd/ovs-vswitchd
47     glibc=`ldd $vswitchd | sed -n 's/^  libc\.[^ ]* => \([^ ]*\) .*/\1/p'`
48     glibc_version=`$glibc | sed -n '1s/.*version \([0-9]\{1,\}\.[0-9]\{1,\}\).*/\1/p'`
49     case $glibc_version in
50         2.[0-9] | 2.1[01]) mcheck=disabled ;;
51         *) mcheck=enabled ;;
52     esac
53     if test $mcheck = enabled; then
54         MALLOC_CHECK_=2; export MALLOC_CHECK_
55     else
56         echo >&2 "glibc $glibc_version detected, disabling memory checking"
57     fi
58     ;;
59 FreeBSD)
60     case `uname -r` in
61     [789].*)
62         MALLOC_CONF=AJ
63         ;;
64     *)
65         MALLOC_CONF=abort:true,junk:true,redzone:true
66         ;;
67     esac
68     export MALLOC_CONF
69 esac