]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: fix test with -Dnetworkd=false
authorDavid Tardon <dtardon@redhat.com>
Tue, 27 Jan 2026 13:41:27 +0000 (14:41 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 29 Jan 2026 12:12:34 +0000 (21:12 +0900)
User and group systemd-network are created from
sysusers.d/systemd-network.conf, which is only copied into the test
image when building with -Dnetworkd=true. This means that if
-Dnetworkd=false is used, the user and the group don't exist, which
causes the test to fail.

Use a locally created user and group to avoid that.

test/units/TEST-74-AUX-UTILS.userdbctl.sh

index e31c6553d52501e82ce33b6bbe06133bd78cb4aa..40818bfa6fe26565dec2a0eface3505cd856be03 100755 (executable)
@@ -6,6 +6,18 @@ set -o pipefail
 # shellcheck source=test/units/util.sh
 . "$(dirname "$0")"/util.sh
 
+cleanup() {
+    set +e
+    userdel -r test-74-userdbctl
+    groupdel test-74-userdbctl
+}
+
+trap cleanup EXIT
+
+systemd-sysusers - <<EOF
+u test-74-userdbctl - "Test user for TEST-74-AUX-UTILS.userdbctl.sh" / /bin/bash
+EOF
+
 # Root
 userdbctl user root
 userdbctl user 0
@@ -40,11 +52,11 @@ assert_eq "$(userdbctl user 2147418110 -j | jq -r .userName)" foreign-65534
 
 # Make sure that -F shows same data as if we'd ask directly
 userdbctl user root -j | userdbctl -F- user  | cmp - <(userdbctl user root)
-userdbctl user systemd-network -j | userdbctl -F- user  | cmp - <(userdbctl user systemd-network)
+userdbctl user test-74-userdbctl -j | userdbctl -F- user  | cmp - <(userdbctl user test-74-userdbctl)
 userdbctl user 65534 -j | userdbctl -F- user  | cmp - <(userdbctl user 65534)
 
 userdbctl group root -j | userdbctl -F- group  | cmp - <(userdbctl group root)
-userdbctl group systemd-network -j | userdbctl -F- group  | cmp - <(userdbctl group systemd-network)
+userdbctl group test-74-userdbctl -j | userdbctl -F- group  | cmp - <(userdbctl group test-74-userdbctl)
 userdbctl group 65534 -j | userdbctl -F- group  | cmp - <(userdbctl group 65534)
 
 # Ensure NSS doesn't try to automount via open_tree