From: Dan Streetman Date: Tue, 17 Nov 2020 20:39:37 +0000 (-0500) Subject: test: find $BUILD_DIR in test-functions, remove from other scripts X-Git-Tag: v248-rc1~246^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=12d31e4ea50583c2aa39573f3d544f08492d5d61;p=thirdparty%2Fsystemd.git test: find $BUILD_DIR in test-functions, remove from other scripts The $BUILD_DIR is only used in test-functions, and doesn't need to be specified in any other scripts. Additionally, to be able to allow the integration test suite to be run against locally installed binaries, instead of built binaries, moving BUILD_DIR logic completely into test-functions allows later patches to be simpler. --- diff --git a/test/README.testsuite b/test/README.testsuite index 1b4736013dc..a05a9936a69 100644 --- a/test/README.testsuite +++ b/test/README.testsuite @@ -8,7 +8,7 @@ $ sudo test/run-integration-tests.sh ninja: Entering directory `/home/zbyszek/src/systemd/build' ninja: no work to do. --x-- Running TEST-01-BASIC --x-- -+ make -C TEST-01-BASIC BUILD_DIR=/home/zbyszek/src/systemd/build clean setup run ++ make -C TEST-01-BASIC clean setup run make: Entering directory '/home/zbyszek/src/systemd/test/TEST-01-BASIC' TEST-01-BASIC CLEANUP: Basic systemd setup TEST-01-BASIC SETUP: Basic systemd setup @@ -17,7 +17,7 @@ TEST-01-BASIC RUN: Basic systemd setup [OK] make: Leaving directory '/home/zbyszek/src/systemd/test/TEST-01-BASIC' --x-- Result of TEST-01-BASIC: 0 --x-- --x-- Running TEST-02-CRYPTSETUP --x-- -+ make -C TEST-02-CRYPTSETUP BUILD_DIR=/home/zbyszek/src/systemd/build clean setup run ++ make -C TEST-02-CRYPTSETUP clean setup run If one of the tests fails, then $subdir/test.log contains the log file of the test. diff --git a/test/TEST-01-BASIC/Makefile b/test/TEST-01-BASIC/Makefile index bee382b8b1c..9b90a1c2bc3 100644 --- a/test/TEST-01-BASIC/Makefile +++ b/test/TEST-01-BASIC/Makefile @@ -1,6 +1,4 @@ -BUILD_DIR=$(shell ../../tools/find-build-dir.sh) - all setup run clean clean-again: - @TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@ + @TEST_BASE_DIR=../ ./test.sh --$@ .PHONY: all setup run clean clean-again diff --git a/test/TEST-52-HONORFIRSTSHUTDOWN/Makefile b/test/TEST-52-HONORFIRSTSHUTDOWN/Makefile index 46a28ac810e..71487d70760 100644 --- a/test/TEST-52-HONORFIRSTSHUTDOWN/Makefile +++ b/test/TEST-52-HONORFIRSTSHUTDOWN/Makefile @@ -1,7 +1,5 @@ -BUILD_DIR=$(shell ../../tools/find-build-dir.sh) - all setup run clean clean-again: - @TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@ + @TEST_BASE_DIR=../ ./test.sh --$@ # finish option is used to run checks that can only be run outside of # the test execution. Example case, honor first shutdown, proof is obtained @@ -11,6 +9,6 @@ all setup run clean clean-again: # the test will loop and will be terminated via a command timeout. # This just provides concrete confirmation. finish: - @TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./fini.sh --$@ + @TEST_BASE_DIR=../ ./fini.sh --$@ .PHONY: all setup run clean clean-again finish diff --git a/test/run-integration-tests.sh b/test/run-integration-tests.sh index e9307601ff0..219216ac566 100755 --- a/test/run-integration-tests.sh +++ b/test/run-integration-tests.sh @@ -22,7 +22,7 @@ cd "$(dirname "$0")" # cache. if [ $do_clean = 1 ]; then for TEST in TEST-??-* ; do - ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" clean ) + ( set -x ; make -C "$TEST" clean ) done [ -n "$args_no_clean" ] || exit 0 @@ -46,7 +46,7 @@ for TEST in TEST-??-* ; do echo -e "\n--x-- Running $TEST --x--" set +e - ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args_no_clean ) + ( set -x ; make -C "$TEST" $args_no_clean ) RESULT=$? set -e echo "--x-- Result of $TEST: $RESULT --x--" @@ -59,7 +59,7 @@ done if [ $FAILURES -eq 0 -a $do_clean = 1 ]; then for TEST in ${!results[@]}; do - ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" clean-again ) + ( set -x ; make -C "$TEST" clean-again ) done fi diff --git a/test/test-functions b/test/test-functions index 928d3fc0ad6..947ba223573 100644 --- a/test/test-functions +++ b/test/test-functions @@ -49,6 +49,12 @@ TEST_UNITS_DIR="$TEST_BASE_DIR/units" SOURCE_DIR=$(realpath "$TEST_BASE_DIR/..") TOOLS_DIR="$SOURCE_DIR/tools" +# note that find-build-dir.sh will return $BUILD_DIR if provided, else it will try to find it +if ! BUILD_DIR=$($TOOLS_DIR/find-build-dir.sh); then + echo "ERROR: no build found, please set BUILD_DIR" >&2 + exit 1 +fi + PATH_TO_INIT=$ROOTLIBDIR/systemd [ "$SYSTEMD_JOURNALD" ] || SYSTEMD_JOURNALD=$(which -a $BUILD_DIR/systemd-journald $ROOTLIBDIR/systemd-journald 2>/dev/null | grep '^/' -m1) [ "$SYSTEMD_JOURNAL_REMOTE" ] || SYSTEMD_JOURNAL_REMOTE=$(which -a $BUILD_DIR/systemd-journal-remote $ROOTLIBDIR/systemd-journal-remote 2>/dev/null | grep '^/' -m1)