]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: use system EACCES message
authorPádraig Brady <P@draigBrady.com>
Mon, 16 Feb 2026 12:09:34 +0000 (12:09 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 18 Feb 2026 18:31:49 +0000 (18:31 +0000)
* tests/chgrp/no-x.sh: Don't harcode "Permission denied".
* tests/chmod/no-x.sh: Likewise.
* tests/du/inacc-dest.sh: Likewise.
* tests/du/no-x.sh: Likewise.
* tests/misc/nohup.sh: Likewise.
* tests/mv/part-fail.sh: Likewise.
* tests/mv/perm-1.sh: Likewise.
* tests/rm/fail-eacces.sh: Likewise.
* tests/rm/rm1.sh: Likewise.
* tests/rm/rm2.sh: Likewise.
* tests/rm/unread2.sh: Likewise.
* tests/rm/unreadable.pl: Likewise.

12 files changed:
tests/chgrp/no-x.sh
tests/chmod/no-x.sh
tests/du/inacc-dest.sh
tests/du/no-x.sh
tests/misc/nohup.sh
tests/mv/part-fail.sh
tests/mv/perm-1.sh
tests/rm/fail-eacces.sh
tests/rm/rm1.sh
tests/rm/rm2.sh
tests/rm/unread2.sh
tests/rm/unreadable.pl

index b20b92562743abce51f5260ea2a62cb1febb383c..8d160957f42fba230ea63910ae53f15506e75fee 100755 (executable)
@@ -22,6 +22,7 @@ print_ver_ chgrp
 require_membership_in_two_groups_
 skip_if_root_
 require_local_dir_
+getlimits_
 
 set _ $groups; shift
 g1=$1
@@ -47,7 +48,7 @@ sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out
 sed 's,d/no-x/y,d/no-x,' out > t && mv t out
 
 cat <<EOF > exp
-$prog: 'd/no-x': Permission denied
+$prog: 'd/no-x': $EACCES
 EOF
 
 compare exp out || fail=1
index 8a44836bf70bf10aa847710d81075dca382bed6e..bbf00375dffad52a595c30b07903a48b8d7561d9 100755 (executable)
@@ -20,6 +20,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ chmod
 skip_if_root_
+getlimits_
 
 mkdir -p d/no-x/y a/b || framework_failure_
 chmod u=rw d/no-x || framework_failure_
@@ -41,7 +42,7 @@ sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out
 sed 's,d/no-x/y,d/no-x,' out > t && mv t out
 
 cat <<EOF > exp
-$prog: 'd/no-x': Permission denied
+$prog: 'd/no-x': $EACCES
 EOF
 
 compare exp out || fail=1
index fc8e86817713e1d619cea41b6c110203e67c5a84..b578d76f1f450effe8f863e7bcd17e8386da9862 100755 (executable)
@@ -20,6 +20,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ du
 skip_if_root_
+getlimits_
 
 mkdir f && cd f && mkdir a b c d e && touch c/j && chmod a-x c \
     || framework_failure_
@@ -33,14 +34,14 @@ du > ../t 2>&1 && fail=1
 # /proc support, nor native openat support.
 
 sed 's/^[0-9][0-9]*    //' ../t | sort -u > out
-cat <<\EOF > exp || framework_failure_
+cat <<EOF > exp || framework_failure_
 .
 ./a
 ./b
 ./c
 ./d
 ./e
-du: cannot read directory './c': Permission denied
+du: cannot read directory './c': $EACCES
 EOF
 
 # Map a diagnostic like this
index f47e4ca5c7140a1c56ba7a04fa11124c45524e44..238b5d0223469665e35dd9aeea3b6d89d431eded 100755 (executable)
@@ -20,6 +20,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ du
 skip_if_root_
+getlimits_
 
 mkdir -p d/no-x/y || framework_failure_
 chmod u=rw d/no-x || framework_failure_
@@ -41,7 +42,7 @@ sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out
 sed 's,d/no-x/y,d/no-x,' out > t && mv t out
 
 cat <<EOF > exp
-$prog: 'd/no-x': Permission denied
+$prog: 'd/no-x': $EACCES
 EOF
 
 compare exp out || fail=1
index 08a486e0178fe72b9d3901f996a651c2ca9b1da5..5c9c9660666e7d7ea426005a87a3cba92c4fed14 100755 (executable)
@@ -18,7 +18,7 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ nohup
-
+getlimits_
 
 nohup sh -c 'echo stdout; echo stderr 1>&2' 2>err || fail=1
 
@@ -108,9 +108,9 @@ if test -t 1; then
   compare /dev/null nohup.out || fail=1
 fi
 
-cat <<\EOF > exp || framework_failure_
+cat <<EOF > exp || framework_failure_
 nohup: appending output to 'nohup.out'
-nohup: cannot run command './k': Permission denied
+nohup: cannot run command './k': $EACCES
 EOF
 # Disable these comparisons.  Too much variation in 2nd line.
 # compare exp err || fail=1
index 024eb9009926b708b24ca47b2666cc0ea8a57c6f..d3145bcb6d334381e244960b9a461478d4c73ccc 100755 (executable)
@@ -22,6 +22,8 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ mv
 skip_if_root_
+getlimits_
+
 cleanup_() { t=$other_partition_tmpdir; chmod -R 700 "$t"; rm -rf "$t"; }
 . "$abs_srcdir/tests/other-fs-tmpdir"
 
@@ -32,13 +34,13 @@ chmod u-w "$other_partition_tmpdir" || framework_failure_
 mv -f k "$other_partition_tmpdir" 2> out && fail=1
 printf \
 "mv: inter-device move failed: '%s' to '%s';"\
-' unable to remove target: Permission denied\n' \
-  k "$other_partition_tmpdir/k" >exp
+' unable to remove target: %s\n' \
+  k "$other_partition_tmpdir/k" "$EACCES" >exp
 
 # On some (less-compliant) systems, we get EPERM in this case.
 # Accept either diagnostic.
 cat <<EOF > exp2
-mv: cannot move 'k' to '$other_partition_tmpdir/k': Permission denied
+mv: cannot move 'k' to '$other_partition_tmpdir/k': $EACCES
 EOF
 
 if cmp out exp >/dev/null 2>&1; then
index d06677f94e7548a380357ec41468a1af42009a05..6d99f85578171ffe26cf43dc185fd9e8f37a9977 100755 (executable)
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ mv
 skip_if_root_
+getlimits_
 
 mkdir -p no-write/dir || framework_failure_
 chmod ug-w no-write || framework_failure_
 
 
 mv no-write/dir . > out 2>&1 && fail=1
-cat <<\EOF > exp
-mv: cannot move 'no-write/dir' to './dir': Permission denied
+cat <<EOF > exp
+mv: cannot move 'no-write/dir' to './dir': $EACCES
 EOF
 
 compare exp out || fail=1
index 69238e9e4bea55f35d2ac6f82178a1a182c59f97..e2d47e31fae706b0d998b18f6d39311bd643df3d 100755 (executable)
@@ -22,6 +22,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ rm
 skip_if_root_
+getlimits_
 
 ok=0
 mkdir d           &&
@@ -39,15 +40,15 @@ test $ok = 1 || framework_failure_
 
 
 rm -rf d/f 2> out && fail=1
-cat <<\EOF > exp
-rm: cannot remove 'd/f': Permission denied
+cat <<EOF > exp
+rm: cannot remove 'd/f': $EACCES
 EOF
 compare exp out || fail=1
 
 # This used to fail with ELOOP.
 rm -rf e 2> out && fail=1
-cat <<\EOF > exp
-rm: cannot remove 'e/slink': Permission denied
+cat <<EOF > exp
+rm: cannot remove 'e/slink': $EACCES
 EOF
 compare exp out || fail=1
 
index 025c5341a02a3755ccc8811b5955e3b96997d2e0..5a9b6c4369390ee71f701294cf3de8622639c8b7 100755 (executable)
@@ -19,6 +19,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ rm
 skip_if_root_
+getlimits_
 
 mkdir -p b/a/p b/c b/d || framework_failure_
 chmod ug-w b/a || framework_failure_
@@ -26,14 +27,14 @@ chmod ug-w b/a || framework_failure_
 
 # This should fail.
 rm -rf b > out 2>&1 && fail=1
-cat <<\EOF > exp
-rm: cannot remove directory 'b/a/p': Permission denied
+cat <<EOF > exp
+rm: cannot remove directory 'b/a/p': $EACCES
 EOF
 
 # On some systems, rm doesn't have enough information to
 # say it's a directory.
-cat <<\EOF > exp2
-rm: cannot remove 'b/a/p': Permission denied
+cat <<EOF > exp2
+rm: cannot remove 'b/a/p': $EACCES
 EOF
 
 cmp out exp > /dev/null 2>&1 || {
index e14b77609a3bccf062f2b69e9dec8ce2d8428200..ee4df1852e94775a1860b0e9d0e77dc1dda19434 100755 (executable)
@@ -19,6 +19,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ rm
 skip_if_root_
+getlimits_
 
 mkdir -p a/0 || framework_failure_
 mkdir -p a/1/2 b/3 || framework_failure_
@@ -30,14 +31,14 @@ chmod u-x a/1 b || framework_failure_
 # in the same sort of diagnostic.
 # Both of these should fail.
 rm -rf a b > out 2>&1 && fail=1
-cat <<\EOF > exp
-rm: cannot remove 'a/1': Permission denied
-rm: cannot remove 'b': Permission denied
+cat <<EOF > exp
+rm: cannot remove 'a/1': $EACCES
+rm: cannot remove 'b': $EACCES
 EOF
 
-cat <<\EOF > exp-solaris
-rm: cannot remove 'a/1/2': Permission denied
-rm: cannot remove 'b/3': Permission denied
+cat <<EOF > exp-solaris
+rm: cannot remove 'a/1/2': $EACCES
+rm: cannot remove 'b/3': $EACCES
 EOF
 
 cmp out exp > /dev/null 2>&1 \
index 1e9e7f6582316dcfc0a2d8296b22eac6966fe72f..84b2fa9e332d27d1989c8e560bee827c5e6fe1ea 100755 (executable)
@@ -19,6 +19,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ rm
 skip_if_root_
+getlimits_
 
 mkdir -p a/b || framework_failure_
 chmod u-r a
@@ -26,8 +27,8 @@ chmod u-r a
 
 # This should fail.
 rm -rf a > out 2>&1 && fail=1
-cat <<\EOF > exp
-rm: cannot remove 'a': Permission denied
+cat <<EOF > exp
+rm: cannot remove 'a': $EACCES
 EOF
 
 compare exp out || fail=1
index 1cba4c2c0b09c0425f475b76805b517643c2f921..7c65d39e372428e4f7a862ea38ff90e94799b463 100755 (executable)
@@ -18,6 +18,8 @@
 
 use strict;
 
+my $limits = getlimits ();
+
 (my $program_name = $0) =~ s|.*/||;
 
 # Turn off localization of executable's output.
@@ -38,7 +40,7 @@ my @Tests =
      ['unreadable-2', '-rf', $d,
       {EXIT => $uid == 0 ? 0 : 1},
       {ERR => $uid == 0 ? ''
-                        : "$prog: cannot remove '$d': Permission denied\n"},
+                        : "$prog: cannot remove '$d': $limits->{EACCES}\n"},
       {PRE => sub { (mkdir $d,0700 and mkdir "$d/x",0700 and chmod 0100,$d)
                     or die "$d: $!\n"}} ],
     );