Subject: Re: Re: [PATCH] t/lib-httpd: switch SANITY check for NOT_ROOT

From: Junio C Hamano <[email-masked]>
Date: Fri, 23 Jan 2015 15:02:13 -0800

Torsten Bögershausen <[email-masked]> writes:

> It has been tested under Mac OS, root@Mac OS, Cygwin / Msysgit
> What do you think ?

Except that we may want to be more careful to detect errors from the
initial mkdir and clean-up part (which should abort the test, not
just declare !SANITY), I think the basic idea is sound.

	test_dir=$TRASH_DIRECTORY/.sanity-test-dir
        ! mkdir "$test_dir" &&
        >"$test_dir/x" &&
        chmod -w "$test_dir" ||
	error "bug in test sript: cannot prepare .sanity-test-dir"

        rm "$test_dir/x"
        status=$?

        chmod +w "$test_dir" &&
        rm -r "$test_dir" ||
	error "bug in test sript: cannot clean .sanity-test-dir"

	return $status

or something along that line?

>
> -- >8 --
> Subject: [PATCH 1/2] test-lib.sh: Improve SANITY
>
> SANITY was not set when running as root,
> but this is not 100% reliable for CYGWIN:
>
> A file is allowed to be deleted when the containing
> directory does not have write permissions.
>
> Signed-off-by: Torsten Bögershausen <[email-masked]>
> ---
>  t/test-lib.sh | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 93f7cad..b8f736f 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -1038,8 +1038,26 @@ test_lazy_prereq NOT_ROOT '
>  
>  # When the tests are run as root, permission tests will report that
>  # things are writable when they shouldn't be.
> +# Special check for CYGWIN (or Windows in general):
> +# A file can be deleted, even if the containing directory does'nt
> +# have write permissions
>  test_lazy_prereq SANITY '
> -	test_have_prereq POSIXPERM,NOT_ROOT
> +	dsdir=$$ds
> +	mkdir $dsdir &&
> +	touch $dsdir/x &&
> +	chmod -w $dsdir &&
> +	if rm $dsdir/x
> +	then
> +		chmod +w $dsdir
> +		rm -rf $dsdir
> +		echo >&2 SANITY=false
> +		false
> +	else
> +		chmod +w $dsdir
> +		rm -rf $dsdir
> +		echo >&2 SANITY=true
> +		true
> +	fi
>  '
>  
>  GIT_UNZIP=${GIT_UNZIP:-unzip}

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to [email-masked]
To unsubscribe from this group, send email to
[email-masked]
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email-masked].
For more options, visit https://groups.google.com/d/optout.