From: Collin Funk Date: Fri, 20 Feb 2026 03:13:34 +0000 (-0800) Subject: tests: chmod: test that chmod(2) is always called X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d233ebd7d9e36208f5bc03935f910de4c3283dd1;p=thirdparty%2Fcoreutils.git tests: chmod: test that chmod(2) is always called * tests/chmod/only-op.sh: New file. * tests/local.mk (all_test): Add the new test. --- diff --git a/tests/chmod/only-op.sh b/tests/chmod/only-op.sh new file mode 100755 index 0000000000..a2fd2546a7 --- /dev/null +++ b/tests/chmod/only-op.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Test that 'chmod' does not skip calling chmod(2) even when the file mode bits +# are unchanged. + +# Copyright (C) 2026 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ chmod stat +skip_if_root_ + +test "$(stat --format=%U /)" = 'root' || skip_ 'root does not own /' + +for op in '+' '-' '='; do + returns_ 1 chmod "$op" / 2>err || fail=1 + grep -F "chmod: changing permissions of '/'" err || { fail=1; cat err; } +done + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk index 5f9f3d19b6..aa71951f86 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -517,6 +517,7 @@ all_tests = \ tests/chmod/ignore-symlink.sh \ tests/chmod/inaccessible.sh \ tests/chmod/octal.sh \ + tests/chmod/only-op.sh \ tests/chmod/partial-fail.sh \ tests/chmod/setgid.sh \ tests/chmod/silent.sh \