From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FC0F272816 for ; Tue, 30 Jun 2026 18:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782845252; cv=none; b=MBkngNrlRafq6poZEX/quy7w0fOnBhI30JnR0whCtcf5rVi6nD6S/eTefOFyLrN/yf+8m83Ev9fdK5x4+Q8bSyMMSCkVfiZG129i5JgQr9hSs+P5M7fNZNR+gF7K9JM+Bt1d7C7yhO6+3I4Su798feVGSJCFXfS+v/DxqN7SqK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782845252; c=relaxed/simple; bh=B/YrRkNptnTrxdARLE4NiWiQZMgLjc8U+E1AtFCRMw8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ruoOnLsDR/19J+CUyEd9oFrpMq3oK26fmcDfLjOXvtV0npP7sWB/XMINbkhrCt5QInwUHseFBRBcp6QHBtx8ew8vifdL9a8UHvp6i1dCgF0bKNgUsW0Io5Y82Y9NnuqFQLmj6nnF+Qcl+dufP73RL4bqVWRxLVToT+J21GhX24E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=GFsh+O7C; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="GFsh+O7C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1782845242; bh=B/YrRkNptnTrxdARLE4NiWiQZMgLjc8U+E1AtFCRMw8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GFsh+O7CnfwR/chvVxj9JlmSp3X5Inot8m6lWRnXo2rPQQZl+O5eXifzopf0Idk5O uV2J6O3OMSk+bg7z8vawNuBywuUjIxcYW5J2w2k1RTqCcr75WzsEeJeCGopcS2V5nh rYJLyLe9gjIoLVTZNysGl4x8SfsaAL9Af38jPhGc= Date: Tue, 30 Jun 2026 20:47:21 +0200 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Daniel Palmer Cc: w@1wt.eu, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/3] selftests/nolibc: Add test for getcwd() and readlink() Message-ID: <86ca5e60-02e5-4ac0-a105-e8f161007663@t-8ch.de> References: <20260630132419.2523890-1-daniel@thingy.jp> <20260630132419.2523890-4-daniel@thingy.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > --- > 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; (...)