From: Pádraig Brady
Date: Thu, 16 Jul 2026 11:14:59 +0000 (+0100) Subject: tests: use more robust cleanup of immutable files X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dbed1698350ba1ec06505e35f37265f9f0c69dc0;p=thirdparty%2Fcoreutils.git tests: use more robust cleanup of immutable files * 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. --- diff --git a/tests/install/install-C-immutable.sh b/tests/install/install-C-immutable.sh index 3b0cbf4d28..0bdb979970 100755 --- a/tests/install/install-C-immutable.sh +++ b/tests/install/install-C-immutable.sh @@ -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 diff --git a/tests/rm/empty-immutable-skip.sh b/tests/rm/empty-immutable-skip.sh index 5b8ea66060..a70d619672 100755 --- a/tests/rm/empty-immutable-skip.sh +++ b/tests/rm/empty-immutable-skip.sh @@ -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