threads / bug / 3708

[BUG] make test (t3600-rm.sh) fails

Subject: [BUG] make test (t3600-rm.sh) fails

## tl;dr

6 messages between Mar 24, 2006 and Mar 24, 2006.

replies: 5people: 4as markdown or json

Panagiotis Issaris· Mar 24, 2006, 10:14 UTC · lore
Hi,

Just a small report that "make test" fails on my system on the current git git tree:

...
* passed all 3 test(s)
*** t3600-rm.sh ***
Committing initial tree e5c556e46aae6124ff4a2a466c95004e92d9a2e4
*   ok 1: Pre-check that foo exists and is in index before git-rm foo
*   ok 2: Test that git-rm foo succeeds
*   ok 3: Post-check that foo exists but is not in index after git-rm foo
*   ok 4: Pre-check that bar exists and is in index before "git-rm -f bar"
*   ok 5: Test that "git-rm -f bar" succeeds
*   ok 6: Post-check that bar does not exist and is not in index after 
"git-rm -f bar"
*   ok 7: Test that "git-rm -- -q" succeeds (remove a file that looks 
like an option)
*   ok 8: Test that "git-rm -f" succeeds with embedded space, tab, or 
newline characters.
* FAIL 9: Test that "git-rm -f" fails if its rm fails
        git-rm -f baz
*   ok 10: When the rm in "git-rm -f" fails, it should not remove the 
file from the index
* failed 1 among 10 test(s)
make[2]: *** [t3600-rm.sh] Error 1
make[2]: Leaving directory `/usr/local/src/git/t'
make[1]: *** [test] Error 2
make[1]: Leaving directory `/usr/local/src/git'
make: *** [build-arch-stamp] Error 2

My system: Ubuntu 5.10 aka Breezy Linux issaris 2.6.15.060103 #1 Tue Jan 3 14:27:55 CET 2006 i686 GNU/Linux model name : Intel(R) Pentium(R) 4 CPU 3.20GHz

With friendly regards, Takis

Junio C Hamano· Mar 24, 2006, 10:29 UTC · re: Panagiotis Issaris · lore

Re: [BUG] make test (t3600-rm.sh) fails

Panagiotis Issaris <takis@issaris.org> writes:
Show 6 quoted lines
> * FAIL 9: Test that "git-rm -f" fails if its rm fails
>        git-rm -f baz
>...
> My system:
> Ubuntu 5.10 aka Breezy
> Linux issaris 2.6.15.060103 #1 Tue Jan 3 14:27:55 CET 2006 i686 GNU/Linux
I wonder what your system shows if you run:
	$ cd t && sh -x t3600-rm.sh -i -v

The test #9 makes the test directory unwritable before trying to unlink a file there, and git-rm runs rm without -f which should make it fail. So either your "chmod u-w ." is broken, you are running it as root and defeating "chmod u-w .", or you have a broken rm that does not report failure with its exit status.

The relevant part on my machine looks like this:
$ cd t
$ sh -x t3600-rm.sh -i -v
...
*   ok 8: Test that "git-rm -f" succeeds with embedded space, tab, or newline characters.
+ test y = y
+ chmod u-w .
+ test_expect_failure 'Test that "git-rm -f" fails if its rm fails' 'git-rm -f baz'
+ test 2 = 2
+ say 'expecting failure: git-rm -f baz'
+ echo '* expecting failure: git-rm -f baz'
* expecting failure: git-rm -f baz
+ test_run_ 'git-rm -f baz'
+ eval 'git-rm -f baz'
++ git-rm -f baz
rm: cannot remove `baz': Permission denied
+ eval_ret=123
+ return 0
+ '[' 0 = 0 -a 123 '!=' 0 ']'
+ test_ok_ 'Test that "git-rm -f" fails if its rm fails'
++ expr 8 + 1
+ test_count=9
+ say '  ok 9: Test that "git-rm -f" fails if its rm fails'
+ echo '*   ok 9: Test that "git-rm -f" fails if its rm fails'
*   ok 9: Test that "git-rm -f" fails if its rm fails
...
Takis· Mar 24, 2006, 10:45 UTC · re: Junio C Hamano · lore

Re: [BUG] make test (t3600-rm.sh) fails

Hi,
2006/3/24, Junio C Hamano <junkio@cox.net>:
Show 12 quoted lines
> Panagiotis Issaris <takis@issaris.org> writes:
>
> > * FAIL 9: Test that "git-rm -f" fails if its rm fails
> >        git-rm -f baz
> >...
> > My system:
> > Ubuntu 5.10 aka Breezy
> > Linux issaris 2.6.15.060103 #1 Tue Jan 3 14:27:55 CET 2006 i686 GNU/Linux
>
> I wonder what your system shows if you run:
>
>         $ cd t && sh -x t3600-rm.sh -i -v
Here's the output:
takis@issaris:/usr/local/src/git$ cd t && sh -x t3600-rm.sh -i -v
...
*   ok 8: Test that "git-rm -f" succeeds with embedded space, tab, or
newline characters.
+ test y = y
+ chmod u-w .
+ test_expect_failure 'Test that "git-rm -f" fails if its rm fails'
'git-rm -f baz'
+ test 2 = 2
+ say 'expecting failure: git-rm -f baz'
+ echo '* expecting failure: git-rm -f baz'
* expecting failure: git-rm -f baz
+ test_run_ 'git-rm -f baz'
+ eval 'git-rm -f baz'
++ git-rm -f baz
rm: cannot remove `baz': Permission denied
+ eval_ret=0
+ return 0
+ '[' 0 = 0 -a 0 '!=' 0 ']'
+ test_failure_ 'Test that "git-rm -f" fails if its rm fails' 'git-rm -f baz'
++ expr 8 + 1
+ test_count=9
++ expr 0 + 1
+ test_failure=1
+ say 'FAIL 9: Test that "git-rm -f" fails if its rm fails'
+ echo '* FAIL 9: Test that "git-rm -f" fails if its rm fails'
* FAIL 9: Test that "git-rm -f" fails if its rm fails
+ shift
+ echo 'git-rm -f baz'
+ sed -e 's/^/  /'
        git-rm -f baz
+ test t = ''
+ trap - exit
+ exit 1
Show 5 quoted lines
> The test #9 makes the test directory unwritable before trying to
> unlink a file there, and git-rm runs rm without -f which should
> make it fail.  So either your "chmod u-w ." is broken, you are
> running it as root and defeating "chmod u-w .", or you have a
> broken rm that does not report failure with its exit status.

I am running it as fakeroot, as part of the "dpkg-buildpackage -rfakeroot -uc -us -b" command for building Debian packages. Would this be the problem (the fakeroot)?

With friendly regards, Takis

Junio C Hamano· Mar 24, 2006, 11:08 UTC · re: Takis · lore

Re: [BUG] make test (t3600-rm.sh) fails

Takis <panagiotis.issaris@gmail.com> writes:
> I am running it as fakeroot, as part of the "dpkg-buildpackage
> -rfakeroot -uc -us -b"
> command for building Debian packages. Would this be the problem (the fakeroot)?
That is what is causing this, yes.
	$ mkdir /var/tmp/junk && cd /var/tmp/junk
        $ chmod u+w .
	$ fakeroot sh -c 'date >foo; chmod u-w .; rm foo; ls -l foo'
        $ chmod u+w .
	$ sh -c 'date >foo; chmod u-w .; rm foo; ls -l foo'

The one under fakeroot happily ignores the directory being unwritable because it mimics to be root.

But that does not mean fakeroot is buggy. Fakeroot is doing what it is designed to do.

That does not mean running our tests under fakeroot is stupidity on your part. We do not advertise that the tests should not be run as root.

The test is buggy -- it tries to make sure the command fails when underlying rm fails, but is not aware that "chmod u-w ." is not a good way to make ./foo undeletable if you run it as root. At least it should skip those two tests if it is run by root.

Panagiotis Issaris· Mar 24, 2006, 12:05 UTC · re: Junio C Hamano · lore

Re: [BUG] make test (t3600-rm.sh) fails

Hi,
Junio C Hamano wrote:
Show 15 quoted lines
>...
>But that does not mean fakeroot is buggy.  Fakeroot is doing
>what it is designed to do.
>
>That does not mean running our tests under fakeroot is stupidity
>on your part.  We do not advertise that the tests should not be
>run as root.
>
>The test is buggy -- it tries to make sure the command fails
>when underlying rm fails, but is not aware that "chmod u-w ."
>is not a good way to make ./foo undeletable if you run it as
>root.  At least it should skip those two tests if it is run by
>root.
>  
>
Something like this?
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index d1947e1..52a1e99 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -56,6 +56,7 @@ test "$test_tabs" = y && test_expect_suc
     "git-rm -f 'space embedded' 'tab   embedded' 'newline
 embedded'"

+if test `whoami` != "root"; then
 if test "$test_tabs" = y; then
 chmod u-w .
 test_expect_failure \
@@ -63,6 +64,7 @@ test_expect_failure \
     'git-rm -f baz'
 chmod u+w .
 fi
+fi

 test_expect_success \
     'When the rm in "git-rm -f" fails, it should not remove the file from the index' \
Petr Baudis· Mar 24, 2006, 13:51 UTC · re: Panagiotis Issaris · lore

Re: [BUG] make test (t3600-rm.sh) fails

Dear diary, on Fri, Mar 24, 2006 at 01:05:02PM CET, I got a letter where Panagiotis Issaris <takis@issaris.org> said that...

Show 9 quoted lines
> diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
> index d1947e1..52a1e99 100755
> --- a/t/t3600-rm.sh
> +++ b/t/t3600-rm.sh
> @@ -56,6 +56,7 @@ test "$test_tabs" = y && test_expect_suc
>     "git-rm -f 'space embedded' 'tab   embedded' 'newline
> embedded'"
> 
> +if test `whoami` != "root"; then

Root is not the only condition when this will not fail, it can happen on broken filesystems as well, specifically AFS. (Avoid avoid avoid that horrid thing!)

So, perhaps rather
> if test "$test_tabs" = y; then
> chmod u-w .
+ touch xyzzy || \
> test_expect_failure \
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time.  I think
I have forgotten this before.

← back to recent threads