From 454edd9e7a122816b140e30e5824c07e8cd4b5ff Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 29 Jul 2025 12:27:18 +0900 Subject: [PATCH 1/3] TEST-46-HOMED: modernize test - use command to check the existence of homectl, - use timeout for waiting user, - use 4ch indentation. --- test/units/TEST-46-HOMED.sh | 68 ++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/test/units/TEST-46-HOMED.sh b/test/units/TEST-46-HOMED.sh index e69323df53..2c0dbd22a9 100755 --- a/test/units/TEST-46-HOMED.sh +++ b/test/units/TEST-46-HOMED.sh @@ -6,9 +6,9 @@ set -eux set -o pipefail # Check if homectl is installed, and if it isn't bail out early instead of failing -if ! test -x /usr/bin/homectl ; then - echo "no homed" >/skipped - exit 77 +if ! command -v homectl >/dev/null; then + echo "no homed" >/skipped + exit 77 fi inspect() { @@ -29,19 +29,11 @@ inspect() { } wait_for_exist() { - # 2min max - for i in {1..60}; do - (( i > 1 )) && sleep 2 - homectl inspect "$1" && break - done + timeout 2m bash -c "until homectl inspect '${1:?}'; do sleep 2; done" } wait_for_state() { - # 2min max - for i in {1..60}; do - (( i > 1 )) && sleep 2 - homectl inspect "$1" | grep -qF "State: $2" && break - done + timeout 2m bash -c "until homectl inspect '${1:?}' | grep -qF 'State: $2'; do sleep 2; done" } FSTYPE="$(stat --file-system --format "%T" /)" @@ -123,32 +115,32 @@ inspect test-user # Do some keyring tests, but only on real kernels, since keyring access inside of containers will fail # (See: https://github.com/systemd/systemd/issues/17606) if ! systemd-detect-virt -cq ; then - PASSWORD=xEhErW0ndafV4s homectl activate test-user - inspect test-user + PASSWORD=xEhErW0ndafV4s homectl activate test-user + inspect test-user - # Key should now be in the keyring - homectl update test-user --real-name "Keyring Test" - inspect test-user + # Key should now be in the keyring + homectl update test-user --real-name "Keyring Test" + inspect test-user - # These commands shouldn't use the keyring - (! timeout 5s homectl authenticate test-user ) - (! NEWPASSWORD="foobar" timeout 5s homectl passwd test-user ) + # These commands shouldn't use the keyring + (! timeout 5s homectl authenticate test-user ) + (! NEWPASSWORD="foobar" timeout 5s homectl passwd test-user ) - homectl lock test-user - inspect test-user + homectl lock test-user + inspect test-user - # Key should be gone from keyring - (! timeout 5s homectl update test-user --real-name "Keyring Test 2" ) + # Key should be gone from keyring + (! timeout 5s homectl update test-user --real-name "Keyring Test 2" ) - PASSWORD=xEhErW0ndafV4s homectl unlock test-user - inspect test-user + PASSWORD=xEhErW0ndafV4s homectl unlock test-user + inspect test-user - # Key should have been re-instantiated into the keyring - homectl update test-user --real-name "Keyring Test 3" - inspect test-user + # Key should have been re-instantiated into the keyring + homectl update test-user --real-name "Keyring Test 3" + inspect test-user - homectl deactivate test-user - inspect test-user + homectl deactivate test-user + inspect test-user fi # Do some resize tests, but only if we run on real kernels and are on btrfs, as quota inside of containers @@ -242,13 +234,13 @@ homectl remove test-user # blob directory tests # See docs/USER_RECORD_BLOB_DIRS.md checkblob() { - test -f "/var/cache/systemd/home/blob-user/$1" - stat -c "%u %#a" "/var/cache/systemd/home/blob-user/$1" | grep "^0 0644" - test -f "/home/blob-user/.identity-blob/$1" - stat -c "%u %#a" "/home/blob-user/.identity-blob/$1" | grep "^12345 0644" + test -f "/var/cache/systemd/home/blob-user/$1" + stat -c "%u %#a" "/var/cache/systemd/home/blob-user/$1" | grep "^0 0644" + test -f "/home/blob-user/.identity-blob/$1" + stat -c "%u %#a" "/home/blob-user/.identity-blob/$1" | grep "^12345 0644" - diff "/var/cache/systemd/home/blob-user/$1" "$2" - diff "/var/cache/systemd/home/blob-user/$1" "/home/blob-user/.identity-blob/$1" + diff "/var/cache/systemd/home/blob-user/$1" "$2" + diff "/var/cache/systemd/home/blob-user/$1" "/home/blob-user/.identity-blob/$1" } mkdir /tmp/blob1 /tmp/blob2 From f48068a379caae0c884b1364571f0d3283aeacf1 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 29 Jul 2025 12:29:12 +0900 Subject: [PATCH 2/3] TEST-46-HOMED: remove unnecessary users Workaround for issue #38240. --- test/units/TEST-46-HOMED.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/units/TEST-46-HOMED.sh b/test/units/TEST-46-HOMED.sh index 2c0dbd22a9..c52178dab1 100755 --- a/test/units/TEST-46-HOMED.sh +++ b/test/units/TEST-46-HOMED.sh @@ -632,6 +632,7 @@ EOF homedsshtest@localhost env wait_for_state homedsshtest inactive + homectl remove homedsshtest fi NEWPASSWORD=hunter4711 homectl create aliastest --storage=directory --alias=aliastest2 --alias=aliastest3 --realm=myrealm @@ -657,6 +658,8 @@ getent passwd aliastest@myrealm getent passwd aliastest2@myrealm getent passwd aliastest3@myrealm +homectl remove aliastest + NEWPASSWORD=quux homectl create tmpfsquota --storage=subvolume --dev-shm-limit=50K --tmp-limit=50K -P for p in /dev/shm /tmp; do if findmnt -n -o options "$p" | grep -q usrquota; then From 5ad6fe9850e0ecad7415bfbdd547d07b9b1177c7 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 29 Jul 2025 13:02:25 +0900 Subject: [PATCH 3/3] TEST-64-UDEV-STORAGE: clear MD superblock on exit Workaround for issue #38240. --- test/units/TEST-64-UDEV-STORAGE.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/units/TEST-64-UDEV-STORAGE.sh b/test/units/TEST-64-UDEV-STORAGE.sh index 69ca6e4d7a..af93532625 100755 --- a/test/units/TEST-64-UDEV-STORAGE.sh +++ b/test/units/TEST-64-UDEV-STORAGE.sh @@ -1186,6 +1186,12 @@ EOF helper_check_device_units # Cleanup mdadm -v --stop "$raid_dev" + + # Clear superblocks to make the MD device will not be restarted even if the VM is restarted. + # This is a workaround for issue #38240. + mdadm -v --zero-superblock --force "${devices[@]}" + udevadm settle --timeout=30 + # Check if all expected symlinks were removed after the cleanup udevadm wait --settle --timeout=30 --removed "${expected_symlinks[@]}" helper_check_device_units @@ -1243,6 +1249,12 @@ testcase_mdadm_lvm() { # Cleanup lvm vgchange -an "$vgroup" mdadm -v --stop "$raid_dev" + + # Clear superblocks to make the MD device will not be restarted even if the VM is restarted. + # This is a workaround for issue #38240. + mdadm -v --zero-superblock --force "${devices[@]}" + udevadm settle --timeout=30 + # Check if all expected symlinks were removed after the cleanup udevadm wait --settle --timeout=30 --removed "${expected_symlinks[@]}" helper_check_device_units