2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
2021-10-17 19:13:06 +03:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2018-09-19 08:30:29 +03:00
set -e
2021-04-19 14:01:59 +03:00
2023-06-07 14:51:02 +03:00
# shellcheck source=test/test-functions
. " ${ TEST_BASE_DIR : ? } /test-functions "
2018-09-19 08:30:29 +03:00
TEST_DESCRIPTION = "Run unit tests under containers"
RUN_IN_UNPRIVILEGED_CONTAINER = yes
2022-04-07 13:45:13 +03:00
# Some tests make collecting coverage impossible (like test-mount-util, which
# remounts the whole / as read-only), so let's ignore the gcov errors in such
# case
IGNORE_MISSING_COVERAGE = yes
2018-09-19 08:30:29 +03:00
2023-06-07 14:51:02 +03:00
# 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
2019-12-13 16:20:35 +03:00
KERNEL_APPEND = "
2023-06-07 14:51:02 +03:00
$( get_bool " ${ TEST_PREFER_NSPAWN :- 0 } " && echo "systemd.setenv=TEST_PREFER_NSPAWN=1" || :)
2019-12-13 16:20:35 +03:00
frobnicate!
2023-06-12 22:05:30 +03:00
systemd.setenv= TEST_CMDLINE_NEWLINE = foo
systemd.setenv= TEST_CMDLINE_NEWLINE = bar
2019-12-13 16:20:35 +03:00
$KERNEL_APPEND
"
2023-06-07 14:51:02 +03:00
# 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
2018-09-19 08:30:29 +03:00
2023-03-20 20:23:33 +03:00
test_append_files( ) {
if get_bool " $LOOKS_LIKE_SUSE " ; then
dinfo "Install the unit test binaries needed by the TEST-02-UNITTESTS at runtime"
inst_recursive " ${ SOURCE_DIR } /unit-tests "
fi
}
2018-09-19 08:30:29 +03:00
check_result_nspawn( ) {
2021-06-21 22:05:47 +03:00
check_result_nspawn_unittests " ${ 1 } "
2018-09-19 08:30:29 +03:00
}
check_result_qemu( ) {
2021-06-21 22:05:47 +03:00
check_result_qemu_unittests
2018-09-19 08:30:29 +03:00
}
2021-04-26 20:20:18 +03:00
do_test " $@ "