]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
CI: run unit tests in a network namespace
authorLuca Boccassi <luca.boccassi@microsoft.com>
Sat, 25 Sep 2021 14:40:39 +0000 (15:40 +0100)
committerLuca Boccassi <luca.boccassi@microsoft.com>
Mon, 27 Sep 2021 11:22:22 +0000 (12:22 +0100)
It seems some of the tests break network connectivity on the host,
as the code coverage upload fails to establish a connection.
Run them in a network namespace with 'unshare -n'.

.github/workflows/unit_tests.sh

index e85c32100188fbae97916301c68d8faf630a849d..f661d45c99b053bf27031af0c6863ac5ec81d51c 100755 (executable)
@@ -6,6 +6,7 @@ ADDITIONAL_DEPS=(
     clang
     expect
     fdisk
+    iproute2
     jekyll
     libfdisk-dev
     libfido2-dev
@@ -18,6 +19,7 @@ ADDITIONAL_DEPS=(
     perl
     python3-libevdev
     python3-pyparsing
+    util-linux
     zstd
 )
 
@@ -45,7 +47,8 @@ for phase in "${PHASES[@]}"; do
             fi
             meson --werror -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true -Dman=true build
             ninja -C build -v
-            meson test -C build --print-errorlogs
+            # Some of the unsafe tests irreparably break the host's network connectivity, so run them in a namespace
+            unshare -n bash -c 'ip link set dev lo up; meson test -C build --print-errorlogs'
             ;;
         RUN_ASAN_UBSAN|RUN_GCC_ASAN_UBSAN|RUN_CLANG_ASAN_UBSAN)
             MESON_ARGS=(--optimization=1)
@@ -74,7 +77,7 @@ for phase in "${PHASES[@]}"; do
             # during debugging, wonderful), so let's at least keep a workaround
             # here to make the builds stable for the time being.
             (set +x; while :; do echo -ne "\n[WATCHDOG] $(date)\n"; sleep 30; done) &
-            meson test --timeout-multiplier=3 -C build --print-errorlogs
+            unshare -n bash -c 'ip link set dev lo up; meson test --timeout-multiplier=3 -C build --print-errorlogs'
             ;;
         CLEANUP)
             info "Cleanup phase"