From: Yu Watanabe Date: Sat, 29 Nov 2025 01:02:19 +0000 (+0900) Subject: integration-test: skip several test cases when nss module is not supported X-Git-Tag: v259-rc3~29^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5932060ed8b63a16170044d580ab732a2d34bd9;p=thirdparty%2Fsystemd.git integration-test: skip several test cases when nss module is not supported --- diff --git a/test/units/TEST-13-NSPAWN.nss-mymachines.sh b/test/units/TEST-13-NSPAWN.nss-mymachines.sh index a14c53154cc..e4a96167128 100755 --- a/test/units/TEST-13-NSPAWN.nss-mymachines.sh +++ b/test/units/TEST-13-NSPAWN.nss-mymachines.sh @@ -7,6 +7,10 @@ set -o pipefail # shellcheck source=test/units/util.sh . "$(dirname "$0")"/util.sh +if ! check_nss_module mymachine; then + exit 0 +fi + at_exit() { set +e diff --git a/test/units/TEST-46-HOMED.sh b/test/units/TEST-46-HOMED.sh index bb6d64bfed6..d7d29e08936 100755 --- a/test/units/TEST-46-HOMED.sh +++ b/test/units/TEST-46-HOMED.sh @@ -233,7 +233,13 @@ testcase_basic() { PASSWORD=xEhErW0ndafV4s homectl with test-user -- rm /home/test-user/xyz PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz (! PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz) - [[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- stat -c %U /home/test-user/hoge)" == "test-user" ]] + if check_nss_module systemd; then + [[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- stat -c %U /home/test-user/hoge)" == "test-user" ]] + [[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- stat -c %u /home/test-user/hoge)" == "$(id -u test-user)" ]] + fi + # The machine ID may start with a numeric, and in that case the field name must be quoted. + [[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- stat -c %u /home/test-user/hoge)" == \ + "$(homectl inspect --json=short test-user | jq .binding.\""$(cat /etc/machine-id)"\".uid)" ]] [[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- cat /home/test-user/hoge)" == "$(cat "$TMP_SKEL"/hoge)" ]] # Regression tests @@ -587,6 +593,11 @@ testcase_ssh() { return 0 fi + # 'ssh homedsshtest@localhost' requires systemd NSS module. + if ! check_nss_module systemd; then + return 0 + fi + if ! command -v ssh >/dev/null || ! command -v sshd >/dev/null; then echo "ssh/sshd is not installed, skipping the ssh test." return 0 @@ -690,17 +701,24 @@ testcase_alias() { userdbctl user aliastest2@myrealm userdbctl user aliastest3@myrealm - getent passwd aliastest - getent passwd aliastest2 - getent passwd aliastest3 - getent passwd aliastest@myrealm - getent passwd aliastest2@myrealm - getent passwd aliastest3@myrealm + if check_nss_module systemd; then + getent passwd aliastest + getent passwd aliastest2 + getent passwd aliastest3 + getent passwd aliastest@myrealm + getent passwd aliastest2@myrealm + getent passwd aliastest3@myrealm + fi homectl remove aliastest } testcase_quota() { + # 'run0 -u' requires systemd NSS module. + if ! check_nss_module systemd; then + return 0 + fi + 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 @@ -725,6 +743,11 @@ testcase_quota() { } testcase_subarea() { + # 'run0 -u' requires systemd NSS module. + if ! check_nss_module systemd; then + return 0 + fi + NEWPASSWORD=quux homectl create subareatest --storage=subvolume -P run0 --property=SetCredential=pam.authtok.systemd-run0:quux -u subareatest mkdir Areas run0 --property=SetCredential=pam.authtok.systemd-run0:quux -u subareatest cp -av /etc/skel Areas/furb diff --git a/test/units/TEST-71-HOSTNAME.sh b/test/units/TEST-71-HOSTNAME.sh index 8ec3bd6cfbf..ffb110be688 100755 --- a/test/units/TEST-71-HOSTNAME.sh +++ b/test/units/TEST-71-HOSTNAME.sh @@ -166,6 +166,10 @@ testcase_hardware_serial() { testcase_nss-myhostname() { local database host i + if ! check_nss_module myhostname; then + return 0 + fi + HOSTNAME="$(hostnamectl hostname)" # Set up a dummy network for _gateway and _outbound labels @@ -316,7 +320,6 @@ EOF assert_in "CHASSIS=watch" "$(cat /run/alternate-path/mymachine-info)" } - run_testcases touch /testok diff --git a/test/units/TEST-74-AUX-UTILS.capsule.sh b/test/units/TEST-74-AUX-UTILS.capsule.sh index 06f6a1ca6e2..c2c3073ea80 100755 --- a/test/units/TEST-74-AUX-UTILS.capsule.sh +++ b/test/units/TEST-74-AUX-UTILS.capsule.sh @@ -4,6 +4,13 @@ set -eux set -o pipefail +# shellcheck source=test/units/util.sh +. "$(dirname "$0")"/util.sh + +if ! check_nss_module systemd; then + exit 0 +fi + at_exit() { set +e systemctl --no-block stop capsule@foobar.service diff --git a/test/units/TEST-75-RESOLVED.sh b/test/units/TEST-75-RESOLVED.sh index 51820016dde..5ec588309bf 100755 --- a/test/units/TEST-75-RESOLVED.sh +++ b/test/units/TEST-75-RESOLVED.sh @@ -408,6 +408,11 @@ manual_testcase_02_mdns_llmnr() { testcase_03_23951() { : "--- nss-resolve/nss-myhostname tests" + + if ! check_nss_module resolve; then + return 0 + fi + # Sanity check TIMESTAMP=$(date '+%F %T') # Issue: https://github.com/systemd/systemd/issues/23951 @@ -426,6 +431,10 @@ testcase_03_23951() { } testcase_04_18812() { + if ! check_nss_module resolve; then + return 0 + fi + # Issue: https://github.com/systemd/systemd/issues/18812 # PR: https://github.com/systemd/systemd/pull/18896 # Follow-up issue: https://github.com/systemd/systemd/issues/23152 @@ -446,6 +455,10 @@ testcase_04_18812() { } testcase_05_25088() { + if ! check_nss_module resolve; then + return 0 + fi + # Issue: https://github.com/systemd/systemd/issues/25088 run getent -s resolve hosts 127.128.0.5 grep -qEx '127\.128\.0\.5\s+localhost5(\s+localhost5?\.localdomain[45]?){4}' "$RUN_OUT" diff --git a/test/units/util.sh b/test/units/util.sh index 445b71836ad..c62f8d9574b 100755 --- a/test/units/util.sh +++ b/test/units/util.sh @@ -458,3 +458,37 @@ built_with_musl() ( set +ex ! systemd-analyze --quiet condition 'ConditionVersion=glibc $= ?*' ) + +check_nss_module() ( + set +e + + local name="${1:?}" + local have= + local i + + if [[ ! -e /etc/nsswitch.conf ]]; then + : "/etc/nsswitch.conf not found." + return 1 + fi + + if ! find /usr/lib* -name "libnss_${name}.so.*" 2>/dev/null | grep . >/dev/null; then + : "NSS module $name not found." + return 1 + fi + + if [[ "$name" == systemd ]]; then + for i in passwd group shadow; do + if ! grep -qE "^$i:.*[[:space:]]*systemd" /etc/nsswitch.conf; then + : "systemd NSS module is not enabled for $i database." + return 1 + fi + done + else + if ! grep -qE "^hosts:.*[[:space:]]*$name" /etc/nsswitch.conf; then + : "$name NSS module is not enabled for hosts database." + return 1 + fi + fi + + return 0 +)