]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: tests: avoid EPERM/EACCES specific handling
authorPádraig Brady <P@draigBrady.com>
Sat, 14 Feb 2026 12:23:00 +0000 (12:23 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 18 Feb 2026 18:31:49 +0000 (18:31 +0000)
* 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.

tests/Coreutils.pm
tests/mv/sticky-to-xpart.sh
tests/rm/fail-2eperm.sh
tests/touch/not-owner.sh

index 376609d73191435f41725cb1fdc59b39c93d65ae..e396d93a4b361775c91dafd605309bfa7a8d4f2f 100644 (file)
@@ -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'.
index d7a5db45585af04003ddf0d30806e820d4eed580..8b3f7029d99aef12a3d5e1cdeec2bd4c17222dc8 100755 (executable)
@@ -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 <<EOF >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 <<EOF >exp || framework_failure_
-mv: cannot remove 't/root-owned': $onp
+mv: cannot remove 't/root-owned': $EPERM
 EOF
 
   compare exp out || fail=1
index 2040128b538559b82cd0bff6db7144b4082ca865..49dbbb48edf0e07087580b149df75242d5fcc2a3 100755 (executable)
@@ -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
 
index 948e16fe9c530e2fe69779980461e1dbfccab909..9e3a23d093c5b9b0922c3dbe9f7a351c89e78d30 100755 (executable)
@@ -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 <<EOF
 touch: setting times of '/': $msg
 EOF