1
0
mirror of https://github.com/systemd/systemd synced 2026-03-14 00:54:46 +01:00

Compare commits

..

No commits in common. "1ceaad69378272c64da4ecaab0d59ebb7a92ca0a" and "732a487fadfe66dcd910183d68131d3b8e3bbbe6" have entirely different histories.

63 changed files with 92 additions and 101 deletions

View File

@ -166,7 +166,6 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
if (!result) if (!result)
return -EINVAL; return -EINVAL;
if (all || !isempty(result))
bus_print_property_value(name, expected_value, value, result); bus_print_property_value(name, expected_value, value, result);
} else if (STR_IN_SET(name, "CapabilityBoundingSet", "AmbientCapabilities")) { } else if (STR_IN_SET(name, "CapabilityBoundingSet", "AmbientCapabilities")) {
@ -176,7 +175,6 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
if (r < 0) if (r < 0)
return r; return r;
if (all || !isempty(s))
bus_print_property_value(name, expected_value, value, s); bus_print_property_value(name, expected_value, value, s);
} else if ((STR_IN_SET(name, "CPUWeight", "StartupCPUWeight", "IOWeight", "StartupIOWeight") && u == CGROUP_WEIGHT_INVALID) || } else if ((STR_IN_SET(name, "CPUWeight", "StartupCPUWeight", "IOWeight", "StartupIOWeight") && u == CGROUP_WEIGHT_INVALID) ||

View File

@ -1425,7 +1425,6 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
if (n < 0) if (n < 0)
return log_oom(); return log_oom();
if (all || !isempty(h))
bus_print_property_value(name, expected_value, value, h); bus_print_property_value(name, expected_value, value, h);
return 1; return 1;
@ -1627,7 +1626,6 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
if (!affinity) if (!affinity)
return log_oom(); return log_oom();
if (all || !isempty(affinity))
bus_print_property_value(name, expected_value, value, affinity); bus_print_property_value(name, expected_value, value, affinity);
return 1; return 1;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -0,0 +1,14 @@
all setup run clean clean-again:
@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
# from the console output as the image shuts down. This does not show up in
# the journal so the output from the do_test is captured in a file in /tmp.
# Without the use of finish the test will still pass because if it fails
# the test will loop and will be terminated via a command timeout.
# This just provides concrete confirmation.
finish:
@TEST_BASE_DIR=../ ./fini.sh --$@
.PHONY: all setup run clean clean-again finish

View File

@ -0,0 +1,10 @@
#!/bin/bash
TEST_DESCRIPTION="test honor first shutdown"
if grep -q "Shutdown is already active. Skipping emergency action request" /tmp/honorfirstshutdown.log; then
echo "$TEST_DESCRIPTION [pass]"
exit 0
else
echo "$TEST_DESCRIPTION [fail]"
exit 1
fi

View File

@ -18,10 +18,4 @@ NSPAWN_TIMEOUT=20
# only found from the console during the poweroff. # only found from the console during the poweroff.
rm -f /tmp/honorfirstshutdown.log >/dev/null rm -f /tmp/honorfirstshutdown.log >/dev/null
check_result_nspawn_hook() { do_test "$@" 52 >/tmp/honorfirstshutdown.log
grep -q "Shutdown is already active. Skipping emergency action request" /tmp/honorfirstshutdown.log
}
# Note: don't use a pipe in the following expression, as it breaks the trap
# handlers we have defined in test/test-functions.
do_test "$@" > >(tee /tmp/honorfirstshutdown.log)

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 # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions" . "${TEST_BASE_DIR:?}/test-functions"
do_test "$@" do_test "$@" 53

View File

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

View File

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

View File

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

View File

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

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 # 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_BASE_DIR=${TEST_BASE_DIR:-$(realpath "$(dirname "${BASH_SOURCE[0]}")")}
TEST_UNITS_DIR="$(realpath "$TEST_BASE_DIR/units")" TEST_UNITS_DIR="$TEST_BASE_DIR/units"
SOURCE_DIR=$(realpath "$TEST_BASE_DIR/..") SOURCE_DIR=$(realpath "$TEST_BASE_DIR/..")
TOOLS_DIR="$SOURCE_DIR/tools" TOOLS_DIR="$SOURCE_DIR/tools"
# These variables are used by test scripts # These variables are used by test scripts
@ -91,17 +91,6 @@ STATEFILE="$STATEDIR/.testdir"
IMAGESTATEDIR="$STATEDIR/.." IMAGESTATEDIR="$STATEDIR/.."
TESTLOG="$STATEDIR/test.log" 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=( BASICTOOLS=(
awk awk
basename basename
@ -1174,14 +1163,6 @@ check_result_nspawn() {
check_result_common "${workspace}" check_result_common "${workspace}"
ret=$? ret=$?
# Run additional test-specific checks if defined by check_result_nspawn_hook()
if declare -F check_result_nspawn_hook >/dev/null; then
if ! check_result_nspawn_hook; then
derror "check_result_nspawn_hook() returned with EC > 0"
ret=4
fi
fi
_umount_dir "${initdir:?}" _umount_dir "${initdir:?}"
return $ret return $ret
@ -1197,14 +1178,6 @@ check_result_qemu() {
_umount_dir "${initdir:?}" _umount_dir "${initdir:?}"
# Run additional test-specific checks if defined by check_result_qemu_hook()
if declare -F check_result_qemu_hook >/dev/null; then
if ! check_result_qemu_hook; then
derror "check_result_qemu_hook() returned with EC > 0"
ret=4
fi
fi
return $ret return $ret
} }
@ -2471,7 +2444,7 @@ do_test() {
case $1 in case $1 in
--run) --run)
echo "${testname} RUN: $TEST_DESCRIPTION" echo "${testname} RUN: $TEST_DESCRIPTION"
test_run "$TESTID" test_run "$2"
ret=$? ret=$?
if [ $ret -eq 0 ]; then if [ $ret -eq 0 ]; then
echo "${testname} RUN: $TEST_DESCRIPTION [OK]" echo "${testname} RUN: $TEST_DESCRIPTION [OK]"
@ -2502,7 +2475,7 @@ do_test() {
test_setup_cleanup </dev/null >>"$TESTLOG" 2>&1 || ret=$? test_setup_cleanup </dev/null >>"$TESTLOG" 2>&1 || ret=$?
fi fi
if [ $ret -eq 0 ]; then if [ $ret -eq 0 ]; then
test_run "$TESTID" </dev/null >>"$TESTLOG" 2>&1 || ret=$? test_run "$2" </dev/null >>"$TESTLOG" 2>&1 || ret=$?
fi fi
test_cleanup test_cleanup
if [ $ret -eq 0 ]; then if [ $ret -eq 0 ]; then

View File

@ -2,5 +2,5 @@
Description=Testsuite service Description=Testsuite service
[Service] [Service]
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh ExecStart=/usr/lib/systemd/tests/testdata/%N.units/%N.sh
Type=oneshot Type=oneshot

View File

@ -2,6 +2,11 @@
set -ex set -ex
set -o pipefail set -o pipefail
if ! test -x /usr/lib/systemd/tests/testdata/units/test-honor-first-shutdown.sh ; then
echo "honor-first-shutdown script not found - FAIL" >/testok
exit 0
fi
systemd-analyze log-level debug systemd-analyze log-level debug
systemd-analyze log-target console systemd-analyze log-target console

View File

@ -3,7 +3,7 @@ Description=Honor First Shutdown feature
After=multi-user.target After=multi-user.target
[Service] [Service]
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-52.units/%N.sh ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
ExecStop=sh -c 'kill -KILL $MAINPID' ExecStop=sh -c 'kill -KILL $MAINPID'
FailureAction=reboot FailureAction=reboot