From: Pádraig Brady Date: Sat, 14 Feb 2026 12:23:00 +0000 (+0000) Subject: maint: tests: avoid EPERM/EACCES specific handling X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c03cc2dca6fb66a0c2055fe0d6c2039bc2a9f042;p=thirdparty%2Fcoreutils.git maint: tests: avoid EPERM/EACCES specific handling * tests/Coreutils.pm: Remove associated comment. * tests/mv/sticky-to-xpart.sh: Use $EACCES and $EPERM. * tests/rm/fail-2eperm.sh: Likewise. * tests/touch/not-owner.sh: Likewise. --- diff --git a/tests/Coreutils.pm b/tests/Coreutils.pm index 376609d731..e396d93a4b 100644 --- a/tests/Coreutils.pm +++ b/tests/Coreutils.pm @@ -80,8 +80,6 @@ defined $ENV{TERM} # {ERR_SUBST => 's/variable_output/expected_output/'} # Transform actual stderr output before comparing it against expected. # This is useful when verifying that we get a meaningful diagnostic. -# For example, in rm/fail-2eperm, we have to account for three different -# diagnostics: Operation not permitted, Not owner, and Permission denied. # {EXIT => N} expect exit status of cmd to be N # {ENV => 'VAR=val ...'} # Prepend 'VAR=val ...' to the command that we execute via 'system'. diff --git a/tests/mv/sticky-to-xpart.sh b/tests/mv/sticky-to-xpart.sh index d7a5db4558..8b3f7029d9 100755 --- a/tests/mv/sticky-to-xpart.sh +++ b/tests/mv/sticky-to-xpart.sh @@ -22,6 +22,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ mv require_root_ +getlimits_ cleanup_() { rm -rf "$other_partition_tmpdir"; } . "$abs_srcdir/tests/other-fs-tmpdir" @@ -54,21 +55,19 @@ esac chroot --skip-chdir --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ mv t/root-owned "$other_partition_tmpdir" 2> out-t && fail=1 -# On some systems, we get 'Not owner'. Convert it. -# On other systems (HPUX), we get 'Permission denied'. Convert it, too. -onp='Operation not permitted' -sed "s/Not owner/$onp/;s/Permission denied/$onp/" out-t > out +# On some systems (HPUX), we get 'Permission denied'. Convert it. +sed "s/$EACCES/$EPERM/;" out-t > out # On some systems (OpenBSD 7.5), the initial rename fails with EPERM, # which is arguably better than the Linux kernel's EXDEV. cat <exp1 || framework_failure_ -mv: cannot move 't/root-owned' to '$other_partition_tmpdir/root-owned': $onp +mv: cannot move 't/root-owned' to '$other_partition_tmpdir/root-owned': $EPERM EOF compare exp1 out >/dev/null || { cat <exp || framework_failure_ -mv: cannot remove 't/root-owned': $onp +mv: cannot remove 't/root-owned': $EPERM EOF compare exp out || fail=1 diff --git a/tests/rm/fail-2eperm.sh b/tests/rm/fail-2eperm.sh index 2040128b53..49dbbb48ed 100755 --- a/tests/rm/fail-2eperm.sh +++ b/tests/rm/fail-2eperm.sh @@ -20,6 +20,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ rm require_root_ +getlimits_ # The containing directory must be owned by the user who eventually runs rm. chown $NON_ROOT_USERNAME . @@ -49,12 +50,10 @@ for file in 'a/b' 'a'; do returns_ 1 chroot --skip-chdir --user=$NON_ROOT_USERNAME / \ env PATH="$PATH" rm $recurse -f "$file" 2> out-t || fail=1 - # On some systems, we get 'Not owner'. Convert it. - # On other systems (HPUX), we get 'Permission denied'. Convert it, too. - onp='Operation not permitted' - sed "s/Not owner/$onp/;s/Permission denied/$onp/" out-t > out + # On some systems (HPUX), we get 'Permission denied'. Convert it. + sed "s/$EACCES/$EPERM/" out-t > out - echo "rm: cannot remove 'a/b': Operation not permitted" > exp + echo "rm: cannot remove 'a/b': $EPERM" > exp compare exp out || fail=1 done diff --git a/tests/touch/not-owner.sh b/tests/touch/not-owner.sh index 948e16fe9c..9e3a23d093 100755 --- a/tests/touch/not-owner.sh +++ b/tests/touch/not-owner.sh @@ -19,6 +19,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ touch +getlimits_ if env -- test -w /; then skip_ you have write access to /. @@ -36,12 +37,9 @@ skip_if_root_ # touch: creating '/': Is a directory touch / > out 2>&1 && fail=1 -# On SunOS4, EPERM is 'Not owner'. -# On some *BSD systems it's 'Operation not permitted'. # On a system where root file system is mounted read-only # it's 'Read-only file system'. -for msg in 'Not owner' 'Operation not permitted' 'Permission denied' \ - 'Read-only file system'; do +for msg in "$EACCES" "$EPERM" "$EROFS"; do cat > exp <