]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: use more robust cleanup of immutable files
authorPádraig Brady <P@draigBrady.com>
Thu, 16 Jul 2026 11:14:59 +0000 (12:14 +0100)
committerPádraig Brady <P@draigBrady.com>
Thu, 16 Jul 2026 11:28:07 +0000 (12:28 +0100)
* tests/rm/empty-immutable-skip.sh: Use cleanup_() to
remove the immutable attribute, so that false failures
or stale files do not result from e.g. a killed test run.

tests/install/install-C-immutable.sh
tests/rm/empty-immutable-skip.sh

index 3b0cbf4d28ce6474bb81374107703d69d334a07f..0bdb979970d55a1945da98ae344aa57a4b601409 100755 (executable)
@@ -43,6 +43,8 @@ g1=1
 
 echo test > a || framework_failure_
 
+cleanup_() { chattr -i b; }
+
 # Install once to create the destination, then make it immutable.
 ginstall -Cv -m0644 -o$u1 -g$g1 a b || framework_failure_
 chattr +i b || framework_failure_
@@ -53,6 +55,4 @@ chattr +i b || framework_failure_
 # it would actually change.
 ginstall -Cv -m0644 -o$u1 -g$g1 a b || fail=1
 
-chattr -i b
-
 Exit $fail
index 5b8ea66060cd1730349f310b52483980c972faf5..a70d61967238ea69ca3832fa5f8a4e3800794982 100755 (executable)
@@ -36,11 +36,12 @@ if test $chattr_i_works = 0; then
   skip_ "chattr +i doesn't work on this file system"
 fi
 
+cleanup_() { chattr -i empty; }
+
 mkdir empty || framework_failure_
 touch x y || framework_failure_
 chattr +i empty || framework_failure_
 rm -rf empty x y
 { test -f x || test -f y; } && fail=1
-chattr -i empty
 
 Exit $fail