summaryrefslogtreecommitdiff
path: root/test/test-functions
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@canonical.com>2021-01-26 16:46:10 -0500
committerDan Streetman <ddstreet@canonical.com>2021-01-26 17:09:39 -0500
commit42f3b48c975bd45b489dff08df5e374d3e3bfb5f (patch)
treef17caa63556e5a983d319376d2e7e5845a88d2a2 /test/test-functions
parent1918406900c2b687cca867d32441ec98f05b16ea (diff)
downloadsystemd-42f3b48c975bd45b489dff08df5e374d3e3bfb5f.tar.gz
test/test-functions: add variables for several dir locations
Diffstat (limited to 'test/test-functions')
-rw-r--r--test/test-functions14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/test-functions b/test/test-functions
index f6a824ae69..928d3fc0ad 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -43,6 +43,12 @@ if ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then
ROOTLIBDIR=/usr/lib/systemd
fi
+# The calling test.sh scripts have TEST_BASE_DIR set via their Makefile, but we don't need them to provide it
+TEST_BASE_DIR=${TEST_BASE_DIR:-$(realpath $(dirname "$BASH_SOURCE"))}
+TEST_UNITS_DIR="$TEST_BASE_DIR/units"
+SOURCE_DIR=$(realpath "$TEST_BASE_DIR/..")
+TOOLS_DIR="$SOURCE_DIR/tools"
+
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)
@@ -50,7 +56,13 @@ PATH_TO_INIT=$ROOTLIBDIR/systemd
[ "$SYSTEMD_NSPAWN" ] || SYSTEMD_NSPAWN=$(which -a $BUILD_DIR/systemd-nspawn systemd-nspawn 2>/dev/null | grep '^/' -m1)
[ "$JOURNALCTL" ] || JOURNALCTL=$(which -a $BUILD_DIR/journalctl journalctl 2>/dev/null | grep '^/' -m1)
-STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
+TESTFILE=${BASH_SOURCE[1]}
+if [ -z "$TESTFILE" ]; then
+ echo "ERROR: test-functions must be sourced from one of the TEST-*/test.sh scripts" >&2
+ exit 1
+fi
+TESTNAME=$(basename $(dirname $(realpath $TESTFILE)))
+STATEDIR="$BUILD_DIR/test/$TESTNAME"
STATEFILE="$STATEDIR/.testdir"
IMAGESTATEDIR="$STATEDIR/.."
TESTLOG="$STATEDIR/test.log"