gitlab-ci: run unit tests under valgrind in gitlab-ci

On Ubuntu 16.04 (trusty) valgrind fails due to rdrand being advertised
but not implemented.

Work around that by installing valgrind from Ubuntu 18.04 (bionic) via
the "contrib/scripts/nm-ci-install-valgrind-in-ubuntu1604.sh" script.
This commit is contained in:
Thomas Haller
2019-02-22 08:23:20 +01:00
parent 16cd84d346
commit 6d76a0974e
4 changed files with 75 additions and 6 deletions

View File

@@ -0,0 +1,36 @@
#!/bin/bash
set -exv
# Ubuntu 16.04 (trusty) ships a valgrind version where __get_cpuid() announces
# rdrand support, but later valgrind crashes with unsupported opcode.
#
# See https://bugs.kde.org/show_bug.cgi?id=353370#c9
# https://bugs.launchpad.net/ubuntu/+source/valgrind/+bug/1501545
#
# We call rdrand for hash-tables of systemd:
# https://github.com/systemd/systemd/blob/e7b621ee1f1abfbcaae1cd17da4d815daf218679/src/basic/random-util.c#L36
#
# Work around that by installing valgrind from bionic.
grep -q 'PRETTY_NAME="Ubuntu 16.04.6 LTS"' /etc/os-release || exit 0
dpkg -s valgrind | grep -q 'Version: 1:3.11.0-1ubuntu4.2$' || exit 0
cat <<EOF > /etc/apt/sources.list.d/bionic1804.list
deb http://us.archive.ubuntu.com/ubuntu/ bionic main
EOF
cat <<EOF > /etc/apt/preferences.d/bionic1804.pref
Package: *
Pin: release n=bionic
Pin-Priority: -10
Package: valgrind
Pin: release n=bionic
Pin-Priority: 500
EOF
apt-get update
apt-get install valgrind -y

View File

@@ -22,6 +22,13 @@ _is_true() {
0|n|no|NO|No|off)
return 1
;;
"")
if [ "$2" == "" ]; then
die "not a boolean argument \"$1\""
fi
_is_true "$2"
return $?
;;
*)
die "not a boolean argument \"$1\""
;;
@@ -85,10 +92,17 @@ fi
###############################################################################
_autotools_test_print_logs() {
_print_test_logs() {
echo ">>>> PRINT TEST LOGS $1 (start)"
cat test-suite.log
if test -f test-suite.log; then
cat test-suite.log
fi
echo ">>>> PRINT TEST LOGS $1 (done)"
if _is_true "$WITH_VALGRIND" 0; then
echo ">>>> PRINT VALGRIND LOGS $1 (start)"
find -name '*.valgrind-log' -print0 | xargs -0 grep -H ^
echo ">>>> PRINT VALGRIND LOGS $1 (done)"
fi
}
run_autotools() {
@@ -141,15 +155,22 @@ run_autotools() {
if ! make check -j 6 -k ; then
_autotools_test_print_logs "first-test"
_print_test_logs "first-test"
echo ">>>> RUN SECOND TEST (start)"
NMTST_DEBUG=TRACE,no-expect-message make check -k || :
echo ">>>> RUN SECOND TEST (done)"
_autotools_test_print_logs "second-test"
_print_test_logs "second-test"
die "test failed"
fi
if _is_true "$WITH_VALGRIND" 0; then
if ! NMTST_USE_VALGRIND=1 make check -j 3 -k ; then
_print_test_logs "(valgrind test)"
die "valgrind test failed"
fi
fi
popd
}
@@ -200,6 +221,13 @@ run_meson() {
ninja -C build
ninja -C build test
if _is_true "$WITH_VALGRIND" 0; then
if ! NMTST_USE_VALGRIND=1 ninja -C build test; then
_print_test_logs "(valgrind test)"
die "valgrind test failed"
fi
fi
}
###############################################################################