From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 14F831A9F94 for ; Mon, 23 Feb 2026 10:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771843095; cv=none; b=UI4kq5KEmcRrw3AxZQLsLLaJJd+wOqzVmzsq/c5rGXx3BLpG7V04gbLN2SDPR02DI5FlH/7xMnA+DPsUsm1CvGRApnbBYgnEJNirBxSnIqvYdCbkuzJ8VgLTiJqG2P//tmPzA7x4JfWJaCkJwa+Xe3Q+pAvLl4zy8SHwbU5hcy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771843095; c=relaxed/simple; bh=/RLgX+p4F+wV7OtpiM7GLS3gMHCyw0csh3Xj+1QbdLc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kU6KO1f6hMDSbaVQgysjfdlgzfoRWPzNERz6w4K+vXIY0l/h64bjDcxZL4QzfBQWk4vj6kk3D6sKCbeZOIWIbvESTdYCT4KXhnAGFHPPMmPRuF+DjsGieh+yXoQUw0GARU8bGocjmi/BKyYYxgRq8rEz7VZiwgdViRt8nlbi1bo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=EE7uN/fS; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="EE7uN/fS" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vuT1D-00GgpI-BH; Mon, 23 Feb 2026 11:18:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=xR8vwnb7Qy5aGBmBq6caH16VdDDYRePCCUdIloUYHho=; b=EE7uN/fSj/P/yXvgIP2EjWNZ2L bDiwIkhhoM0zEiSlzKZQnKg7xt7K2ofL98PnkEQ+NCs44b/mYa4MQK3pWBhBU+ozrOHnu2zKsyb1V v/qLDK3l9VyGV2nmmi67C5yW8yAfPfm5u5UyuGjRznNGgZtvEZ2vzPNEtNTLCh0T2pkAW8x9VIvhB +XnbkO2UqxAb/bQL7Fam7XOor91MH0OCkMdON/upmYoiHOyPzgHlB7QSIq8CcJlHe0HA0VdMaTuQ9 0Akg1xOq3elPB+z5ttdxx3U3itKET12EBzifUyl/iJ6QIgYWoiW6zGDWhxYBS0+S9OXHfdXEYL/ym ZPDwdlWA==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vuT1D-0005Pu-1H; Mon, 23 Feb 2026 11:18:23 +0100 Received: by submission02.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vuT11-006AjD-DX; Mon, 23 Feb 2026 11:18:11 +0100 From: david.laight.linux@gmail.com To: Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kernel@vger.kernel.org, Cheng Li Cc: David Laight Subject: [PATCH v3 next 03/17] selftests/nolibc: Fix build with host headers and libc Date: Mon, 23 Feb 2026 10:17:21 +0000 Message-Id: <20260223101735.2922-4-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260223101735.2922-1-david.laight.linux@gmail.com> References: <20260223101735.2922-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: David Laight Many systems don't have strlcpy() or strlcat() and readdir_r() is deprecated. This makes the tests fail to build with the host headers. Disable the 'directories' test and define strlcpy(), strlcat() and readdir_r() using #defines so that the code compiles. Fixes: 6fe8360b16acb ("selftests/nolibc: also test libc-test through regular selftest framework") Signed-off-by: David Laight --- For v3 (no v2): - Now part of the patch series that enhances _nolibc_printf(). - Disable the test that uses readdir_r() and #defines readdir_r() instead of disabling compiler warnings. - No need to change is_nolibc, doesn't help. Basically the nolibc-test program makefiles don't work without this change. tools/testing/selftests/nolibc/nolibc-test.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 1b9d3b2e2491..0e8b3b9a86ef 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -74,6 +74,20 @@ static const int is_nolibc = #endif ; +#if !defined(NOLIBC) +/* Some disabled tests may not compile. */ + +/* strlcat() and strlcpy() may not be in the system headers. */ +#undef strlcat +#undef strlcpy +#define strlcat(d, s, l) 0 +#define strlcpy(d, s, l) 0 + +/* readdir_r() is likely to be marked deprecated */ +#undef readdir_r +#define readdir_r(dir, dirent, result) ((errno = EINVAL), -1) +#endif + /* definition of a series of tests */ struct test { const char *name; /* test name */ @@ -1408,7 +1422,7 @@ int run_syscall(int min, int max) CASE_TEST(fork); EXPECT_SYSZR(1, test_fork(FORK_STANDARD)); break; CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; - CASE_TEST(directories); EXPECT_SYSZR(proc, test_dirent()); break; + CASE_TEST(directories); EXPECT_SYSZR(is_nolibc && proc, test_dirent()); break; CASE_TEST(getrandom); EXPECT_SYSZR(1, test_getrandom()); break; CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; CASE_TEST(gettimeofday_tv_tz);EXPECT_SYSZR(1, gettimeofday(&tv, &tz)); break; -- 2.39.5