]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Work around unreadable file test failure when root
authorMartin Schwenke <martin@meltin.net>
Fri, 22 Jul 2022 01:05:21 +0000 (11:05 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 22 Jul 2022 16:09:31 +0000 (16:09 +0000)
root can read files for which the mode prohibits reading, so this test
case fails when run as root.  Work around this when running as root.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/UNIT/cunit/tunable_test_001.sh

index 2ae87f6f1fd963d1e9aa540a8738f009bce83db5..c68cd69c64a0b969a95fcb9b6a4e5985f0d8d869 100755 (executable)
@@ -98,9 +98,15 @@ ok_tunable ()
 test_case "Unreadable file"
 : >"$tfile"
 chmod a-r "$tfile"
-required_error EINVAL <<EOF
+uid=$(id -u)
+# root can read unreadable files
+if [ "$uid" = 0 ]; then
+       ok_tunable_defaults
+else
+       required_error EINVAL <<EOF
 ctdb_tunable_load_file: Failed to open ${tfile}
 EOF
+fi
 unit_test tunable_test "$tfile"
 rm -f "$tfile"