summaryrefslogtreecommitdiffstats
path: root/test/compilation
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:09:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:09:41 +0000
commit3271d1ac389d2ec93db9c5b9ce0991ce478476cf (patch)
tree35ff7d180e1ccc061f28535d7435b5ba1789e734 /test/compilation
parentInitial commit. (diff)
downloadchrony-upstream/4.3.tar.xz
chrony-upstream/4.3.zip
Adding upstream version 4.3.upstream/4.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtest/compilation/001-features36
-rwxr-xr-xtest/compilation/002-scanbuild16
-rwxr-xr-xtest/compilation/003-sanitizers103
3 files changed, 155 insertions, 0 deletions
diff --git a/test/compilation/001-features b/test/compilation/001-features
new file mode 100755
index 0000000..9bd340f
--- /dev/null
+++ b/test/compilation/001-features
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# Try to compile chrony in various combinations of disabled features
+
+cd ../..
+
+export CFLAGS="-O2 -Werror -Wpointer-arith -Wformat-signedness -Wno-unknown-warning-option -D_FORTIFY_SOURCE=2"
+
+for opts in \
+ "--enable-debug" \
+ "--enable-ntp-signd" \
+ "--enable-scfilter" \
+ "--disable-asyncdns" \
+ "--disable-ipv6" \
+ "--disable-privdrop" \
+ "--disable-readline" \
+ "--disable-rtc" \
+ "--disable-sechash" \
+ "--disable-cmdmon" \
+ "--disable-cmdmon --enable-scfilter" \
+ "--disable-ntp" \
+ "--disable-ntp --enable-scfilter" \
+ "--disable-nts" \
+ "--disable-refclock" \
+ "--disable-timestamping" \
+ "--disable-timestamping --disable-ntp" \
+ "--disable-cmdmon --disable-ntp" \
+ "--disable-cmdmon --disable-ntp --enable-scfilter" \
+ "--disable-cmdmon --disable-refclock" \
+ "--disable-cmdmon --disable-ntp --disable-refclock"
+do
+ ./configure $opts || exit 1
+ make clean
+ make "$@" || exit 1
+ make -C test/unit check || exit 1
+done
diff --git a/test/compilation/002-scanbuild b/test/compilation/002-scanbuild
new file mode 100755
index 0000000..35a3faf
--- /dev/null
+++ b/test/compilation/002-scanbuild
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+cd ../..
+
+for opts in \
+ "--host-system=Linux" \
+ "--host-system=NetBSD" \
+ "--host-system=FreeBSD" \
+ "--without-nettle" \
+ "--without-nettle --without-nss" \
+ "--without-nettle --without-nss --without-tomcrypt" \
+ "--without-nettle --without-nss --without-tomcrypt --without-gnutls"
+do
+ ./configure $opts
+ scan-build make "$@" || exit 1
+done
diff --git a/test/compilation/003-sanitizers b/test/compilation/003-sanitizers
new file mode 100755
index 0000000..8040efe
--- /dev/null
+++ b/test/compilation/003-sanitizers
@@ -0,0 +1,103 @@
+#!/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-scfilter" \
+ "--without-gnutls" \
+ "--without-nettle" \
+ "--without-nettle --without-nss" \
+ "--without-nettle --without-nss --without-tomcrypt" \
+ "--without-nettle --without-nss --without-tomcrypt --without-gnutls"; \
+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 -fno-sanitize-recover=undefined,float-divide-by-zero $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