]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-17-UDEV: conditionalize test cases for testuser
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Jul 2025 07:54:49 +0000 (16:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 11 Jul 2025 01:42:08 +0000 (10:42 +0900)
Then, we can also run the test script in our local machine.

test/units/TEST-17-UDEV.verify.sh

index 9580ba4ac1ee21c2f671601e9acd1f76622b80ac..b456fdef72698a9eef78b3ccda10c272fe154325 100755 (executable)
@@ -315,8 +315,10 @@ if ! getent passwd 12345 >/dev/null; then
     test_syntax_error 'OWNER="12345"' "Unknown user '12345', ignoring."
 fi
 # regular user
-test_syntax_error 'OWNER="testuser"' "User 'testuser' is not a system user, ignoring."
-test_syntax_error "OWNER=\"$(id -u testuser)\"" "User '$(id -u testuser)' is not a system user, ignoring."
+if getent passwd testuser >/dev/null; then
+    test_syntax_error 'OWNER="testuser"' "User 'testuser' is not a system user, ignoring."
+    test_syntax_error "OWNER=\"$(id -u testuser)\"" "User '$(id -u testuser)' is not a system user, ignoring."
+fi
 test_syntax_error 'GROUP{a}="b"' 'Invalid attribute for GROUP.'
 test_syntax_error 'GROUP-="b"' 'Invalid operator for GROUP.'
 test_syntax_error 'GROUP!="b"' 'Invalid operator for GROUP.'
@@ -345,8 +347,10 @@ if ! getent group 12345 >/dev/null; then
     test_syntax_error 'GROUP="12345"' "Unknown group '12345', ignoring."
 fi
 # regular group
-test_syntax_error 'GROUP="testuser"' "Group 'testuser' is not a system group, ignoring."
-test_syntax_error "GROUP=\"$(id -g testuser)\"" "Group '$(id -g testuser)' is not a system group, ignoring."
+if getent group testuser >/dev/null; then
+    test_syntax_error 'GROUP="testuser"' "Group 'testuser' is not a system group, ignoring."
+    test_syntax_error "GROUP=\"$(id -g testuser)\"" "Group '$(id -g testuser)' is not a system group, ignoring."
+fi
 test_syntax_error 'MODE{a}="b"' 'Invalid attribute for MODE.'
 test_syntax_error 'MODE-="b"' 'Invalid operator for MODE.'
 test_syntax_error 'MODE!="b"' 'Invalid operator for MODE.'