bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix test failure where rm would appear to succeed incorrectly.


From: Bob Proulx
Subject: Fix test failure where rm would appear to succeed incorrectly.
Date: Mon, 25 Feb 2008 02:33:21 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

I have been seeing the rm fail-eperm test sporadically fail.  It turns
out that there is a race.  The test is opportunistically looking for
files that it can't remove so as to provide a test for that part of
rm's functionality.  But between the time it finds a candidate file
and the time it tries to test rm on the file that file may have
already been removed external to the test script.  The code didn't
expect that and therefore threw an error message.  This suggested
patch fixes the problem by detecting that case and ignoring it.

Please fetch this patch.

  git fetch --no-tags git://git.proulx.com/idutils 
rm-fail-eperm-fix:rm-fail-eperm-fix

Bob


2008-02-25  Bob Proulx  <address@hidden>

        Fix test failure where rm would appear to succeed incorrectly.
        * tests/rm/fail-eperm: Ignore files that were opportunistically chosen
        to test permission failures but disappear before we can finish the test.

diff --git a/tests/rm/fail-eperm b/tests/rm/fail-eperm
index 5fa54b0..e9e2108 100755
--- a/tests/rm/fail-eperm
+++ b/tests/rm/fail-eperm
@@ -96,6 +96,17 @@ foreach my $dir (@dir_list)
 
            close RM;
            my $rc = $?;
+           # This test opportunistically looks for files that can't
+           # be removed but those files may already have been removed
+           # by their owners by the time we get to them.  It is a
+           # race condition.  If so then the rm is successful and our
+           # test is thwarted.  Detect this case and ignore.
+           if ($rc == 0)
+             {
+               next if ! -e $target_file;
+               die "$ME: unexpected exit status from `$cmd';\n"
+                 . "  got 0, expected 1\n";
+             }
            if (0x80 < $rc)
              {
                my $status = $rc >> 8;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]