Fix test failure where rm would appear to succeed incorrectly.
authorBob Proulx <bob@proulx.com>
Mon, 25 Feb 2008 19:38:23 +0000 (20:38 +0100)
committerJim Meyering <meyering@redhat.com>
Mon, 25 Feb 2008 20:03:53 +0000 (21:03 +0100)
* tests/rm/fail-eperm: Ignore files that were opportunistically chosen
to test permission failures but disappear before we can finish the test.

tests/rm/fail-eperm

index 5fa54b097b403946ba8f0d88032c4b0980461aa1..e9e2108ec8f71d412e3bce167cad88af93547e93 100755 (executable)
@@ -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;