blob: 928722382f22bde4530caae910c38cdf92b66d91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/usr/bin/env bash
# Run the unit and simulation tests with different compiler sanitizers
# and under valgrind
valgrind_opts="--leak-check=full --errors-for-leak-kinds=definite"
cd ../..
if [ "$(uname -sm)" != "Linux x86_64" ]; then
echo Test supported on Linux x86_64 only
exit 1
fi
[ -f /etc/os-release ] && . /etc/os-release
if [ "$ID" = "fedora" ]; then
echo Checking test dependencies:
rpm -q {gcc,clang}.x86_64 {valgrind,libgcc,clang-libs}.{x86_64,i686} || exit 1
rpm -q {libseccomp,nettle,nss-softokn-freebl,libtomcrypt,gnutls}-devel.{x86_64,i686} || exit 1
echo
fi
touch Makefile
for extra_config_opts in \
"--all-privops" \
"--disable-ipv6" \
"--disable-nts" \
"--disable-scfilter" \
"--without-aes-gcm-siv" \
"--without-nettle" \
"--without-nettle --without-gnutls" \
"--without-nettle --without-gnutls --without-nss" \
"--without-nettle --without-gnutls --without-nss --without-tomcrypt"; \
do
for arch_opts in "-m32" ""; do
pushd test/simulation/clknetsim || exit 1
make clean > /dev/null 2>&1
CFLAGS="$arch_opts -DCLKNETSIM_DISABLE_SYSCALL" make "$@" || exit 1
echo
popd
for CC in gcc clang; do
export CC
for san_options in "" "-fsanitize=address" "-fsanitize=memory"; do
export CFLAGS="-O2 -g -fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize-recover=all $san_options $arch_opts"
# clang msan doesn't work on i686 and otherwise requires patches
echo $CFLAGS | grep -q 'sanitize=memory' && continue
[ -n "$TEST_NO_M32_CLANG" -a "$arch_opts" = "-m32" -a "$CC" = "clang" ] && continue
[ -n "$TEST_GCC_STATIC_ASAN" -a "$CC" = "gcc" ] &&
echo $CFLAGS | grep -q 'sanitize=address' && CFLAGS="$CFLAGS -static-libasan"
config_opts="--with-user=chrony --with-ntp-era=1000000000 --enable-debug --enable-scfilter --enable-ntp-signd $extra_config_opts"
echo -----------------------------------------------------------------------------
echo CC=\"$CC\" CFLAGS=\"$CFLAGS\" ./configure $config_opts
make distclean > /dev/null 2>&1
./configure $config_opts || exit 1
if echo "$config_opts" | grep -q all-privops; then
for op in ADJUSTTIME ADJUSTTIMEX SETTIME BINDSOCKET; do
echo "#define PRIVOPS_$op 1" >> config.h
done
fi
make "$@" || exit 1
[ -n "$TEST_BUILD_ONLY" ] && continue
echo
pushd test/unit || exit 1
make "$@" || exit 1
if [ "$san_options" = "" ]; then
make check TEST_WRAPPER="valgrind $valgrind_opts --error-exitcode=1" || exit 1
else
make check || exit 1
fi
popd
[ -n "$TEST_UNIT_ONLY" ] && continue
echo
pushd test/simulation || exit 1
export CLKNETSIM_RANDOM_SEED=101
if [ "$arch_opts" = "" -a "$san_options" = "" ]; then
CLKNETSIM_CLIENT_WRAPPER="valgrind $valgrind_opts" ./run -i 1 || exit 1
elif [ "$CC" = "gcc" ] && ! echo $CFLAGS | grep -q "-static-libasan"; then
libasan=$(ldd ../../chronyd | grep -o '/.*lib.*/libasan.so.[0-9]')
CLKNETSIM_PRELOAD=$libasan ./run -i 1 || exit 1
else
./run -i 1 || exit 1
fi
popd
done
done
done
done
|