tests: chmod: ensure --reference processes operands in order

Reported at https://github.com/uutils/coreutils/issues/15666

* tests/chmod/reference-order.sh: New test.
* tests/local.mk: Reference the new test.

Link: https://github.com/coreutils/coreutils/pull/410
This commit is contained in:
Sylvestre Ledru authored and Pádraig Brady committed 2026-11-07 12:35:10 +00:00
1 parent 529612a8ae
commit d1f6125ecf
2 files changed
+42

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
# Ensure chmod --reference processes operands in command-line order
# 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 <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ chmod
touch ref c a b || framework_failure_
chmod 644 ref && chmod 600 c a b || framework_failure_
chmod -v --reference=ref c a b > out || fail=1
cat <<\EOF > exp || framework_failure_
mode of 'c' changed from 0600 (rw-------) to 0644 (rw-r--r--)
mode of 'a' changed from 0600 (rw-------) to 0644 (rw-r--r--)
mode of 'b' changed from 0600 (rw-------) to 0644 (rw-r--r--)
EOF
compare exp out || fail=1
# The reference mode removes the search bit from dir, so dir/file
# must be handled before dir.
mkdir dir && touch dir/file || framework_failure_
chmod 600 dir/file || framework_failure_
chmod --reference=ref dir/file dir || fail=1
chmod 755 dir || framework_failure_
test "$(stat -c %a dir/file)" = 644 || fail=1
Exit $fail
+1
View File
@@ -574,6 +574,7 @@ all_tests = \
tests/chmod/octal.sh \
tests/chmod/only-op.sh \
tests/chmod/partial-fail.sh \
tests/chmod/reference-order.sh \
tests/chmod/setgid.sh \
tests/chmod/silent.sh \
tests/chmod/thru-dangling.sh \