git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, "René Scharfe" <l.s.r@web.de>,
	"David Coppa" <dcoppa@openbsd.org>,
	"brian m . carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH v2] t0001: fix broken not-quite getcwd(3) test in bed67874e2
Date: Fri, 30 Jul 2021 10:16:51 -0700	[thread overview]
Message-ID: <xmqqmtq3203g.fsf@gitster.g> (raw)
In-Reply-To: <patch-v2-1.1-d7d071441b0-20210730T161540Z-avarab@gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Fri, 30 Jul 2021 18:18:14 +0200")

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> The problem with that fix is that while its analysis of the problem is
> correct, it doesn't actually call getcwd(3), instead it invokes "pwd
> -P". There is no guarantee that "pwd -P" is going to call getcwd(3),
> as opposed to e.g. being a shell built-in.
>
> On AIX under both bash and ksh this test breaks because "pwd -P" will
> happily display the current working directory, but getcwd(3) called by
> the "git init" we're testing here will fail to get it.

Well described.  And logically it leads to "when we want to know
getcwd() is OK to use, trying to run getcwd() to see it works is the
right way to do so", which is your test-getcwd.c?  Nice.

Will queue.

> diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
> index 490ac026c51..3ce5585e53a 100644
> --- a/t/helper/test-tool.c
> +++ b/t/helper/test-tool.c
> @@ -33,6 +33,7 @@ static struct test_cmd cmds[] = {
>  	{ "fast-rebase", cmd__fast_rebase },
>  	{ "genrandom", cmd__genrandom },
>  	{ "genzeros", cmd__genzeros },
> +	{ "getcwd", cmd__getcwd },
>  	{ "hashmap", cmd__hashmap },
>  	{ "hash-speed", cmd__hash_speed },
>  	{ "index-version", cmd__index_version },
> diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
> index f8dc266721f..9f0f5228508 100644
> --- a/t/helper/test-tool.h
> +++ b/t/helper/test-tool.h
> @@ -23,6 +23,7 @@ int cmd__example_decorate(int argc, const char **argv);
>  int cmd__fast_rebase(int argc, const char **argv);
>  int cmd__genrandom(int argc, const char **argv);
>  int cmd__genzeros(int argc, const char **argv);
> +int cmd__getcwd(int argc, const char **argv);
>  int cmd__hashmap(int argc, const char **argv);
>  int cmd__hash_speed(int argc, const char **argv);
>  int cmd__index_version(int argc, const char **argv);
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index acd662e403b..df544bb321f 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -356,7 +356,10 @@ test_lazy_prereq GETCWD_IGNORES_PERMS '
>  	chmod 100 $base ||
>  	BUG "cannot prepare $base"
>  
> -	(cd $base/dir && /bin/pwd -P)
> +	(
> +		cd $base/dir &&
> +		test-tool getcwd
> +	)
>  	status=$?
>  
>  	chmod 700 $base &&

  reply	other threads:[~2021-07-30 17:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-06 23:38 [PATCH] tests: don't give unportable ">" to "test" built-in, use -gt Ævar Arnfjörð Bjarmason
2017-08-07  1:18 ` brian m. carlson
2017-08-07 10:17   ` René Scharfe
2017-08-07 10:59     ` Ævar Arnfjörð Bjarmason
2017-08-07 11:04     ` [PATCH] t0001: skip test with restrictive permissions if getpwd(3) respects them René Scharfe
2021-06-01  0:38       ` [PATCH] t0001: fix broken not-quite getcwd(3) test in bed67874e2 Ævar Arnfjörð Bjarmason
2021-06-01 16:15         ` René Scharfe
2021-06-01 21:20           ` Junio C Hamano
2021-06-07 11:29             ` Ævar Arnfjörð Bjarmason
2021-06-07 11:24           ` Ævar Arnfjörð Bjarmason
2021-06-07 15:26             ` René Scharfe
2021-06-07 15:38               ` Ævar Arnfjörð Bjarmason
2021-07-30 16:18         ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2021-07-30 17:16           ` Junio C Hamano [this message]
2017-08-07  1:33 ` [PATCH] tests: don't give unportable ">" to "test" built-in, use -gt Junio C Hamano
2017-08-07 17:32 ` Junio C Hamano
2017-08-07 18:06 ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqmtq3203g.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=dcoppa@openbsd.org \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).