The test was originally introduced for Ubuntu CI, as it uses
PREFER_NSPAWN=1, but it was subsequently disabled two years ago [0], so
it was pretty much useless. Let's merge it into TEST-02 and tweak it a
bit to run only certain tests under QEMU when $TEST_PREFER_NSPAWN is
set.
[0]
b152adbfa9b708dade8559b9962241902bf2eb7c
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
+# shellcheck source=test/test-functions
+. "${TEST_BASE_DIR:?}/test-functions"
+
TEST_DESCRIPTION="Run unit tests under containers"
RUN_IN_UNPRIVILEGED_CONTAINER=yes
# Some tests make collecting coverage impossible (like test-mount-util, which
# case
IGNORE_MISSING_COVERAGE=yes
-# embed some newlines in the kernel command line to stress our test suite
+# Embed some newlines in the kernel command line to stress our test suite
+# Also, pass $TEST_PREFER_NSPAWN to the VM/container if set
+#
+# shellcheck disable=SC2015
KERNEL_APPEND="
+$(get_bool "${TEST_PREFER_NSPAWN:-0}" && echo "systemd.setenv=TEST_PREFER_NSPAWN=1" || :)
frobnicate!
$KERNEL_APPEND
"
-
-# shellcheck source=test/test-functions
-. "${TEST_BASE_DIR:?}/test-functions"
+# Override $TEST_PREFER_NSPAWN if it was set to always run both the QEMU and
+# the nspawn part of the test
+TEST_PREFER_NSPAWN=no
test_append_files() {
if get_bool "$LOOKS_LIKE_SUSE"; then
+++ /dev/null
-../TEST-01-BASIC/Makefile
\ No newline at end of file
+++ /dev/null
-#!/usr/bin/env bash
-# SPDX-License-Identifier: LGPL-2.1-or-later
-set -e
-
-TEST_DESCRIPTION="Run unit tests under qemu"
-# this subset of unit tests requires qemu, so they are ran here to avoid slowing down TEST-02
-TEST_NO_NSPAWN=1
-
-# embed some newlines in the kernel command line to stress our test suite
-KERNEL_APPEND="
-
-frobnicate!
-
-$KERNEL_APPEND
-"
-
-# shellcheck source=test/test-functions
-. "${TEST_BASE_DIR:?}/test-functions"
-
-check_result_nspawn() {
- check_result_nspawn_unittests "${1}"
-}
-
-check_result_qemu() {
- check_result_qemu_unittests
-}
-
-do_test "$@"
exit 1
fi
+# If we're running with TEST_PREFER_NSPAWN=1 limit the set of tests we run
+# in QEMU to only those that can't run in a container to avoid running
+# the same tests again in a, most likely, very slow environment
+if ! systemd-detect-virt -qc && [[ "${TEST_PREFER_NSPAWN:-0}" -ne 0 ]]; then
+ TESTS_GLOB="test-loop-block"
+else
+ TESTS_GLOB=${TESTS_GLOB:-test-*}
+fi
+
NPROC=$(nproc)
MAX_QUEUE_SIZE=${NPROC:-2}
-TESTS_GLOB=${TESTS_GLOB:-test-*}
mapfile -t TEST_LIST < <(find /usr/lib/systemd/tests/unit-tests/ -maxdepth 1 -type f -name "${TESTS_GLOB}")
# reset state
+++ /dev/null
-# SPDX-License-Identifier: LGPL-2.1-or-later
-[Unit]
-Description=TEST-61-UNITTESTS-QEMU
-
-[Service]
-ExecStartPre=rm -f /failed /testok
-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
-Type=oneshot
+++ /dev/null
-#!/usr/bin/env bash
-# SPDX-License-Identifier: LGPL-2.1-or-later
-# shellcheck disable=SC2317
-set -eux
-set -o pipefail
-
-TESTS_GLOB="test-loop-block"
-# shellcheck source=test/units/testsuite-02.sh
-. "$(dirname "$0")/testsuite-02.sh"
-
-exit 0