1
0
mirror of https://github.com/systemd/systemd synced 2024-07-05 17:39:42 +00:00

test: "detect" the test number automagically

Specifying the test number manually is tedious and prone to errors (as
recently proven). Since we have all the necessary data to work out the
test number, let's do it automagically.
This commit is contained in:
Frantisek Sumsal 2021-04-26 19:20:18 +02:00
parent 732a487fad
commit c4cd6205e0
54 changed files with 67 additions and 56 deletions

View File

@ -16,4 +16,4 @@ test_append_files() {
cp -v "$TEST_UNITS_DIR"/{testsuite-01,end}.service "$TEST_UNITS_DIR/testsuite.target" "$dst"
}
do_test "$@" 01
do_test "$@"

View File

@ -71,4 +71,4 @@ check_result_qemu() {
return $ret
}
do_test "$@" 02
do_test "$@"

View File

@ -8,4 +8,4 @@ IMAGE_NAME="default"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 03
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="Journal-related tests"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 04
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="Resource limits-related tests"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 05
do_test "$@"

View File

@ -54,4 +54,4 @@ test_append_files() {
)
}
do_test "$@" 06
do_test "$@"

View File

@ -9,4 +9,4 @@ TEST_NO_QEMU=1
NSPAWN_TIMEOUT=30
do_test "$@" 07
do_test "$@"

View File

@ -12,4 +12,4 @@ QEMU_TIMEOUT=300
FSTYPE=ext4
TEST_FORCE_NEWIMAGE=1
do_test "$@" 08
do_test "$@"

View File

@ -9,4 +9,4 @@ TEST_NO_NSPAWN=1
QEMU_TIMEOUT=300
do_test "$@" 09
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 10
do_test "$@"

View File

@ -7,4 +7,4 @@ TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 11
do_test "$@"

View File

@ -7,4 +7,4 @@ TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 12
do_test "$@"

View File

@ -17,4 +17,4 @@ test_append_files() {
)
}
do_test "$@" 13
do_test "$@"

View File

@ -12,4 +12,4 @@ test_append_files() {
printf "556f48e837bc4424a710fa2e2c9d3e3c\ne3d\n" >"${1:?}/etc/machine-id"
}
do_test "$@" 14
do_test "$@"

View File

@ -7,4 +7,4 @@ TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 15
do_test "$@"

View File

@ -8,4 +8,4 @@ TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 16
do_test "$@"

View File

@ -17,4 +17,4 @@ test_append_files() {
)
}
do_test "$@" 17
do_test "$@"

View File

@ -8,4 +8,4 @@ TEST_DESCRIPTION="FailureAction= operation"
QEMU_TIMEOUT=600
do_test "$@" 18
do_test "$@"

View File

@ -10,4 +10,4 @@ TEST_NO_NSPAWN=1
QEMU_TIMEOUT=600
UNIFIED_CGROUP_HIERARCHY=yes
do_test "$@" 19
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test changing main PID"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 20
do_test "$@"

View File

@ -18,4 +18,4 @@ test_append_files() {
fi
}
do_test "$@" 22
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test Type=exec"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 23
do_test "$@"

View File

@ -86,4 +86,4 @@ test_setup_cleanup() {
cleanup_initdir
}
do_test "$@" 24
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test importd"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 25
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test setenv"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 26
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test StandardOutput=file:"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 27
do_test "$@"

View File

@ -7,4 +7,4 @@ RUN_IN_UNPRIVILEGED_CONTAINER=yes
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 28
do_test "$@"

View File

@ -27,4 +27,4 @@ test_append_files() {
)
}
do_test "$@" 29
do_test "$@"

View File

@ -7,4 +7,4 @@ TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 30
do_test "$@"

View File

@ -9,4 +9,4 @@ TEST_NO_NSPAWN=1
QEMU_TIMEOUT=300
do_test "$@" 31
do_test "$@"

View File

@ -9,4 +9,4 @@ TEST_NO_NSPAWN=1
UNIFIED_CGROUP_HIERARCHY=yes
do_test "$@" 32
do_test "$@"

View File

@ -8,4 +8,4 @@ TEST_DESCRIPTION="test CleanUnit"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 33
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test migrating state directory from DynamicUser=1 to DynamicUs
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 34
do_test "$@"

View File

@ -13,4 +13,4 @@ else
QEMU_OPTIONS="-numa node,nodeid=0"
fi
do_test "$@" 36
do_test "$@"

View File

@ -8,4 +8,4 @@ TEST_DESCRIPTION="test RuntimeDirectoryPreserve=yes"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 37
do_test "$@"

View File

@ -7,4 +7,4 @@ TEST_NO_NSPAWN=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 38
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="Test ExecReload= (PR #13098)"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 39
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test ExecXYZEx= service unit dbus hookups"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 40
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="Test oneshot unit restart on failure"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 41
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test that ExecStopPost= is always run"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 42
do_test "$@"

View File

@ -8,4 +8,4 @@ TEST_DESCRIPTION="Test PrivateUsers=yes on user manager"
has_user_dbus_socket || exit 0
do_test "$@" 43
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test log namespaces"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 44
do_test "$@"

View File

@ -7,4 +7,4 @@ TEST_NO_QEMU=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 46
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="Test that KillMode=mixed does not leave left over processes wi
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 47
do_test "$@"

View File

@ -8,4 +8,4 @@ TEST_DESCRIPTION="test StartStopNoReload"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 48
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test adding new BindPaths while unit is already running"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 49
do_test "$@"

View File

@ -30,4 +30,4 @@ test_append_files() {
)
}
do_test "$@" 50
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="Test ExecCondition= does not restart on abnormal or failure"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 51
do_test "$@"

View File

@ -9,4 +9,4 @@ QEMU_OPTIONS="-rtc base=$(date -u +%Y-%m-%dT%H:%M:%S -d '+3 days')"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 53
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test credentials"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 54
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_DESCRIPTION="test ExitType=cgroup"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" 56
do_test "$@"

View File

@ -4,4 +4,4 @@ TEST_DESCRIPTION="test systemd-repart"
TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
do_test "$@" 58
do_test "$@"

View File

@ -6,4 +6,4 @@ TEST_NO_QEMU=1
. $TEST_BASE_DIR/test-functions
do_test "$@" 59
do_test "$@"

View File

@ -57,7 +57,7 @@ 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[0]}")")}
TEST_UNITS_DIR="$TEST_BASE_DIR/units"
TEST_UNITS_DIR="$(realpath "$TEST_BASE_DIR/units")"
SOURCE_DIR=$(realpath "$TEST_BASE_DIR/..")
TOOLS_DIR="$SOURCE_DIR/tools"
# These variables are used by test scripts
@ -91,6 +91,17 @@ STATEFILE="$STATEDIR/.testdir"
IMAGESTATEDIR="$STATEDIR/.."
TESTLOG="$STATEDIR/test.log"
if ! [[ "$TESTNAME" =~ ^TEST\-([0-9]+)\-.+$ ]]; then
echo "ERROR: Test name '$TESTNAME' is not in the expected format: TEST-[0-9]+-*" >&2
exit 1
fi
TESTID="${BASH_REMATCH[1]:?}"
if [[ ! -f "$TEST_UNITS_DIR/testsuite-$TESTID.service" ]]; then
echo "ERROR: Test '$TESTNAME' is missing its service file '$TEST_UNITS_DIR/testsuite-$TESTID.service" >&2
exit 1
fi
BASICTOOLS=(
awk
basename
@ -2444,7 +2455,7 @@ do_test() {
case $1 in
--run)
echo "${testname} RUN: $TEST_DESCRIPTION"
test_run "$2"
test_run "$TESTID"
ret=$?
if [ $ret -eq 0 ]; then
echo "${testname} RUN: $TEST_DESCRIPTION [OK]"
@ -2475,7 +2486,7 @@ do_test() {
test_setup_cleanup </dev/null >>"$TESTLOG" 2>&1 || ret=$?
fi
if [ $ret -eq 0 ]; then
test_run "$2" </dev/null >>"$TESTLOG" 2>&1 || ret=$?
test_run "$TESTID" </dev/null >>"$TESTLOG" 2>&1 || ret=$?
fi
test_cleanup
if [ $ret -eq 0 ]; then