mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Daniel Palmer <daniel@thingy.jp>
Cc: w@1wt.eu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] selftests/nolibc: Add test for getcwd() and readlink()
Date: Tue, 30 Jun 2026 20:47:21 +0200	[thread overview]
Message-ID: <86ca5e60-02e5-4ac0-a105-e8f161007663@t-8ch.de> (raw)
In-Reply-To: <20260630132419.2523890-4-daniel@thingy.jp>

Hi Daniel,

thanks for the patches!

On 2026-06-30 22:24:19+0900, Daniel Palmer wrote:
> Add a test that uses both getcwd() and readlink() so that both
> are exercised.
> 
> First the happy path is tested by fetching what should be the
> same string via getcwd() and readlink() and checking they match.
> 
> Then a few different combinations of bad parameters are passed to
> getcwd() to make sure it returns NULL and sets errno in those
> cases.

Sashiko found a few things. I think all of them are valid.
https://sashiko.dev/#/patchset/20260630132419.2523890-1-daniel%40thingy.jp

> Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> ---
>  tools/testing/selftests/nolibc/nolibc-test.c | 48 ++++++++++++++++++++
>  1 file changed, 48 insertions(+)
> 
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index c1c1ce43a047..d54e7188e2ab 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -854,6 +854,53 @@ static int test_dirent(void)
>  	return 0;
>  }
>  
> +static int test_getcwd(void)
> +{
> +	char cwd_syscall[1024];
> +	char cwd_proc[1024];
> +	ssize_t len;
> +
> +	/* Read where the link /proc/self/cwd points */
> +	len = readlink("/proc/self/cwd", cwd_proc, sizeof(cwd_proc) - 1);
> +	if (len <= 0)
> +		return -1;

Please return different values here, so it is obvious which subtest
failed.


> +
> +	/* Terminate the string from readlink() */
> +	cwd_proc[len] = '\0';
> +
> +	/* Get the cwd via syscall */
> +	if (getcwd(cwd_syscall, sizeof(cwd_syscall)) == NULL)
> +		return -1;

(...)

      reply	other threads:[~2026-06-30 18:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 13:24 [PATCH v2 0/3] nolibc: Add " Daniel Palmer
2026-06-30 13:24 ` [PATCH v2 1/3] tools/nolibc: unistd: Add getcwd() Daniel Palmer
2026-06-30 13:24 ` [PATCH v2 2/3] tools/nolibc: unistd: Add readlink() Daniel Palmer
2026-06-30 13:24 ` [PATCH v2 3/3] selftests/nolibc: Add test for getcwd() and readlink() Daniel Palmer
2026-06-30 18:47   ` Thomas Weißschuh [this message]

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=86ca5e60-02e5-4ac0-a105-e8f161007663@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=daniel@thingy.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=w@1wt.eu \
    /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

Powered by JetHome