Skip to content

Commit

Permalink
test/TEST-01: allow running w/o -Dinstall-tests=true
Browse files Browse the repository at this point in the history
This is useful for sanitizer builds under CI, see
systemd/systemd-centos-ci#202 (comment).
  • Loading branch information
keszybz committed Mar 27, 2020
1 parent 2736ffe commit 56cd3de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions test/TEST-01-BASIC/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion test/test-functions
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 56cd3de

Please sign in to comment.