show_summary
}
+# Run all subtests (i.e. files named as testsuite-<testid>.<subtest_name>.sh)
run_subtests() {
local subtests=("${0%.sh}".*.sh)
local subtest
show_summary
}
+# Run all test cases (i.e. functions prefixed with testcase_ in the current namespace)
+run_testcases() {
+ local testcase testcases
+
+ # Create a list of all functions prefixed with testcase_
+ mapfile -t testcases < <(declare -F | awk '$3 ~ /^testcase_/ {print $3;}')
+
+ if [[ "${#testcases[@]}" -eq 0 ]]; then
+ echo >&2 "No test cases found, this is most likely an error"
+ exit 1
+ fi
+
+ for testcase in "${testcases[@]}"; do
+ : "+++ $testcase BEGIN +++"
+ # Note: the subshell here is used purposefully, otherwise we might
+ # unexpectedly inherit a RETURN trap handler from the called
+ # function and call it for the second time once we return,
+ # causing a "double-free"
+ ("$testcase")
+ : "+++ $testcase END +++"
+ done
+}
+
show_summary() {(
set +x
set -eux
set -o pipefail
+# shellcheck source=test/units/test-control.sh
+. "$(dirname "$0")"/test-control.sh
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
+
export SYSTEMD_LOG_LEVEL=debug
export SYSTEMD_LOG_TARGET=journal
return 0
}
-# Create a list of all functions prefixed with testcase_
-mapfile -t TESTCASES < <(declare -F | awk '$3 ~ /^testcase_/ {print $3;}')
-
-if [[ "${#TESTCASES[@]}" -eq 0 ]]; then
- echo >&2 "No test cases found, this is most likely an error"
- exit 1
-fi
-
-for testcase in "${TESTCASES[@]}"; do
- "$testcase"
-done
+run_testcases
for api_vfs_writable in yes no network; do
matrix_run_one no no $api_vfs_writable
set -eux
set -o pipefail
+# shellcheck source=test/units/test-control.sh
+. "$(dirname "$0")"/test-control.sh
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
export SYSTEMD_KBD_MODEL_MAP=/usr/lib/systemd/tests/testdata/test-keymap-util/kbd-model-map
enable_debug
-
-# Create a list of all functions prefixed with testcase_
-mapfile -t TESTCASES < <(declare -F | awk '$3 ~ /^testcase_/ {print $3;}')
-
-if [[ "${#TESTCASES[@]}" -eq 0 ]]; then
- echo >&2 "No test cases found, this is most likely an error"
- exit 1
-fi
-
-for testcase in "${TESTCASES[@]}"; do
- "$testcase"
-done
+run_testcases
touch /testok
rm /failed
set -eux
set -o pipefail
+# shellcheck source=test/units/test-control.sh
+. "$(dirname "$0")"/test-control.sh
+# shellcheck source=test/units/util.sh
+. "$(dirname "$0")"/util.sh
+
root_mock() {
local root="${1:?}"
systemctl --state=failed --no-legend --no-pager >/failed
test ! -s /failed
-# Create a list of all functions prefixed with testcase_
-mapfile -t TESTCASES < <(declare -F | awk '$3 ~ /^testcase_/ {print $3;}')
-
-if [[ "${#TESTCASES[@]}" -eq 0 ]]; then
- echo >&2 "No test cases found, this is most likely an error"
- exit 1
-fi
-
-for testcase in "${TESTCASES[@]}"; do
- "$testcase"
-done
+run_testcases