2018-11-03 11:15:36 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2019-02-04 11:30:55 +01:00
|
|
|
# Arguments via environment variables:
|
|
|
|
|
# - CI
|
|
|
|
|
# - CC
|
|
|
|
|
# - BUILD_TYPE
|
|
|
|
|
# - CFLAGS
|
2019-02-05 16:06:02 +01:00
|
|
|
# - WITH_DOCS
|
2019-02-04 11:30:55 +01:00
|
|
|
|
2020-12-10 20:08:00 +01:00
|
|
|
set -ex
|
2018-11-03 11:15:36 +01:00
|
|
|
|
|
|
|
|
die() {
|
|
|
|
|
printf "%s\n" "$@"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-05 16:06:02 +01:00
|
|
|
_is_true() {
|
|
|
|
|
case "$1" in
|
|
|
|
|
1|y|yes|YES|Yes|on)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
0|n|no|NO|No|off)
|
|
|
|
|
return 1
|
|
|
|
|
;;
|
2019-02-22 08:23:20 +01:00
|
|
|
"")
|
|
|
|
|
if [ "$2" == "" ]; then
|
|
|
|
|
die "not a boolean argument \"$1\""
|
|
|
|
|
fi
|
|
|
|
|
_is_true "$2"
|
|
|
|
|
return $?
|
|
|
|
|
;;
|
2019-02-05 16:06:02 +01:00
|
|
|
*)
|
|
|
|
|
die "not a boolean argument \"$1\""
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-18 08:46:53 +02:00
|
|
|
USE_CCACHE=0
|
2020-12-11 11:11:57 +01:00
|
|
|
if command -v ccache &>/dev/null; then
|
2019-04-18 08:46:53 +02:00
|
|
|
USE_CCACHE=1
|
2019-02-04 11:06:21 +01:00
|
|
|
export PATH="/usr/lib64/ccache:/usr/lib/ccache${PATH:+:${PATH}}"
|
|
|
|
|
fi
|
|
|
|
|
|
2020-12-10 20:08:00 +01:00
|
|
|
IS_FEDORA=0
|
|
|
|
|
IS_CENTOS=0
|
|
|
|
|
IS_ALPINE=0
|
|
|
|
|
grep -q '^NAME=.*\(CentOS\)' /etc/os-release && IS_CENTOS=1
|
|
|
|
|
grep -q '^NAME=.*\(Fedora\)' /etc/os-release && IS_FEDORA=1
|
|
|
|
|
grep -q '^NAME=.*\(Alpine\)' /etc/os-release && IS_ALPINE=1
|
|
|
|
|
|
2018-11-03 11:15:36 +01:00
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
if [ "$BUILD_TYPE" == meson ]; then
|
|
|
|
|
_TRUE=true
|
|
|
|
|
_FALSE=false
|
|
|
|
|
elif [ "$BUILD_TYPE" == autotools ]; then
|
|
|
|
|
_TRUE=yes
|
|
|
|
|
_FALSE=no
|
|
|
|
|
else
|
2019-02-04 11:30:55 +01:00
|
|
|
die "invalid \$BUILD_TYPE \"$BUILD_TYPE\""
|
2018-11-03 11:15:36 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_WITH_CRYPTO="gnutls"
|
2019-02-08 13:42:16 +01:00
|
|
|
_WITH_WERROR=1
|
2018-11-03 11:15:36 +01:00
|
|
|
_WITH_LIBTEAM="$_TRUE"
|
|
|
|
|
_WITH_DOCS="$_TRUE"
|
|
|
|
|
_WITH_SYSTEMD_LOGIND="$_TRUE"
|
2020-12-10 20:08:00 +01:00
|
|
|
if [ $IS_ALPINE = 1 ]; then
|
|
|
|
|
_WITH_SYSTEMD_LOGIND="$_FALSE"
|
|
|
|
|
fi
|
2019-02-04 11:30:55 +01:00
|
|
|
|
2023-01-26 13:24:07 +01:00
|
|
|
if [ -z "${NMTST_SEED_RAND+x}" ]; then
|
|
|
|
|
NMTST_SEED_RAND="$SRANDOM"
|
|
|
|
|
if [ -z "$NMTST_SEED_RAND" ]; then
|
|
|
|
|
NMTST_SEED_RAND="$(( ( (RANDOM<<15|RANDOM)<<15|RANDOM ) % 0xfffffffe ))"
|
|
|
|
|
fi
|
2019-05-17 13:30:14 +02:00
|
|
|
fi
|
2023-01-26 13:24:07 +01:00
|
|
|
export NMTST_SEED_RAND
|
2019-05-17 13:30:14 +02:00
|
|
|
|
2019-04-18 08:46:53 +02:00
|
|
|
case "$CI" in
|
|
|
|
|
""|"true"|"default"|"gitlab")
|
|
|
|
|
CI=default
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
die "invalid \$CI \"$CI\""
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2018-11-03 11:15:36 +01:00
|
|
|
if [ "$CC" != gcc ]; then
|
|
|
|
|
_WITH_CRYPTO=nss
|
|
|
|
|
fi
|
|
|
|
|
|
2019-02-05 16:06:02 +01:00
|
|
|
if [ "$WITH_DOCS" != "" ]; then
|
|
|
|
|
if _is_true "$WITH_DOCS"; then
|
|
|
|
|
_WITH_DOCS="$_TRUE"
|
|
|
|
|
else
|
|
|
|
|
_WITH_DOCS="$_FALSE"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2019-05-18 11:19:45 +02:00
|
|
|
unset _WITH_VALGRIND_CHECKED
|
|
|
|
|
_with_valgrind() {
|
|
|
|
|
_is_true "$WITH_VALGRIND" 0 || return 1
|
|
|
|
|
|
|
|
|
|
test "$_WITH_VALGRIND_CHECKED" == "1" && return 0
|
|
|
|
|
_WITH_VALGRIND_CHECKED=1
|
|
|
|
|
|
2020-12-22 23:36:49 +01:00
|
|
|
if [ "$IS_ALPINE" = 1 ]; then
|
|
|
|
|
# on Alpine we have no debug symbols and the suppressions
|
|
|
|
|
# don't work. Skip valgrind tests.
|
|
|
|
|
WITH_VALGRIND=0
|
|
|
|
|
fi
|
|
|
|
|
|
2019-05-18 11:19:45 +02:00
|
|
|
# Certain glib2 versions are known to report *lots* of leaks. Disable
|
|
|
|
|
# valgrind tests in this case.
|
|
|
|
|
# https://bugzilla.redhat.com/show_bug.cgi?id=1710417
|
|
|
|
|
if grep -q '^PRETTY_NAME="Fedora 30 (.*)"$' /etc/os-release ; then
|
|
|
|
|
if rpm -q glib2 | grep -q glib2-2.60.2-1.fc30 ; then
|
|
|
|
|
WITH_VALGRIND=0
|
|
|
|
|
fi
|
|
|
|
|
elif grep -q '^PRETTY_NAME="Fedora 31 (.*)"$' /etc/os-release; then
|
|
|
|
|
if rpm -q glib2 | grep -q glib2-2.61.0-2.fc31 ; then
|
|
|
|
|
WITH_VALGRIND=0
|
|
|
|
|
fi
|
2021-01-28 13:44:05 +01:00
|
|
|
elif grep -q '^PRETTY_NAME="Debian.*sid"$' /etc/os-release; then
|
|
|
|
|
if dpkg -s libglib2.0-bin | grep -q '^Version: 2.66.4-2$' ; then
|
|
|
|
|
WITH_VALGRIND=0
|
|
|
|
|
fi
|
2019-05-18 11:19:45 +02:00
|
|
|
fi
|
|
|
|
|
if [ "$WITH_VALGRIND" == 0 ]; then
|
|
|
|
|
echo "Don't use valgrind due to known issues in other packages."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-03 11:15:36 +01:00
|
|
|
###############################################################################
|
|
|
|
|
|
2019-02-22 08:23:20 +01:00
|
|
|
_print_test_logs() {
|
2018-11-03 11:15:36 +01:00
|
|
|
echo ">>>> PRINT TEST LOGS $1 (start)"
|
2019-02-22 08:23:20 +01:00
|
|
|
if test -f test-suite.log; then
|
|
|
|
|
cat test-suite.log
|
|
|
|
|
fi
|
2018-11-03 11:15:36 +01:00
|
|
|
echo ">>>> PRINT TEST LOGS $1 (done)"
|
2019-05-18 11:19:45 +02:00
|
|
|
if _with_valgrind; then
|
2019-02-22 08:23:20 +01:00
|
|
|
echo ">>>> PRINT VALGRIND LOGS $1 (start)"
|
2019-05-24 12:48:20 +02:00
|
|
|
find -name '*.valgrind-log' -print0 | xargs -0 grep -H ^ || true
|
2019-02-22 08:23:20 +01:00
|
|
|
echo ">>>> PRINT VALGRIND LOGS $1 (done)"
|
|
|
|
|
fi
|
2018-11-03 11:15:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run_autotools() {
|
|
|
|
|
NOCONFIGURE=1 ./autogen.sh
|
|
|
|
|
mkdir ./build
|
2019-02-08 13:42:16 +01:00
|
|
|
if [ "$_WITH_WERROR" == 1 ]; then
|
|
|
|
|
_WITH_WERROR_VAL="error"
|
|
|
|
|
else
|
|
|
|
|
_WITH_WERROR_VAL="yes"
|
|
|
|
|
fi
|
2020-12-10 20:08:00 +01:00
|
|
|
DISABLE_DEPENDENCY_TRACKING=
|
|
|
|
|
if [ $IS_ALPINE = 1 ]; then
|
|
|
|
|
DISABLE_DEPENDENCY_TRACKING='--disable-dependency-tracking'
|
|
|
|
|
fi
|
2018-11-03 11:15:36 +01:00
|
|
|
pushd ./build
|
|
|
|
|
../configure \
|
|
|
|
|
--prefix="$PWD/INST" \
|
2020-12-10 20:08:00 +01:00
|
|
|
$DISABLE_DEPENDENCY_TRACKING \
|
|
|
|
|
\
|
2018-11-03 11:15:36 +01:00
|
|
|
--enable-introspection=$_WITH_DOCS \
|
|
|
|
|
--enable-gtk-doc=$_WITH_DOCS \
|
|
|
|
|
--with-systemd-logind=$_WITH_SYSTEMD_LOGIND \
|
2019-02-08 13:42:16 +01:00
|
|
|
--enable-more-warnings="$_WITH_WERROR_VAL" \
|
2018-11-03 11:15:36 +01:00
|
|
|
--enable-tests=yes \
|
|
|
|
|
--with-crypto=$_WITH_CRYPTO \
|
|
|
|
|
\
|
gitlab-ci: run unit tests for n-acd with eBPF disabled
Enabling eBPF causes src/devices/tests/test-acd to fail:
strace: bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_HASH, key_size=4, value_size=1, max_entries=8, map_flags=0, inner_map_fd=0, map_name="", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0}, 112) = -1 EPERM (Operation not permitted)
NetworkManager-Message: 10:07:04.404: <warn> [1554631624.4046] acd[0xa2b400,10]: couldn't init ACD for announcing addresses on interface 'nm-test-veth0': Operation not permitted
Interestingly it does not always fail. Seems to depend on the kernel
which is used in the containerized test environments of gitlab-ci.
For now, just disable eBPF and use the fallback implementation.
2019-04-07 12:19:02 +02:00
|
|
|
--with-ebpf=no \
|
|
|
|
|
\
|
2018-11-03 11:15:36 +01:00
|
|
|
--with-iwd=yes \
|
|
|
|
|
--with-ofono=yes \
|
|
|
|
|
--enable-teamdctl=$_WITH_LIBTEAM \
|
|
|
|
|
\
|
|
|
|
|
--with-dhcpcanon=yes \
|
|
|
|
|
--with-dhcpcd=yes \
|
|
|
|
|
--with-dhclient=yes \
|
|
|
|
|
\
|
|
|
|
|
--with-netconfig=/bin/nowhere/netconfig \
|
|
|
|
|
--with-resolvconf=/bin/nowhere/resolvconf \
|
|
|
|
|
\
|
|
|
|
|
--enable-ifcfg-rh=yes \
|
|
|
|
|
--enable-ifupdown=yes \
|
|
|
|
|
\
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
make -j 6
|
|
|
|
|
make install
|
|
|
|
|
|
|
|
|
|
export NM_TEST_CLIENT_CHECK_L10N=1
|
|
|
|
|
|
|
|
|
|
if ! make check -j 6 -k ; then
|
|
|
|
|
|
2019-02-22 08:23:20 +01:00
|
|
|
_print_test_logs "first-test"
|
2018-11-03 11:15:36 +01:00
|
|
|
|
|
|
|
|
echo ">>>> RUN SECOND TEST (start)"
|
gitlab-ci: explicitly set "NMTST_DEBUG=debug,..." for second debug run
"debug" is implied when setting NMTST_DEBUG, but not specifying
"no-debug". This change has thus no effect, but it seems clearer to be
explicit.
The "debug" flag affects nmtst_is_debug(). Note that tests *must* not
result in different code paths based on debug, they may only
1) print more debug logging
2) do more assertion checks.
Having more assertion checks can result in different outcome of the
test, that is, that the additional assertion fails first. That is
acceptable, because failing earlier is possibly closer to the issue and
helps debugging. Also, when the additional failure is fixed and passes,
we still will fail at the assertion we are trying to debug.
In particular, an access to nmtst_get_rand*()/nmtst_rand*() must not
depend on nmtst_is_debug(), because then different randomized paths
are taken based on whether debugging is enabled.
(cherry picked from commit 3f2ad76363e2f53078829fb31406d5950de5e6f7)
2023-01-26 13:50:33 +01:00
|
|
|
NMTST_DEBUG="debug,TRACE,no-expect-message" make check -k || :
|
2018-11-03 11:15:36 +01:00
|
|
|
echo ">>>> RUN SECOND TEST (done)"
|
|
|
|
|
|
2019-02-22 08:23:20 +01:00
|
|
|
_print_test_logs "second-test"
|
2018-11-03 11:15:36 +01:00
|
|
|
die "test failed"
|
|
|
|
|
fi
|
2019-02-22 08:23:20 +01:00
|
|
|
|
2019-05-18 11:19:45 +02:00
|
|
|
if _with_valgrind; then
|
2019-02-22 08:23:20 +01:00
|
|
|
if ! NMTST_USE_VALGRIND=1 make check -j 3 -k ; then
|
|
|
|
|
_print_test_logs "(valgrind test)"
|
|
|
|
|
die "valgrind test failed"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2018-11-03 11:15:36 +01:00
|
|
|
popd
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
run_meson() {
|
2019-02-08 13:42:16 +01:00
|
|
|
if [ "$_WITH_WERROR" == 1 ]; then
|
|
|
|
|
_WITH_WERROR_VAL="--werror"
|
|
|
|
|
else
|
|
|
|
|
_WITH_WERROR_VAL=""
|
|
|
|
|
fi
|
2018-11-03 11:15:36 +01:00
|
|
|
meson build \
|
2021-03-15 10:59:24 +01:00
|
|
|
\
|
|
|
|
|
-Dprefix="$PWD/INST" \
|
2019-02-08 13:42:16 +01:00
|
|
|
\
|
|
|
|
|
--warnlevel 2 \
|
|
|
|
|
$_WITH_WERROR_VAL \
|
2018-11-03 11:15:36 +01:00
|
|
|
\
|
|
|
|
|
-D ld_gc=false \
|
|
|
|
|
-D session_tracking=no \
|
|
|
|
|
-D systemdsystemunitdir=no \
|
|
|
|
|
-D systemd_journal=false \
|
|
|
|
|
-D selinux=false \
|
|
|
|
|
-D libaudit=no \
|
|
|
|
|
-D libpsl=false \
|
|
|
|
|
-D vapi=false \
|
|
|
|
|
-D introspection=$_WITH_DOCS \
|
|
|
|
|
-D qt=false \
|
|
|
|
|
-D crypto=$_WITH_CRYPTO \
|
|
|
|
|
-D docs=$_WITH_DOCS \
|
|
|
|
|
\
|
gitlab-ci: run unit tests for n-acd with eBPF disabled
Enabling eBPF causes src/devices/tests/test-acd to fail:
strace: bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_HASH, key_size=4, value_size=1, max_entries=8, map_flags=0, inner_map_fd=0, map_name="", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0}, 112) = -1 EPERM (Operation not permitted)
NetworkManager-Message: 10:07:04.404: <warn> [1554631624.4046] acd[0xa2b400,10]: couldn't init ACD for announcing addresses on interface 'nm-test-veth0': Operation not permitted
Interestingly it does not always fail. Seems to depend on the kernel
which is used in the containerized test environments of gitlab-ci.
For now, just disable eBPF and use the fallback implementation.
2019-04-07 12:19:02 +02:00
|
|
|
-D ebpf=false \
|
|
|
|
|
\
|
2018-11-03 11:15:36 +01:00
|
|
|
-D iwd=true \
|
|
|
|
|
-D ofono=true \
|
|
|
|
|
-D teamdctl=$_WITH_LIBTEAM \
|
|
|
|
|
\
|
|
|
|
|
-D dhclient=/bin/nowhere/dhclient \
|
|
|
|
|
-D dhcpcanon=/bin/nowhere/dhcpcanon \
|
|
|
|
|
-D dhcpcd=/bin/nowhere/dhcpd \
|
|
|
|
|
\
|
|
|
|
|
-D netconfig=/bin/nowhere/netconfig \
|
|
|
|
|
-D resolvconf=/bin/nowhere/resolvconf \
|
|
|
|
|
\
|
|
|
|
|
-D ifcfg_rh=false \
|
|
|
|
|
-D ifupdown=true \
|
|
|
|
|
\
|
|
|
|
|
#end
|
|
|
|
|
|
2021-03-15 10:59:24 +01:00
|
|
|
export NM_TEST_CLIENT_CHECK_L10N=1
|
|
|
|
|
|
2018-11-03 11:15:36 +01:00
|
|
|
ninja -C build
|
2021-03-15 10:59:24 +01:00
|
|
|
ninja -C build install
|
2018-11-03 11:15:36 +01:00
|
|
|
ninja -C build test
|
2019-02-22 08:23:20 +01:00
|
|
|
|
2019-05-18 11:19:45 +02:00
|
|
|
if _with_valgrind; then
|
2019-02-22 08:23:20 +01:00
|
|
|
if ! NMTST_USE_VALGRIND=1 ninja -C build test; then
|
|
|
|
|
_print_test_logs "(valgrind test)"
|
|
|
|
|
die "valgrind test failed"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2018-11-03 11:15:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
if [ "$BUILD_TYPE" == autotools ]; then
|
|
|
|
|
run_autotools
|
|
|
|
|
elif [ "$BUILD_TYPE" == meson ]; then
|
|
|
|
|
run_meson
|
|
|
|
|
fi
|
2019-04-18 08:46:53 +02:00
|
|
|
|
|
|
|
|
if [ "$USE_CCACHE" = 1 ]; then
|
|
|
|
|
echo "ccache statistics:"
|
|
|
|
|
ccache -s
|
|
|
|
|
fi
|