]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test/TEST-01: allow running w/o -Dinstall-tests=true
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 17 Dec 2019 11:52:35 +0000 (12:52 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 28 Mar 2020 10:51:29 +0000 (11:51 +0100)
This is useful for sanitizer builds under CI, see
https://github.com/systemd/systemd-centos-ci/pull/202#issuecomment-566476592.

test/TEST-01-BASIC/test.sh
test/test-functions

index 9f2ec1e8ae5af867ee132122cacddc4145a3aa5d..58f6cd141429a2d2c880c8b13953fd5ef3aa22f3 100755 (executable)
@@ -3,6 +3,7 @@ set -e
 TEST_DESCRIPTION="Basic systemd setup"
 IMAGE_NAME="basic"
 RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}
+TEST_REQUIRE_INSTALL_TESTS=0
 
 . $TEST_BASE_DIR/test-functions
 
@@ -13,6 +14,10 @@ test_create_image() {
     (
         LOG_LEVEL=5
         setup_basic_environment
+
+        # install tests manually so the test is functional even when -Dinstall-tests=false
+        mkdir -p $initdir/usr/lib/systemd/tests/testdata/units/
+        cp -v $(dirname $0)/../units/{testsuite-01,end}.service $initdir/usr/lib/systemd/tests/testdata/units/
     )
     setup_nspawn_root
 }
index bca0588af82d591648495715ff24e6094de1b028..7ae7d74fa8c155acf2a571dc5ba27ae5e62011aa 100644 (file)
@@ -17,6 +17,7 @@ UNIFIED_CGROUP_HIERARCHY="${UNIFIED_CGROUP_HIERARCHY:-default}"
 EFI_MOUNT="${EFI_MOUNT:-$(bootctl -x 2>/dev/null || echo /boot)}"
 QEMU_MEM="${QEMU_MEM:-512M}"
 IMAGE_NAME=${IMAGE_NAME:-default}
+TEST_REQUIRE_INSTALL_TESTS="${TEST_REQUIRE_INSTALL_TESTS:-1}"
 
 # Decide if we can (and want to) run QEMU with KVM acceleration.
 # Check if nested KVM is explicitly enabled (TEST_NESTED_KVM). If not,
@@ -1933,7 +1934,9 @@ test_create_image() {
 }
 
 test_setup() {
-    if type -P meson >/dev/null && [[ "$(meson configure $BUILD_DIR | grep install-tests | awk '{ print $2 }')" != "true" ]]; then
+    if [ ${TEST_REQUIRE_INSTALL_TESTS} -ne 0 ] && \
+            type -P meson >/dev/null && \
+            [[ "$(meson configure $BUILD_DIR | grep install-tests | awk '{ print $2 }')" != "true" ]]; then
         dfatal "Needs to be built with -Dinstall-tests=true"
         exit 1
     fi