From: Pádraig Brady Date: Mon, 16 Feb 2026 12:09:34 +0000 (+0000) Subject: tests: use system EACCES message X-Git-Tag: v9.11~266 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c073ec7c50705e1f8b9c3b38fbccf4131079505;p=thirdparty%2Fcoreutils.git tests: use system EACCES message * 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. --- diff --git a/tests/chgrp/no-x.sh b/tests/chgrp/no-x.sh index b20b925627..8d160957f4 100755 --- a/tests/chgrp/no-x.sh +++ b/tests/chgrp/no-x.sh @@ -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 < exp -$prog: 'd/no-x': Permission denied +$prog: 'd/no-x': $EACCES EOF compare exp out || fail=1 diff --git a/tests/chmod/no-x.sh b/tests/chmod/no-x.sh index 8a44836bf7..bbf00375df 100755 --- a/tests/chmod/no-x.sh +++ b/tests/chmod/no-x.sh @@ -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 < exp -$prog: 'd/no-x': Permission denied +$prog: 'd/no-x': $EACCES EOF compare exp out || fail=1 diff --git a/tests/du/inacc-dest.sh b/tests/du/inacc-dest.sh index fc8e868177..b578d76f1f 100755 --- a/tests/du/inacc-dest.sh +++ b/tests/du/inacc-dest.sh @@ -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 < 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 diff --git a/tests/du/no-x.sh b/tests/du/no-x.sh index f47e4ca5c7..238b5d0223 100755 --- a/tests/du/no-x.sh +++ b/tests/du/no-x.sh @@ -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 < exp -$prog: 'd/no-x': Permission denied +$prog: 'd/no-x': $EACCES EOF compare exp out || fail=1 diff --git a/tests/misc/nohup.sh b/tests/misc/nohup.sh index 08a486e017..5c9c966066 100755 --- a/tests/misc/nohup.sh +++ b/tests/misc/nohup.sh @@ -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 < 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 diff --git a/tests/mv/part-fail.sh b/tests/mv/part-fail.sh index 024eb90099..d3145bcb6d 100755 --- a/tests/mv/part-fail.sh +++ b/tests/mv/part-fail.sh @@ -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 < 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 diff --git a/tests/mv/perm-1.sh b/tests/mv/perm-1.sh index d06677f94e..6d99f85578 100755 --- a/tests/mv/perm-1.sh +++ b/tests/mv/perm-1.sh @@ -20,14 +20,15 @@ . "${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 < exp +mv: cannot move 'no-write/dir' to './dir': $EACCES EOF compare exp out || fail=1 diff --git a/tests/rm/fail-eacces.sh b/tests/rm/fail-eacces.sh index 69238e9e4b..e2d47e31fa 100755 --- a/tests/rm/fail-eacces.sh +++ b/tests/rm/fail-eacces.sh @@ -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 < 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 < exp +rm: cannot remove 'e/slink': $EACCES EOF compare exp out || fail=1 diff --git a/tests/rm/rm1.sh b/tests/rm/rm1.sh index 025c5341a0..5a9b6c4369 100755 --- a/tests/rm/rm1.sh +++ b/tests/rm/rm1.sh @@ -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 < 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 < exp2 +rm: cannot remove 'b/a/p': $EACCES EOF cmp out exp > /dev/null 2>&1 || { diff --git a/tests/rm/rm2.sh b/tests/rm/rm2.sh index e14b77609a..ee4df1852e 100755 --- a/tests/rm/rm2.sh +++ b/tests/rm/rm2.sh @@ -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 < 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 < exp-solaris +rm: cannot remove 'a/1/2': $EACCES +rm: cannot remove 'b/3': $EACCES EOF cmp out exp > /dev/null 2>&1 \ diff --git a/tests/rm/unread2.sh b/tests/rm/unread2.sh index 1e9e7f6582..84b2fa9e33 100755 --- a/tests/rm/unread2.sh +++ b/tests/rm/unread2.sh @@ -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 < exp +rm: cannot remove 'a': $EACCES EOF compare exp out || fail=1 diff --git a/tests/rm/unreadable.pl b/tests/rm/unreadable.pl index 1cba4c2c0b..7c65d39e37 100755 --- a/tests/rm/unreadable.pl +++ b/tests/rm/unreadable.pl @@ -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"}} ], );