integration-test: skip several test cases when nss module is not supported
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user