From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B734EECAAD1 for ; Wed, 31 Aug 2022 18:26:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232901AbiHaS0H (ORCPT ); Wed, 31 Aug 2022 14:26:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232536AbiHaSZf (ORCPT ); Wed, 31 Aug 2022 14:25:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5215FF2D6B for ; Wed, 31 Aug 2022 11:21:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C3DFD61CD5 for ; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20F8FC433C1; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=G6VCAaAlg/8tBYkx3RPV5CkGGSZS3E5wZVxJmH+lP90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SVBHJbpNQdgbnc4qXYLa+ovth+GIPc7SCLhCOA6jS5UqRAf/NBnMuaRtX2GsKQV7m hpi2tqu1Sd+z1oP7yFNBuQSEKCFrIIlQa2R8hZmAGWK7q6uo8HhxxapcLBYR78jC7q Pei9AcypNaKfMPjIMe8csMI+ZQGbIUHCBSyvFiMNbu8EB+K3bA+QOy8fRX06rNqLZn BhM/pRcBsQ7QuoerunDb6speRipO+PJP4aofMvvifHF59W3gDsrvyX532HFUYeGT3N op0KYOvA6VDi8UBetIc2CnfTA+hq1JuXgYOXaiXGozu5+61Zuc7z+KRym/2P9koOaj jWyQxvf2sK78A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D16295C0143; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, "Paul E. McKenney" , John Ogness Subject: [PATCH rcu 1/2] torture: Optionally flush printk() buffers before powering off Date: Wed, 31 Aug 2022 11:21:30 -0700 Message-Id: <20220831182148.2698489-2-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The rcutorture test suite produces quite a bit of console output at the end of a test. This means that the new-in-2022 printk() kthreads are likely to be in the process of flushing output at the time of the torture_shutdown() function's call to kernel_power_off(). Normally, rcutorture relies on printk() to flush any pending output upon shutdown, the better to detect bugs in this area, for example, the one introduced by 8e274732115f ("printk: extend console_lock for per-console locking"). However, once such a bug is detected and reported, it is necessary to test the rest of the system, without noise from the already-reported bug. This commit therefore adds a torture.printk_shutdown_bug_workaround kernel parameter, which causes torture_shutdown() to invoke pr_flush(), and print an informative message on the console, immediately before invoking kernel_power_off(). When this kernel parameter is not specified, it is up to printk() to flush its own buffers. Suggested-by: John Ogness Signed-off-by: Paul E. McKenney --- Documentation/admin-guide/kernel-parameters.txt | 6 ++++++ kernel/torture.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index d7f30902fda02..ba1b8776aab83 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6143,6 +6143,12 @@ are running concurrently, especially on systems with rotating-rust storage. =20 + torture.printk_shutdown_bug_workaround=3D [KNL] + Execute pr_flush(1000, true) just before invoking + kernel_power_off() to work around any bugs that + might prevent printk() from flushing its buffers + at shutdown time. + torture.verbose_sleep_frequency=3D [KNL] Specifies how many verbose printk()s should be emitted between each sleep. The default of zero diff --git a/kernel/torture.c b/kernel/torture.c index 789aeb0e1159c..7cd2016b02076 100644 --- a/kernel/torture.c +++ b/kernel/torture.c @@ -48,6 +48,9 @@ module_param(disable_onoff_at_boot, bool, 0444); static bool ftrace_dump_at_shutdown; module_param(ftrace_dump_at_shutdown, bool, 0444); =20 +static bool printk_shutdown_bug_workaround; +module_param(printk_shutdown_bug_workaround, bool, 0444); + static int verbose_sleep_frequency; module_param(verbose_sleep_frequency, int, 0444); =20 @@ -651,6 +654,10 @@ static int torture_shutdown(void *arg) VERBOSE_TOROUT_STRING("No torture_shutdown_hook(), skipping."); if (ftrace_dump_at_shutdown) rcu_ftrace_dump(DUMP_ALL); + if (printk_shutdown_bug_workaround) { + pr_info("%s: Flushing printk() buffers at power-down time.\n", __func__); + pr_flush(1000, true); + } kernel_power_off(); /* Shut down the system. */ return 0; } --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C079DC0502A for ; Wed, 31 Aug 2022 18:26:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232585AbiHaS0E (ORCPT ); Wed, 31 Aug 2022 14:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232500AbiHaSZf (ORCPT ); Wed, 31 Aug 2022 14:25:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A81BF327A for ; Wed, 31 Aug 2022 11:21:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B5D8861CCE for ; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C3A7C433D6; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=6XP22WTmc8yL/Ak3Vl83+H3N1Eq7ZOAnCRPlATglroc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FU5A3CG2XmPZTVGIDeITHow4YBhkVZku8EyLz8IYtjfCTd1yEakYzRlDQU4nUhml6 9v5RUwRNGH0AAx3m3CIfq2x7EgyxoUtSKdEFM+tH/E7HQRUICmAp9FKL9yZpfoPm5i GMKp7pGL9deirpDTNBmVpV/fWGgZtaP6svuS67bqvpAbaIL2jhy2EeGLAlMWbpFNsw P2xUWLvmlC7kq7dbmbjY/OLX5+oAiWuZ+t7zlqTQBD98BqFUbRnzYtRuPQUVO8J4H+ K/lnTlQcACZvKzMw5EXX1psV++0UUfm96fmHzJ0gUjRXOUVsphGHJYGke7+Iy6y3DC KvW8OIx+qFL7g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id CF0BC5C015D; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , Pranith Kumar , "Paul E . McKenney" Subject: [PATCH nolibc 01/18] tools/nolibc: make argc 32-bit in riscv startup code Date: Wed, 31 Aug 2022 11:21:29 -0700 Message-Id: <20220831182148.2698489-1-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau The "ld a0, 0(sp)" instruction doesn't build on RISCV32 because that would load a 64-bit value into a 32-bit register. But argc 32-bit, not 64, so we ought to use "lw" here. Tested on both RISCV32 and RISCV64. Cc: Pranith Kumar Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-riscv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-= riscv.h index 95e2b79249257..ba04771cb3a34 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -190,7 +190,7 @@ __asm__ (".section .text\n" ".option norelax\n" "lla gp, __global_pointer$\n" ".option pop\n" - "ld a0, 0(sp)\n" // argc (a0) was in the stack + "lw a0, 0(sp)\n" // argc (a0) was in the stack "add a1, sp, "SZREG"\n" // argv (a1) =3D sp "slli a2, a0, "PTRLOG"\n" // envp (a2) =3D SZREG*argc ... "add a2, a2, "SZREG"\n" // + SZREG (skip null) --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7A30ECAAD1 for ; Wed, 31 Aug 2022 18:26:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232014AbiHaS0b (ORCPT ); Wed, 31 Aug 2022 14:26:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232755AbiHaSZh (ORCPT ); Wed, 31 Aug 2022 14:25:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 464F1A2DAC for ; Wed, 31 Aug 2022 11:21:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 824F6B82274 for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 274F7C433D7; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=PbgqrlZZosHYbW1nGq71ZuCzDyWkjMJCAl8bHAx5ujs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m2hHmhTlnhrQBP23DC4aegtGLyEdtj+cabH/135m81FavzC3rZTMlAUHM0+jOTupX b5mjGnFAGF0lle8toXNjpYU4hBkGvv1Pi0g5Du3ag+bYnhfgdmSS4EeJmdb51z+CO7 Ni6QqW3/Z5M6xQLdJk+iRjSqjcwKr9tpR1nYKoUR+bPXe5QTK3IsElV+GCOtDDDIPV GOMi4WtfuOqN3ScnYfbFWYH7D/cQqLrgLizFNGF9mF5Cnz+wbUUanCacq5vqy4ykbN cR1Zt786nh3WsneWxtNbhNwr8uGftZrf9ThZfkYO/iufD4hIBLVIMyR6+wzwC/N2el Ajq5eRSNJhDpg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D35715C02A9; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Zqiang , "Paul E . McKenney" Subject: [PATCH rcu 2/2] rcutorture: Use the barrier operation specified by cur_ops Date: Wed, 31 Aug 2022 11:21:31 -0700 Message-Id: <20220831182148.2698489-3-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zqiang The rcutorture_oom_notify() function unconditionally invokes rcu_barrier(), which is OK when the rcutorture.torture_type value is "rcu", but unhelpful otherwise. The purpose of these barrier calls is to wait for all outstanding callback-flooding callbacks to be invoked before cleaning up their data. Using the wrong barrier function therefore risks arbitrary memory corruption. Thus, this commit changes these rcu_barrier() calls into cur_ops->cb_barrier() to make things work when torturing non-vanilla flavors of RCU. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index d8e1b270a065f..08b7b59d5d05b 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2600,12 +2600,12 @@ static int rcutorture_oom_notify(struct notifier_bl= ock *self, for (i =3D 0; i < fwd_progress; i++) ncbs +=3D rcu_torture_fwd_prog_cbfree(&rfp[i]); pr_info("%s: Freed %lu RCU callbacks.\n", __func__, ncbs); - rcu_barrier(); + cur_ops->cb_barrier(); ncbs =3D 0; for (i =3D 0; i < fwd_progress; i++) ncbs +=3D rcu_torture_fwd_prog_cbfree(&rfp[i]); pr_info("%s: Freed %lu RCU callbacks.\n", __func__, ncbs); - rcu_barrier(); + cur_ops->cb_barrier(); ncbs =3D 0; for (i =3D 0; i < fwd_progress; i++) ncbs +=3D rcu_torture_fwd_prog_cbfree(&rfp[i]); --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50897ECAAD3 for ; Wed, 31 Aug 2022 18:26:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232937AbiHaS0e (ORCPT ); Wed, 31 Aug 2022 14:26:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232782AbiHaSZh (ORCPT ); Wed, 31 Aug 2022 14:25:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B58FEEF002 for ; Wed, 31 Aug 2022 11:21:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D79FA61CD9 for ; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D992C4347C; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=9uoF+g4LweCmuA8kE2/a+fIZkh1WmvOLh306TOxum+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z5TO/DIxTSPXgs2wk9pcL/8e82ok9w0UGdRmWpKKHvk6mWQl/toUj7HeeJ7XRjv4q 8Kyd3RpRGsoLgjIhI+ezj6x80BsVInfsTo8UJEuZDNrKpj+B2fRZEFM7uDRNRyDJLY iXKve3NiNrTPfIGtCWlgcKGcyOgijYkQmYeOx2o9M7v3A49taA3D0Kc06Km5C6WVU1 qRSaQcYB4m6fiHNVD4ZDjaj3ZiBDw+7NGVCFY5Pez89s33zZH9RGNdk0V8YebyJEDh AJ6u97Y1b1xFJ9xaGjZJi25g/g8s3BOt+O6h/yuaz4jXZiMxIsPuTF7UauCCAyjmgu XlcLvCKkKg5kw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D53CE5C0513; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 02/18] tools/nolibc: fix build warning in sys_mmap() when my_syscall6 is not defined Date: Wed, 31 Aug 2022 11:21:32 -0700 Message-Id: <20220831182148.2698489-4-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau We return -ENOSYS when there's no syscall6() operation, but we must cast it to void* to avoid a warning. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 08491070387bc..b8c96878c9ce0 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -692,7 +692,7 @@ void *sys_mmap(void *addr, size_t length, int prot, int= flags, int fd, { #ifndef my_syscall6 /* Function not implemented. */ - return -ENOSYS; + return (void *)-ENOSYS; #else =20 int n; --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73313ECAAD3 for ; Wed, 31 Aug 2022 18:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232825AbiHaS0M (ORCPT ); Wed, 31 Aug 2022 14:26:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbiHaSZg (ORCPT ); Wed, 31 Aug 2022 14:25:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4639DFBA5C for ; Wed, 31 Aug 2022 11:21:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8C4C2B82275 for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B220C433B5; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=nNEzh9yptkWyGVGTNGnwj/QZ/DlDOZpEjF3yTgBo8vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZMnDNVNxWh37xzFyn2SrR0BhE+uv0Vc4Uxki6au7y/gH1lspujGeOBnLqPIzK1Jjv Dn4GMm6dYqHJCxUTvZS18tUBCUADxMVrtUqAoUQVGIBIZCHCVfrC1Cm81W8DbmEfih 7ohz0ZrsCMYtcEY+WOuKhuKejvuGE0UqKynP+UctXusRUOsrFFBBsUjvaHCx3sVaXO o6I1mg1hRT7AltbA2/V8HUYVqhA13YOTsPrqASjCsqPfv0bfG75h8VPah12kFJ/idP +pAoeCaiwkeaDQMhiPzCkoQmy2jsPOcY2AbXNC2p0j0R63EXbF0WpO8dXQIcmMvK76 m1sFC6vRoVjcw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D712E5C06A7; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 03/18] tools/nolibc: make sys_mmap() automatically use the right __NR_mmap definition Date: Wed, 31 Aug 2022 11:21:33 -0700 Message-Id: <20220831182148.2698489-5-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau __NR_mmap2 was used for i386 but it's also needed for other archs such as RISCV32 or ARM. Let's decide to use it based on the __NR_mmap2 definition as it's not defined on other archs. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index b8c96878c9ce0..ce3ee03aa6794 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -697,7 +697,7 @@ void *sys_mmap(void *addr, size_t length, int prot, int= flags, int fd, =20 int n; =20 -#if defined(__i386__) +#if defined(__NR_mmap2) n =3D __NR_mmap2; offset >>=3D 12; #else --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE2D0ECAAD1 for ; Wed, 31 Aug 2022 18:26:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231645AbiHaS0x (ORCPT ); Wed, 31 Aug 2022 14:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232791AbiHaSZp (ORCPT ); Wed, 31 Aug 2022 14:25:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26B88FBA7E for ; Wed, 31 Aug 2022 11:21:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 65A1D61CDA for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E56EC43148; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=lb42YBMvLlJW4lhYMw9xjWvBOmbnubrtUFTuevru2ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cFqs+jXql95dhNhsLgp/E6VykkPUTD3fs0WXfOsZfDFEkra8Gd/eyNwUDvSIrDf63 c3x34MVYx7EiM/qw2CMIiEfY/kRThs0L/KjcySwSUABqc/apZ/rDtaBZvFwCx2b3Dz nbZ+Eoy13AU4LIFECFwPPXuKOoTuIok3YUyDIspTrHDd2NPToVDv/a063RD/ntbMCV 6A59fYamRPZNywb/lPJQOooOmIj+HibhC8biw8c8vjDIG2XBP3vUAWmovnl/avxPdX qCx4epYJDsXtJK2BLiItnrKDIkVS8NczIV9P8VeImjxItL9TZppRYeUjsnJZ6JGT5W fbkMyefLIcOAw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D905F5C090A; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 04/18] selftests/nolibc: add basic infrastructure to ease creation of nolibc tests Date: Wed, 31 Aug 2022 11:21:34 -0700 Message-Id: <20220831182148.2698489-6-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau This creates a "nolibc" selftest that intends to test various parts of the nolibc component, both in terms of build and execution for a given architecture. The aim is for it to be as simple to run as a kernel build, by just passing the compiler (for the build) and the ARCH (for kernel and execution). It brings a basic squeleton made of a single C file that will ease testing and error reporting. The code will be arranged so that it remains easy to add basic tests for syscalls or library calls that may rely on a condition to be executed, and whose result is compared to a value or to an error with a specific errno value. Tests will just use a relative line number in switch/case statements as an index, saving the user from having to maintain arrays and complicated functions which can often just be one-liners. MAINTAINERS was updated. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- MAINTAINERS | 1 + tools/testing/selftests/nolibc/Makefile | 43 ++ tools/testing/selftests/nolibc/nolibc-test.c | 395 +++++++++++++++++++ 3 files changed, 439 insertions(+) create mode 100644 tools/testing/selftests/nolibc/Makefile create mode 100644 tools/testing/selftests/nolibc/nolibc-test.c diff --git a/MAINTAINERS b/MAINTAINERS index 8a5012ba6ff98..89f939ad19963 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14444,6 +14444,7 @@ M: Willy Tarreau S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/nolibc.git F: tools/include/nolibc/ +F: tools/testing/selftests/nolibc/ =20 NSDEPS M: Matthias Maennich diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile new file mode 100644 index 0000000000000..fd0a670823340 --- /dev/null +++ b/tools/testing/selftests/nolibc/Makefile @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: GPL-2.0 +# Makefile for nolibc tests +include ../../../scripts/Makefile.include + +# we're in ".../tools/testing/selftests/nolibc" +ifeq ($(srctree),) +srctree :=3D $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR))) +endif + +ifeq ($(ARCH),) +include $(srctree)/scripts/subarch.include +ARCH =3D $(SUBARCH) +endif + +# OUTPUT is only set when run from the main makefile, otherwise +# it defaults to this nolibc directory. +OUTPUT ?=3D $(CURDIR)/ + +ifeq ($(V),1) +Q=3D +else +Q=3D@ +endif + +CFLAGS ?=3D -Os -fno-ident -fno-asynchronous-unwind-tables +LDFLAGS :=3D -s + +all: nolibc-test + +nolibc-test: nolibc-test.c + $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ + -nostdlib -static -include ../../../include/nolibc/nolibc.h $^ -lgcc + +initramfs: nolibc-test + $(QUIET_MKDIR)mkdir -p initramfs + $(call QUIET_INSTALL, initramfs/init) + $(Q)cp nolibc-test initramfs/init + +clean: + $(call QUIET_CLEAN, nolibc-test) + $(Q)rm -f nolibc-test + $(call QUIET_CLEAN, initramfs) + $(Q)rm -rf initramfs diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c new file mode 100644 index 0000000000000..6c050d4381fec --- /dev/null +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -0,0 +1,395 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* platform-specific include files coming from the compiler */ +#include + +/* libc-specific include files + * The program may be built in 2 ways: + * $(CC) -nostdlib -include /path/to/nolibc.h =3D> NOLIBC already defined + * $(CC) -nostdlib -I/path/to/nolibc/sysroot + */ +#ifndef NOLIBC +#include +#include +#include +#endif + +/* will be used by nolibc by getenv() */ +char **environ; + +#define CASE_ERR(err) \ + case err: return #err + +/* returns the error name (e.g. "ENOENT") for common errors, "SUCCESS" for= 0, + * or the decimal value for less common ones. + */ +const char *errorname(int err) +{ + switch (err) { + case 0: return "SUCCESS"; + CASE_ERR(EPERM); + CASE_ERR(ENOENT); + CASE_ERR(ESRCH); + CASE_ERR(EINTR); + CASE_ERR(EIO); + CASE_ERR(ENXIO); + CASE_ERR(E2BIG); + CASE_ERR(ENOEXEC); + CASE_ERR(EBADF); + CASE_ERR(ECHILD); + CASE_ERR(EAGAIN); + CASE_ERR(ENOMEM); + CASE_ERR(EACCES); + CASE_ERR(EFAULT); + CASE_ERR(ENOTBLK); + CASE_ERR(EBUSY); + CASE_ERR(EEXIST); + CASE_ERR(EXDEV); + CASE_ERR(ENODEV); + CASE_ERR(ENOTDIR); + CASE_ERR(EISDIR); + CASE_ERR(EINVAL); + CASE_ERR(ENFILE); + CASE_ERR(EMFILE); + CASE_ERR(ENOTTY); + CASE_ERR(ETXTBSY); + CASE_ERR(EFBIG); + CASE_ERR(ENOSPC); + CASE_ERR(ESPIPE); + CASE_ERR(EROFS); + CASE_ERR(EMLINK); + CASE_ERR(EPIPE); + CASE_ERR(EDOM); + CASE_ERR(ERANGE); + CASE_ERR(ENOSYS); + default: + return itoa(err); + } +} + +static int pad_spc(int llen, int cnt, const char *fmt, ...) +{ + va_list args; + int len; + int ret; + + for (len =3D 0; len < cnt - llen; len++) + putchar(' '); + + va_start(args, fmt); + ret =3D vfprintf(stdout, fmt, args); + va_end(args); + return ret < 0 ? ret : ret + len; +} + +/* The tests below are intended to be used by the macroes, which evaluate + * expression , print the status to stdout, and update the "ret" + * variable to count failures. The functions themselves return the number + * of failures, thus either 0 or 1. + */ + +#define EXPECT_ZR(cond, expr) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_zr= (expr, llen); } while (0) + +static int expect_zr(int expr, int llen) +{ + int ret =3D !(expr =3D=3D 0); + + llen +=3D printf(" =3D %d ", expr); + pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + return ret; +} + + +#define EXPECT_NZ(cond, expr, val) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_nz= (expr, llen; } while (0) + +static int expect_nz(int expr, int llen) +{ + int ret =3D !(expr !=3D 0); + + llen +=3D printf(" =3D %d ", expr); + pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + return ret; +} + + +#define EXPECT_EQ(cond, expr, val) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_eq= (expr, llen, val); } while (0) + +static int expect_eq(int expr, int llen, int val) +{ + int ret =3D !(expr =3D=3D val); + + llen +=3D printf(" =3D %d ", expr); + pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + return ret; +} + + +#define EXPECT_NE(cond, expr, val) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_ne= (expr, llen, val); } while (0) + +static int expect_ne(int expr, int llen, int val) +{ + int ret =3D !(expr !=3D val); + + llen +=3D printf(" =3D %d ", expr); + pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + return ret; +} + + +#define EXPECT_GE(cond, expr, val) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_ge= (expr, llen, val); } while (0) + +static int expect_ge(int expr, int llen, int val) +{ + int ret =3D !(expr >=3D val); + + llen +=3D printf(" =3D %d ", expr); + pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + return ret; +} + + +#define EXPECT_GT(cond, expr, val) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_gt= (expr, llen, val); } while (0) + +static int expect_gt(int expr, int llen, int val) +{ + int ret =3D !(expr > val); + + llen +=3D printf(" =3D %d ", expr); + pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + return ret; +} + + +#define EXPECT_LE(cond, expr, val) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_le= (expr, llen, val); } while (0) + +static int expect_le(int expr, int llen, int val) +{ + int ret =3D !(expr <=3D val); + + llen +=3D printf(" =3D %d ", expr); + pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + return ret; +} + + +#define EXPECT_LT(cond, expr, val) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_lt= (expr, llen, val); } while (0) + +static int expect_lt(int expr, int llen, int val) +{ + int ret =3D !(expr < val); + + llen +=3D printf(" =3D %d ", expr); + pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + return ret; +} + + +#define EXPECT_SYSZR(cond, expr) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_sy= szr(expr, llen); } while (0) + +static int expect_syszr(int expr, int llen) +{ + int ret =3D 0; + + if (expr) { + ret =3D 1; + llen +=3D printf(" =3D %d %s ", expr, errorname(errno)); + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D printf(" =3D %d ", expr); + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + + +#define EXPECT_SYSEQ(cond, expr, val) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_sy= seq(expr, llen, val); } while (0) + +static int expect_syseq(int expr, int llen, int val) +{ + int ret =3D 0; + + if (expr !=3D val) { + ret =3D 1; + llen +=3D printf(" =3D %d %s ", expr, errorname(errno)); + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D printf(" =3D %d ", expr); + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + + +#define EXPECT_SYSNE(cond, expr, val) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_sy= sne(expr, llen, val); } while (0) + +static int expect_sysne(int expr, int llen, int val) +{ + int ret =3D 0; + + if (expr =3D=3D val) { + ret =3D 1; + llen +=3D printf(" =3D %d %s ", expr, errorname(errno)); + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D printf(" =3D %d ", expr); + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + + +#define EXPECT_SYSER(cond, expr, expret, experr) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_sy= serr(expr, expret, experr, llen); } while (0) + +static int expect_syserr(int expr, int expret, int experr, int llen) +{ + int ret =3D 0; + int _errno =3D errno; + + llen +=3D printf(" =3D %d %s ", expr, errorname(_errno)); + if (expr !=3D expret || _errno !=3D experr) { + ret =3D 1; + llen +=3D printf(" !=3D (%d %s) ", expret, errorname(experr)); + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + + +#define EXPECT_PTRZR(cond, expr) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_pt= rzr(expr, llen); } while (0) + +static int expect_ptrzr(const void *expr, int llen) +{ + int ret =3D 0; + + llen +=3D printf(" =3D <%p> ", expr); + if (expr) { + ret =3D 1; + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + + +#define EXPECT_PTRNZ(cond, expr) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_pt= rnz(expr, llen); } while (0) + +static int expect_ptrnz(const void *expr, int llen) +{ + int ret =3D 0; + + llen +=3D printf(" =3D <%p> ", expr); + if (!expr) { + ret =3D 1; + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + + +#define EXPECT_STRZR(cond, expr) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_st= rzr(expr, llen); } while (0) + +static int expect_strzr(const char *expr, int llen) +{ + int ret =3D 0; + + llen +=3D printf(" =3D <%s> ", expr); + if (expr) { + ret =3D 1; + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + + +#define EXPECT_STRNZ(cond, expr) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_st= rnz(expr, llen); } while (0) + +static int expect_strnz(const char *expr, int llen) +{ + int ret =3D 0; + + llen +=3D printf(" =3D <%s> ", expr); + if (!expr) { + ret =3D 1; + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + + +#define EXPECT_STREQ(cond, expr, cmp) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_st= req(expr, llen, cmp); } while (0) + +static int expect_streq(const char *expr, int llen, const char *cmp) +{ + int ret =3D 0; + + llen +=3D printf(" =3D <%s> ", expr); + if (strcmp(expr, cmp) !=3D 0) { + ret =3D 1; + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + + +#define EXPECT_STRNE(cond, expr, cmp) \ + do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_st= rne(expr, llen, cmp); } while (0) + +static int expect_strne(const char *expr, int llen, const char *cmp) +{ + int ret =3D 0; + + llen +=3D printf(" =3D <%s> ", expr); + if (strcmp(expr, cmp) =3D=3D 0) { + ret =3D 1; + llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + } else { + llen +=3D pad_spc(llen, 40, " [OK]\n"); + } + return ret; +} + +/* declare tests based on line numbers. There must be exactly one test per= line. */ +#define CASE_TEST(name) \ + case __LINE__: llen +=3D printf("%d %s", test, #name); + + +int main(int argc, char **argv, char **envp) +{ + int min =3D 0; + int max =3D __INT_MAX__; + int ret =3D 0; + + environ =3D envp; + + printf("Total number of errors: %d\n", ret); + printf("Exiting with status %d\n", !!ret); + return !!ret; +} --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 914FEECAAD3 for ; Wed, 31 Aug 2022 18:26:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232913AbiHaS0S (ORCPT ); Wed, 31 Aug 2022 14:26:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232739AbiHaSZg (ORCPT ); Wed, 31 Aug 2022 14:25:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45EE4FB294 for ; Wed, 31 Aug 2022 11:21:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6377861CDE for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CFE2C43145; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=SQPsyy9Vw1zAhKnxU2HPB0epktjeTQk3RDWN/C0VtjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uTzY4pGiBFNhDe/LhkJfWLA/OI5kQxPv6QKYYcFwxRtIUjY78yHG37at6JH/4OW5g +w7eektmCnuAFAfpVKmj/Uf6icornAmMnfLXnsrTYFwwQVrGfQf0CM88Wjjejz4xG/ DYcV7RpnyMbd8/gFqdlTXecUV201Qeq76KsFMdkter6gv3OtI8H1NR/pG33P2b32UW PhuwFc8PrinDnU43L1je4T7tJ4Fw3qVRi24lMbt377VtcvOghQZvVM8vtyUaSciG+I nq7kR3RNOl4F0r07WO5TvC24Zhd9y7wSLfj011I38LqXq0mGLwMATJLMhyI9ahGNFK a1oJ/gRaG9cnw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DBBD65C0950; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 05/18] selftests/nolibc: support a test definition format Date: Wed, 31 Aug 2022 11:21:35 -0700 Message-Id: <20220831182148.2698489-7-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau It now becomes possible to pass a string either in argv[1] or in the NOLIBC_TEST environment variable (the former having precedence), to specify which tests to run. The format is: testname[:range]*[,testname...] Where a range is either a single value or the min and max numbers of the test IDs in a sequence, delimited by a dash. Multiple ranges are possible. This should provide enough flexibility to focus on certain failing parts just by playing with the boot command line in a boot loader or in qemu depending on what is accessible. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 91 ++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 6c050d4381fec..49177ea9943cc 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -17,6 +17,12 @@ /* will be used by nolibc by getenv() */ char **environ; =20 +/* definition of a series of tests */ +struct test { + const char *name; // test name + int (*func)(int min, int max); // handler +}; + #define CASE_ERR(err) \ case err: return #err =20 @@ -376,19 +382,104 @@ static int expect_strne(const char *expr, int llen, = const char *cmp) return ret; } =20 + /* declare tests based on line numbers. There must be exactly one test per= line. */ #define CASE_TEST(name) \ case __LINE__: llen +=3D printf("%d %s", test, #name); =20 =20 +/* This is the definition of known test names, with their functions */ +static struct test test_names[] =3D { + /* add new tests here */ + { 0 } +}; + int main(int argc, char **argv, char **envp) { int min =3D 0; int max =3D __INT_MAX__; int ret =3D 0; + int err; + int idx; + char *test; =20 environ =3D envp; =20 + /* the definition of a series of tests comes from either argv[1] or the + * "NOLIBC_TEST" environment variable. It's made of a comma-delimited + * series of test names and optional ranges: + * syscall:5-15[:.*],stdlib:8-10 + */ + test =3D argv[1]; + if (!test) + test =3D getenv("NOLIBC_TEST"); + + if (test) { + char *comma, *colon, *dash, *value; + + do { + comma =3D strchr(test, ','); + if (comma) + *(comma++) =3D '\0'; + + colon =3D strchr(test, ':'); + if (colon) + *(colon++) =3D '\0'; + + for (idx =3D 0; test_names[idx].name; idx++) { + if (strcmp(test, test_names[idx].name) =3D=3D 0) + break; + } + + if (test_names[idx].name) { + /* The test was named, it will be called at least + * once. We may have an optional range at + * here, which defaults to the full range. + */ + do { + min =3D 0; max =3D __INT_MAX__; + value =3D colon; + if (value && *value) { + colon =3D strchr(value, ':'); + if (colon) + *(colon++) =3D '\0'; + + dash =3D strchr(value, '-'); + if (dash) + *(dash++) =3D '\0'; + + /* support :val: :min-max: :min-: :-max: */ + if (*value) + min =3D atoi(value); + if (!dash) + max =3D min; + else if (*dash) + max =3D atoi(dash); + + value =3D colon; + } + + /* now's time to call the test */ + printf("Running test '%s'\n", test_names[idx].name); + err =3D test_names[idx].func(min, max); + ret +=3D err; + printf("Errors during this test: %d\n\n", err); + } while (colon && *colon); + } else + printf("Ignoring unknown test name '%s'\n", test); + + test =3D comma; + } while (test && *test); + } else { + /* no test mentioned, run everything */ + for (idx =3D 0; test_names[idx].name; idx++) { + printf("Running test '%s'\n", test_names[idx].name); + err =3D test_names[idx].func(min, max); + ret +=3D err; + printf("Errors during this test: %d\n\n", err); + } + } + printf("Total number of errors: %d\n", ret); printf("Exiting with status %d\n", !!ret); return !!ret; --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC879ECAAD3 for ; Wed, 31 Aug 2022 18:26:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232859AbiHaS0l (ORCPT ); Wed, 31 Aug 2022 14:26:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232860AbiHaSZj (ORCPT ); Wed, 31 Aug 2022 14:25:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40880FCA0C for ; Wed, 31 Aug 2022 11:21:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 00E6DB82273 for ; Wed, 31 Aug 2022 18:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D009C43146; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=P67HLCtareZHyS5w7ZkkvyTWtCvesN1SPEN962WT4qM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=awkdzw93uTP/OIjMot/kYfc48LiKIEhls/Ld7GN4LJ9tRh2U0SeRLzl2HDHtsQkTE tTFFLdrJfWBwBD23nElUNWksTJvBS/UqGOAy3+qRUQU0ewoKM2K6SjEIRtxD/VynQi DK9zsjRC4+EFh5Vfy1yZtH+oRKRmM4PbNJwJ1T1MW41J4YL4TQskN56d9jAvexVuOL CHDDR/HHFUQ2gPO4BE5eHtME7AjldYBPUGisD85aW4irhZJ7QxpJVFOAudy8ctIjDR TmMWe/5rst58UDGEKUQfrsIMejYbUBvSlN6ibaXwSUIgzmcMgS9f1Y3wHx0eM4dmV6 OqWVBK6Qq7Exg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DD03F5C0981; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 06/18] selftests/nolibc: implement a few tests for various syscalls Date: Wed, 31 Aug 2022 11:21:36 -0700 Message-Id: <20220831182148.2698489-8-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau This adds 63 tests covering about 34 syscalls. Both successes and failures are tested. Two tests fail when run as unprivileged user (link_dir which returns EACCESS instead of EPERM, and chroot which returns EPERM). One test (execve("/")) expects to fail on EACCESS, but needs to have valid arguments otherwise the kernel will log a message. And a few tests require /proc to be mounted. The code is not pretty since all tests are one-liners, sometimes resulting in long lines, especially when using compount statements to preset a line, but it's convenient and doesn't obfuscate the code, which is important to understand what failed. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 110 +++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 49177ea9943cc..dc87832912ce4 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -388,9 +388,119 @@ static int expect_strne(const char *expr, int llen, c= onst char *cmp) case __LINE__: llen +=3D printf("%d %s", test, #name); =20 =20 +/* used by some syscall tests below */ +int test_getdents64(const char *dir) +{ + char buffer[4096]; + int fd, ret; + int err; + + ret =3D fd =3D open(dir, O_RDONLY | O_DIRECTORY, 0); + if (ret < 0) + return ret; + + ret =3D getdents64(fd, (void *)buffer, sizeof(buffer)); + err =3D errno; + close(fd); + + errno =3D err; + return ret; +} + +/* Run syscall tests between IDs and . + * Return 0 on success, non-zero on failure. + */ +int run_syscall(int min, int max) +{ + struct stat stat_buf; + int test; + int tmp; + int ret =3D 0; + void *p1, *p2; + + for (test =3D min; test >=3D 0 && test <=3D max; test++) { + int llen =3D 0; // line length + + /* avoid leaving empty lines below, this will insert holes into + * test numbers. + */ + switch (test + __LINE__ + 1) { + CASE_TEST(getpid); EXPECT_SYSNE(1, getpid(), -1); break; + CASE_TEST(getppid); EXPECT_SYSNE(1, getppid(), -1); break; + CASE_TEST(gettid); EXPECT_SYSNE(1, gettid(), -1); break; + CASE_TEST(getpgid_self); EXPECT_SYSNE(1, getpgid(0), -1); break; + CASE_TEST(getpgid_bad); EXPECT_SYSER(1, getpgid(-1), -1, ESRCH); b= reak; + CASE_TEST(kill_0); EXPECT_SYSZR(1, kill(getpid(), 0)); break; + CASE_TEST(kill_CONT); EXPECT_SYSZR(1, kill(getpid(), 0)); break; + CASE_TEST(kill_BADPID); EXPECT_SYSER(1, kill(INT_MAX, 0), -1, ESRC= H); break; + CASE_TEST(sbrk); if ((p1 =3D p2 =3D sbrk(4096)) !=3D (void = *)-1) p2 =3D sbrk(-4096); EXPECT_SYSZR(1, (p2 =3D=3D (void *)-1) || p2 =3D= =3D p1); break; + CASE_TEST(brk); EXPECT_SYSZR(1, brk(sbrk(0))); break; + CASE_TEST(chdir_root); EXPECT_SYSZR(1, chdir("/")); break; + CASE_TEST(chdir_dot); EXPECT_SYSZR(1, chdir(".")); break; + CASE_TEST(chdir_blah); EXPECT_SYSER(1, chdir("/blah"), -1, ENOENT= ); break; + CASE_TEST(chmod_net); EXPECT_SYSZR(1, chmod("/proc/self/net", 05= 55)); break; + CASE_TEST(chmod_self); EXPECT_SYSER(1, chmod("/proc/self", 0555),= -1, EPERM); break; + CASE_TEST(chown_self); EXPECT_SYSER(1, chown("/proc/self", 0, 0),= -1, EPERM); break; + CASE_TEST(chroot_root); EXPECT_SYSZR(1, chroot("/")); break; + CASE_TEST(chroot_blah); EXPECT_SYSER(1, chroot("/proc/self/blah"),= -1, ENOENT); break; + CASE_TEST(chroot_exe); EXPECT_SYSER(1, chroot("/proc/self/exe"), = -1, ENOTDIR); break; + CASE_TEST(close_m1); EXPECT_SYSER(1, close(-1), -1, EBADF); bre= ak; + CASE_TEST(close_dup); EXPECT_SYSZR(1, close(dup(0))); break; + CASE_TEST(dup_0); tmp =3D dup(0); EXPECT_SYSNE(1, tmp, -1);= close(tmp); break; + CASE_TEST(dup_m1); tmp =3D dup(-1); EXPECT_SYSER(1, tmp, -1, = EBADF); if (tmp !=3D -1) close(tmp); break; + CASE_TEST(dup2_0); tmp =3D dup2(0, 100); EXPECT_SYSNE(1, tmp= , -1); close(tmp); break; + CASE_TEST(dup2_m1); tmp =3D dup2(-1, 100); EXPECT_SYSER(1, tmp= , -1, EBADF); if (tmp !=3D -1) close(tmp); break; + CASE_TEST(dup3_0); tmp =3D dup3(0, 100, 0); EXPECT_SYSNE(1, = tmp, -1); close(tmp); break; + CASE_TEST(dup3_m1); tmp =3D dup3(-1, 100, 0); EXPECT_SYSER(1, = tmp, -1, EBADF); if (tmp !=3D -1) close(tmp); break; + CASE_TEST(execve_root); EXPECT_SYSER(1, execve("/", (char*[]){ [0]= =3D "/", [1] =3D NULL }, NULL), -1, EACCES); 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(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL));= break; + CASE_TEST(gettimeofday_bad1); EXPECT_SYSER(1, gettimeofday((void *)1, NU= LL), -1, EFAULT); break; + CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *= )1), -1, EFAULT); break; + CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *= )1), -1, EFAULT); break; + CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); = break; + CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); = break; + CASE_TEST(link_root1); EXPECT_SYSER(1, link("/", "/"), -1, EEXIST= ); break; + CASE_TEST(link_blah); EXPECT_SYSER(1, link("/proc/self/blah", "/= blah"), -1, ENOENT); break; + CASE_TEST(link_dir); EXPECT_SYSER(1, link("/", "/blah"), -1, EP= ERM); break; + CASE_TEST(link_cross); EXPECT_SYSER(1, link("/proc/self/net", "/b= lah"), -1, EXDEV); break; + CASE_TEST(lseek_m1); EXPECT_SYSER(1, lseek(-1, 0, SEEK_SET), -1= , EBADF); break; + CASE_TEST(lseek_0); EXPECT_SYSER(1, lseek(0, 0, SEEK_SET), -1,= ESPIPE); break; + CASE_TEST(mkdir_root); EXPECT_SYSER(1, mkdir("/", 0755), -1, EEXI= ST); break; + CASE_TEST(open_tty); EXPECT_SYSNE(1, tmp =3D open("/dev/null", = 0), -1); if (tmp !=3D -1) close(tmp); break; + CASE_TEST(open_blah); EXPECT_SYSER(1, tmp =3D open("/proc/self/b= lah", 0), -1, ENOENT); if (tmp !=3D -1) close(tmp); break; + CASE_TEST(poll_null); EXPECT_SYSZR(1, poll(NULL, 0, 0)); break; + CASE_TEST(poll_stdout); EXPECT_SYSNE(1, ({ struct pollfd fds =3D {= 1, POLLOUT, 0}; poll(&fds, 1, 0); }), -1); break; + CASE_TEST(poll_fault); EXPECT_SYSER(1, poll((void *)1, 1, 0), -1,= EFAULT); break; + CASE_TEST(read_badf); EXPECT_SYSER(1, read(-1, &tmp, 1), -1, EBA= DF); break; + CASE_TEST(sched_yield); EXPECT_SYSZR(1, sched_yield()); break; + CASE_TEST(select_null); EXPECT_SYSZR(1, ({ struct timeval tv =3D {= 0 }; select(0, NULL, NULL, NULL, &tv); })); break; + CASE_TEST(select_stdout); EXPECT_SYSNE(1, ({ fd_set fds; FD_ZERO(&fd= s); FD_SET(1, &fds); select(2, NULL, &fds, NULL, NULL); }), -1); break; + CASE_TEST(select_fault); EXPECT_SYSER(1, select(1, (void *)1, NULL,= NULL, 0), -1, EFAULT); break; + CASE_TEST(stat_blah); EXPECT_SYSER(1, stat("/proc/self/blah", &s= tat_buf), -1, ENOENT); break; + CASE_TEST(stat_fault); EXPECT_SYSER(1, stat(NULL, &stat_buf), -1,= EFAULT); break; + CASE_TEST(symlink_root); EXPECT_SYSER(1, symlink("/", "/"), -1, EEX= IST); break; + CASE_TEST(unlink_root); EXPECT_SYSER(1, unlink("/"), -1, EISDIR); = break; + CASE_TEST(unlink_blah); EXPECT_SYSER(1, unlink("/proc/self/blah"),= -1, ENOENT); break; + CASE_TEST(wait_child); EXPECT_SYSER(1, wait(&tmp), -1, ECHILD); b= reak; + CASE_TEST(waitpid_min); EXPECT_SYSER(1, waitpid(INT_MIN, &tmp, WNO= HANG), -1, ESRCH); break; + CASE_TEST(waitpid_child); EXPECT_SYSER(1, waitpid(getpid(), &tmp, WN= OHANG), -1, ECHILD); break; + CASE_TEST(write_badf); EXPECT_SYSER(1, write(-1, &tmp, 1), -1, EB= ADF); break; + CASE_TEST(write_zero); EXPECT_SYSZR(1, write(1, &tmp, 0)); break; + case __LINE__: + return ret; /* must be last */ + /* note: do not set any defaults so as to permit holes above */ + } + } + return ret; +} + + /* This is the definition of known test names, with their functions */ static struct test test_names[] =3D { /* add new tests here */ + { .name =3D "syscall", .func =3D run_syscall }, { 0 } }; =20 --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB5C2ECAAD3 for ; Wed, 31 Aug 2022 18:26:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230340AbiHaS00 (ORCPT ); Wed, 31 Aug 2022 14:26:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232756AbiHaSZh (ORCPT ); Wed, 31 Aug 2022 14:25:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 409C1FCA2C for ; Wed, 31 Aug 2022 11:21:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0F780B82278 for ; Wed, 31 Aug 2022 18:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D613C43147; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=Cc1PozE4Kvo2KpHAs/2aNkgoLKg3JAhc3RNFnVGkdlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DonB0/CVLG3l2uQY+D8qFgEMnR1rFNq4Af5Svwo2EM5tXyCJm4wjRcUw1YLb3b9/L Kti+1NzP41QbSzjO7oqaB54J6asvqX7e0/d3Yp7DAIiFmxs/cGaVBvT3Y3zKQkZFt4 BL1Ak7etLvMHCb8uk84YwcZ2wES2rt/xLqkAvMGu85khdbbprH+JiZgDP2DKD8zGfe YUBXqdCgZ5x0jbxNtd3eIug9+HR6O4I14ajmDQNdS3XAviHQZYiEyRdRGt2I35Z4Qv 4duFMw1hdLZg6oSflkMXGAlh0FoVLTO+UNi5Rd58Nm9fRQX7f668CL5xSwKOtUYjyF 8cSSaj9V/uMAQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DEE785C09C2; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 07/18] selftests/nolibc: add a few tests for some libc functions Date: Wed, 31 Aug 2022 11:21:37 -0700 Message-Id: <20220831182148.2698489-9-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau The test series called "stdlib" covers some libc functions (string, stdlib etc). By default they are automatically run after "syscall" but may be requested in argument or in variable NOLIBC_TEST. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index dc87832912ce4..b928f099431f7 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -496,11 +496,46 @@ int run_syscall(int min, int max) return ret; } =20 +int run_stdlib(int min, int max) +{ + int test; + int tmp; + int ret =3D 0; + void *p1, *p2; + + for (test =3D min; test >=3D 0 && test <=3D max; test++) { + int llen =3D 0; // line length + + /* avoid leaving empty lines below, this will insert holes into + * test numbers. + */ + switch (test + __LINE__ + 1) { + CASE_TEST(getenv_TERM); EXPECT_STRNZ(1, getenv("TERM")); break; + CASE_TEST(getenv_blah); EXPECT_STRZR(1, getenv("blah")); break; + CASE_TEST(setcmp_blah_blah); EXPECT_EQ(1, strcmp("blah", "blah"), 0); = break; + CASE_TEST(setcmp_blah_blah2); EXPECT_NE(1, strcmp("blah", "blah2"), 0);= break; + CASE_TEST(setncmp_blah_blah); EXPECT_EQ(1, strncmp("blah", "blah", 10),= 0); break; + CASE_TEST(setncmp_blah_blah4); EXPECT_EQ(1, strncmp("blah", "blah4", 4),= 0); break; + CASE_TEST(setncmp_blah_blah5); EXPECT_NE(1, strncmp("blah", "blah5", 5),= 0); break; + CASE_TEST(setncmp_blah_blah6); EXPECT_NE(1, strncmp("blah", "blah6", 6),= 0); break; + CASE_TEST(strchr_foobar_o); EXPECT_STREQ(1, strchr("foobar", 'o'), "o= obar"); break; + CASE_TEST(strchr_foobar_z); EXPECT_STRZR(1, strchr("foobar", 'z')); b= reak; + CASE_TEST(strrchr_foobar_o); EXPECT_STREQ(1, strrchr("foobar", 'o'), "= obar"); break; + CASE_TEST(strrchr_foobar_z); EXPECT_STRZR(1, strrchr("foobar", 'z')); = break; + case __LINE__: + return ret; /* must be last */ + /* note: do not set any defaults so as to permit holes above */ + } + } + return ret; +} + =20 /* This is the definition of known test names, with their functions */ static struct test test_names[] =3D { /* add new tests here */ { .name =3D "syscall", .func =3D run_syscall }, + { .name =3D "stdlib", .func =3D run_stdlib }, { 0 } }; =20 --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0D0CECAAD1 for ; Wed, 31 Aug 2022 18:27:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232787AbiHaS1K (ORCPT ); Wed, 31 Aug 2022 14:27:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbiHaSZq (ORCPT ); Wed, 31 Aug 2022 14:25:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 269E21F2C2 for ; Wed, 31 Aug 2022 11:21:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A2998B82282 for ; Wed, 31 Aug 2022 18:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D974C4314B; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=fmmGXrtft4WY+vYxlsPoch8NfKf9311WO6goU05GNWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sKiFWYHWw3ttCgjlsyc2E1INvfoTWR9OpKuHkufgBVo5RJr1haye3k19z1zICIyDb Y45L3NkcrTYqzl/LkYwzg5PEUkYcD805Z7uE2apsuloFYftTH4YQzhM7j/d3XNuoeg MfL5xtC8p0wpAAX4Fs3nPbsVNVt7zWosCh7uyJS3Fad2BLZJWZokgEL4qUOSu70PDc 9RUgK9CLEwMyHj5aXhhiZSORjNQ6LdA+Kve3cAd59VQudoFtoQJ0AxO0HHReRvjiHM 2fuvLc4A7HqzuLtjUP63Xr8qhwsDIrDvVXgVDm0GuyUcYzk23lmoSRE2BdoTjM/Pr/ fdcXIe0stWfYA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E09525C0A6B; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 08/18] selftests/nolibc: exit with poweroff on success when getpid() == 1 Date: Wed, 31 Aug 2022 11:21:38 -0700 Message-Id: <20220831182148.2698489-10-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau The idea is to ease automated testing under qemu. If the test succeeds while running as PID 1, indicating the system was booted with init=3D/test, let's just power off so that qemu can exit with a successful code. In other situations it will exit and provoke a panic, which may be caught for example with CONFIG_PVPANIC. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index b928f099431f7..291d96bfd7c12 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -626,6 +626,20 @@ int main(int argc, char **argv, char **envp) } =20 printf("Total number of errors: %d\n", ret); + + if (getpid() =3D=3D 1) { + /* we're running as init, there's no other process on the + * system, thus likely started from a VM for a quick check. + * Exiting will provoke a kernel panic that may be reported + * as an error by Qemu or the hypervisor, while stopping + * cleanly will often be reported as a success. This allows + * to use the output of this program for bisecting kernels. + */ + printf("Leaving init with final status: %d\n", !!ret); + if (ret =3D=3D 0) + reboot(LINUX_REBOOT_CMD_POWER_OFF); + } + printf("Exiting with status %d\n", !!ret); return !!ret; } --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88296ECAAD1 for ; Wed, 31 Aug 2022 18:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231653AbiHaS0i (ORCPT ); Wed, 31 Aug 2022 14:26:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232855AbiHaSZi (ORCPT ); Wed, 31 Aug 2022 14:25:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E15FC30B for ; Wed, 31 Aug 2022 11:21:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 93ADA61CE3 for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89F5FC4314A; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=ji7Ed4q5NuKbjIkgjEFzkBepKawEfl7hcBFRLDYPOOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jH5dGoI7dwzUvb9xbHnxXkdaEdEXKojiLHWsoVR+4UKLEFsutoqcSf/aLlBTn1RAb XZOagUdC7E/VQz6YnquoLWV/D2+MlmKScQrKDqT3qjrQ/FH2KttbbUby/gUxS03P6e eTXw/oVMp4c8QrnBabSALBpCIxcbU0InjC4PTZRUrmhHAY9hHtdmAzBuLaWzmOjUHE 8BlFqmVmbRcTDFBm4f/kGBc4PdN2sVebVp74GBXYgxhi1cjwIdCi6vzsouqO8HONle 4hcGt+cwtSCcrjXVe19CN8J2Rrcqwn0bV1YUTPCnchrTq2zuqsCxrJh/nEIMFf0faX CPPrAxV66jDDw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E24F55C0AAE; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 09/18] selftests/nolibc: on x86, support exiting with isa-debug-exit Date: Wed, 31 Aug 2022 11:21:39 -0700 Message-Id: <20220831182148.2698489-11-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau QEMU, when started with "-device isa-debug-exit -no-reboot" will exit with status code 2N+1 when N is written to 0x501. This is particularly convenient for automated tests but this is not portable. As such we only enable this on x86_64 when pid=3D=3D1. In addition, this requires an ioperm() call but in order not to have to define arch-specific syscalls we just perform the syscall by hand there. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 291d96bfd7c12..eeb254749239c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -638,6 +638,15 @@ int main(int argc, char **argv, char **envp) printf("Leaving init with final status: %d\n", !!ret); if (ret =3D=3D 0) reboot(LINUX_REBOOT_CMD_POWER_OFF); +#if defined(__x86_64__) + /* QEMU started with "-device isa-debug-exit -no-reboot" will + * exit with status code 2N+1 when N is written to 0x501. We + * hard-code the syscall here as it's arch-dependent. + */ + else if (my_syscall3(__NR_ioperm, 0x501, 1, 1) =3D=3D 0) + asm volatile ("outb %%al, %%dx" :: "d"(0x501), "a"(0)); + /* if it does nothing, fall back to the regular panic */ +#endif } =20 printf("Exiting with status %d\n", !!ret); --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F02FECAAD1 for ; Wed, 31 Aug 2022 18:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232954AbiHaS0o (ORCPT ); Wed, 31 Aug 2022 14:26:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232861AbiHaSZj (ORCPT ); Wed, 31 Aug 2022 14:25:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ED9C6359 for ; Wed, 31 Aug 2022 11:21:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2F0AAB8227A for ; Wed, 31 Aug 2022 18:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 841E9C43149; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=lwk5wcOOPAaS02+SYW0iG5ev2+vHqTxry4RcwHjG3WQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cG+BIk0oG+YYu4lyAQxuAJiTMvF8FjfkNg76PXl3buiLU+G7o06r9XL7K5OF/+3Pm SMw6tpWHY4byJC03yVcl2S2u1Ai94LTgZDJk9a0VfJ1m6tcBN7bTBr0i0miCmj9paV my1p79uNcbT5IGNEpnx+U4uDjxD7KtHpTz9dQ5TEhDB0Xs0TpIXuF9FfWNya4g2t0R rgCPh01+ZNFINUXsY+1oiYqJnORcY0iLhgEHpd0xeRGO1M37wNI1080SOJzgpZNMyz wRqRPgnCby+ldXYPAJcz8nm/y61PRkr17EyTSbaD3M3WV+d6uc71ZiMI+mqbsVLtSt 1EAvF0YN0xxhw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E3FCD5C0B00; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 10/18] selftests/nolibc: recreate and populate /dev and /proc if missing Date: Wed, 31 Aug 2022 11:21:40 -0700 Message-Id: <20220831182148.2698489-12-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau Most of the time the program will be run alone in an initramfs. There is no value in requiring the user to populate /dev and /proc for such tests, we can do it ourselves, and it participates to the tests at the same time. What's done here is that when called as init (getpid()=3D=3D1) we check if /dev exists or create it, if /dev/console and /dev/null exists, otherwise we try to mount a devtmpfs there, and if it fails we fall back to mknod. The console is reopened if stdout was closed. Finally /proc is created and mounted if /proc/self cannot be found. This is sufficient for most tests. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index eeb254749239c..a697182c87f57 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -530,6 +530,54 @@ int run_stdlib(int min, int max) return ret; } =20 +/* prepare what needs to be prepared for pid 1 (stdio, /dev, /proc, etc) */ +int prepare(void) +{ + struct stat stat_buf; + + /* It's possible that /dev doesn't even exist or was not mounted, so + * we'll try to create it, mount it, or create minimal entries into it. + * We want at least /dev/null and /dev/console. + */ + if (stat("/dev/.", &stat_buf) =3D=3D 0 || mkdir("/dev", 0755) =3D=3D 0) { + if (stat("/dev/console", &stat_buf) !=3D 0 || + stat("/dev/null", &stat_buf) !=3D 0) { + /* try devtmpfs first, otherwise fall back to manual creation */ + if (mount("/dev", "/dev", "devtmpfs", 0, 0) !=3D 0) { + mknod("/dev/console", 0600 | S_IFCHR, makedev(5, 1)); + mknod("/dev/null", 0666 | S_IFCHR, makedev(1, 3)); + } + } + } + + /* If no /dev/console was found before calling init, stdio is closed so + * we need to reopen it from /dev/console. If it failed above, it will + * still fail here and we cannot emit a message anyway. + */ + if (close(dup(1)) =3D=3D -1) { + int fd =3D open("/dev/console", O_RDWR); + + if (fd >=3D 0) { + if (fd !=3D 0) + dup2(fd, 0); + if (fd !=3D 1) + dup2(fd, 1); + if (fd !=3D 2) + dup2(fd, 2); + if (fd > 2) + close(fd); + puts("\nSuccessfully reopened /dev/console."); + } + } + + /* try to mount /proc if not mounted. Silently fail otherwise */ + if (stat("/proc/.", &stat_buf) =3D=3D 0 || mkdir("/proc", 0755) =3D=3D 0)= { + if (stat("/proc/self", &stat_buf) !=3D 0) + mount("/proc", "/proc", "proc", 0, 0); + } + + return 0; +} =20 /* This is the definition of known test names, with their functions */ static struct test test_names[] =3D { @@ -550,6 +598,14 @@ int main(int argc, char **argv, char **envp) =20 environ =3D envp; =20 + /* when called as init, it's possible that no console was opened, for + * example if no /dev file system was provided. We'll check that fd#1 + * was opened, and if not we'll attempt to create and open /dev/console + * and /dev/null that we'll use for later tests. + */ + if (getpid() =3D=3D 1) + prepare(); + /* the definition of a series of tests comes from either argv[1] or the * "NOLIBC_TEST" environment variable. It's made of a comma-delimited * series of test names and optional ranges: --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A276ECAAD3 for ; Wed, 31 Aug 2022 18:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232919AbiHaS0X (ORCPT ); Wed, 31 Aug 2022 14:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232753AbiHaSZg (ORCPT ); Wed, 31 Aug 2022 14:25:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46299FB2AF for ; Wed, 31 Aug 2022 11:21:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 72AA161CDF for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8752FC43144; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=oWTBcWxwRcNwj5pYtUzATgnqSwPazE+3AJlhHkeS8Dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ClzmHyot5hQJaJf4f3olS2jN43V3At6jLwx8uaE0cAlsdnmJFMcDLLbxsKcCK3c7Y DHsITUky26rzvmKnwsSpYfT3X5aHTqXj7cKyc67nfc3cMU9HtpBpV9YyZVL70uAn9X hXGAl+gIyhs5wlXZXVWnlnU1CHTM95ZcTxAjzMA0twVUlwBWkqCs5ovFlWAyNLexBU SHEZD+XNxiWbLQssXULi8RmB3hGwsAsdaxkLgWskYX4OFl6txcdHEeddASC0958AHL bdKIymWpSR335KQ1LBmQmhgpJd2oby38bafAs5FVOTg8hjcNk0PKIcj8H2wIq0FdAT e3/9mb7fUqaAA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E5B8B5C0B07; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 11/18] selftests/nolibc: condition some tests on /proc existence Date: Wed, 31 Aug 2022 11:21:41 -0700 Message-Id: <20220831182148.2698489-13-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau If /proc is not available (program run inside a chroot or without sufficient permissions), it's better to disable the associated tests. Some will be preserved like the ones which check for a failure to create some entries there since they're still supposed to fail. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index a697182c87f57..662dea691749c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -413,11 +413,15 @@ int test_getdents64(const char *dir) int run_syscall(int min, int max) { struct stat stat_buf; + int proc; int test; int tmp; int ret =3D 0; void *p1, *p2; =20 + /* indicates whether or not /proc is mounted */ + proc =3D stat("/proc", &stat_buf) =3D=3D 0; + for (test =3D min; test >=3D 0 && test <=3D max; test++) { int llen =3D 0; // line length =20 @@ -438,12 +442,12 @@ int run_syscall(int min, int max) CASE_TEST(chdir_root); EXPECT_SYSZR(1, chdir("/")); break; CASE_TEST(chdir_dot); EXPECT_SYSZR(1, chdir(".")); break; CASE_TEST(chdir_blah); EXPECT_SYSER(1, chdir("/blah"), -1, ENOENT= ); break; - CASE_TEST(chmod_net); EXPECT_SYSZR(1, chmod("/proc/self/net", 05= 55)); break; - CASE_TEST(chmod_self); EXPECT_SYSER(1, chmod("/proc/self", 0555),= -1, EPERM); break; - CASE_TEST(chown_self); EXPECT_SYSER(1, chown("/proc/self", 0, 0),= -1, EPERM); break; + CASE_TEST(chmod_net); EXPECT_SYSZR(proc, chmod("/proc/self/net",= 0555)); break; + CASE_TEST(chmod_self); EXPECT_SYSER(proc, chmod("/proc/self", 055= 5), -1, EPERM); break; + CASE_TEST(chown_self); EXPECT_SYSER(proc, chown("/proc/self", 0, = 0), -1, EPERM); break; CASE_TEST(chroot_root); EXPECT_SYSZR(1, chroot("/")); break; CASE_TEST(chroot_blah); EXPECT_SYSER(1, chroot("/proc/self/blah"),= -1, ENOENT); break; - CASE_TEST(chroot_exe); EXPECT_SYSER(1, chroot("/proc/self/exe"), = -1, ENOTDIR); break; + CASE_TEST(chroot_exe); EXPECT_SYSER(proc, chroot("/proc/self/exe"= ), -1, ENOTDIR); break; CASE_TEST(close_m1); EXPECT_SYSER(1, close(-1), -1, EBADF); bre= ak; CASE_TEST(close_dup); EXPECT_SYSZR(1, close(dup(0))); break; CASE_TEST(dup_0); tmp =3D dup(0); EXPECT_SYSNE(1, tmp, -1);= close(tmp); break; @@ -464,7 +468,7 @@ int run_syscall(int min, int max) CASE_TEST(link_root1); EXPECT_SYSER(1, link("/", "/"), -1, EEXIST= ); break; CASE_TEST(link_blah); EXPECT_SYSER(1, link("/proc/self/blah", "/= blah"), -1, ENOENT); break; CASE_TEST(link_dir); EXPECT_SYSER(1, link("/", "/blah"), -1, EP= ERM); break; - CASE_TEST(link_cross); EXPECT_SYSER(1, link("/proc/self/net", "/b= lah"), -1, EXDEV); break; + CASE_TEST(link_cross); EXPECT_SYSER(proc, link("/proc/self/net", = "/blah"), -1, EXDEV); break; CASE_TEST(lseek_m1); EXPECT_SYSER(1, lseek(-1, 0, SEEK_SET), -1= , EBADF); break; CASE_TEST(lseek_0); EXPECT_SYSER(1, lseek(0, 0, SEEK_SET), -1,= ESPIPE); break; CASE_TEST(mkdir_root); EXPECT_SYSER(1, mkdir("/", 0755), -1, EEXI= ST); break; --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AEE6ECAAD1 for ; Wed, 31 Aug 2022 18:26:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232963AbiHaS0u (ORCPT ); Wed, 31 Aug 2022 14:26:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232740AbiHaSZm (ORCPT ); Wed, 31 Aug 2022 14:25:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE87FBA56 for ; Wed, 31 Aug 2022 11:21:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A2A3B61CE8 for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98829C43150; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=Aozz16IgN8xofEXnp7WD6afvGqRXQ72TKTm8qXa/snM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UEgb7Sbw+XginjhLeDEeNxbBp2JEgr4wWdYgLImEAweIEbVk8bKNSlc+RSMX9ilns ZuHhUkKubV6fyvr+0kC4CspPkMk/ozjY4C3s4ensT3hn3UpaCYeOJtoA+Ht0pf1u4t r+my3LRjClmIeLQI5VGeQfgXquy3M1ogkdOgV0ukr35cF7A10F7Tf7L2Zp9dpwlGPV Lkn53Bzuprnkp5vru1TaSh5kYCK6ABIRF8/fDblQV/uv5cNxYM4V4OdmuI4EbeUQAW MYiPVtYh6R9dVZq9Sg1xi8jN6sVpfjvSZowwKBz1Nq1a3ppZCRJmnJUCbvXR+8JJXE XopclT0kZFzLA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E77DC5C0B54; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 12/18] selftests/nolibc: support glibc as well Date: Wed, 31 Aug 2022 11:21:42 -0700 Message-Id: <20220831182148.2698489-14-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau Adding support for glibc can be useful to distinguish between bugs in nolibc and bugs in the kernel when a syscall reports an unusual value. It's not that much work and should not affect the long term maintainability of the tests. The necessary changes can essentially be summed up like this: - set _GNU_SOURCE a the top to access some definitions - many includes added when we know we don't come from nolibc (missing the stdio include guard) - disable gettid() which is not exposed by glibc - disable gettimeofday's support of bad pointers since these crash in glibc - add a simple itoa() for errorname(); strerror() is too verbose (no way to get short messages). strerrorname_np() was added in modern glibc (2.32) to do exactly this but that 's too recent to be usable as the default fallback. - use the standard ioperm() definition. May be we need to implement ioperm() in nolibc if that's useful. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 47 +++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 662dea691749c..78bced95ac630 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1,17 +1,41 @@ // SPDX-License-Identifier: GPL-2.0 =20 +#define _GNU_SOURCE + /* platform-specific include files coming from the compiler */ #include =20 /* libc-specific include files - * The program may be built in 2 ways: + * The program may be built in 3 ways: * $(CC) -nostdlib -include /path/to/nolibc.h =3D> NOLIBC already defined - * $(CC) -nostdlib -I/path/to/nolibc/sysroot + * $(CC) -nostdlib -I/path/to/nolibc/sysroot =3D> _NOLIBC_* guards are = present + * $(CC) with default libc =3D> NOLIBC* never defined */ #ifndef NOLIBC #include #include #include +#ifndef _NOLIBC_STDIO_H +/* standard libcs need more includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif #endif =20 /* will be used by nolibc by getenv() */ @@ -23,6 +47,17 @@ struct test { int (*func)(int min, int max); // handler }; =20 +#ifndef _NOLIBC_STDLIB_H +char *itoa(int i) +{ + static char buf[12]; + int ret; + + ret =3D snprintf(buf, sizeof(buf), "%d", i); + return (ret >=3D 0 && ret < sizeof(buf)) ? buf : "#err"; +} +#endif + #define CASE_ERR(err) \ case err: return #err =20 @@ -431,7 +466,9 @@ int run_syscall(int min, int max) switch (test + __LINE__ + 1) { CASE_TEST(getpid); EXPECT_SYSNE(1, getpid(), -1); break; CASE_TEST(getppid); EXPECT_SYSNE(1, getppid(), -1); break; +#ifdef NOLIBC CASE_TEST(gettid); EXPECT_SYSNE(1, gettid(), -1); break; +#endif CASE_TEST(getpgid_self); EXPECT_SYSNE(1, getpgid(0), -1); break; CASE_TEST(getpgid_bad); EXPECT_SYSER(1, getpgid(-1), -1, ESRCH); b= reak; CASE_TEST(kill_0); EXPECT_SYSZR(1, kill(getpid(), 0)); break; @@ -460,9 +497,11 @@ int run_syscall(int min, int max) 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(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL));= break; +#ifdef NOLIBC CASE_TEST(gettimeofday_bad1); EXPECT_SYSER(1, gettimeofday((void *)1, NU= LL), -1, EFAULT); break; CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *= )1), -1, EFAULT); break; CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *= )1), -1, EFAULT); break; +#endif CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); = break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); = break; CASE_TEST(link_root1); EXPECT_SYSER(1, link("/", "/"), -1, EEXIST= ); break; @@ -703,7 +742,11 @@ int main(int argc, char **argv, char **envp) * exit with status code 2N+1 when N is written to 0x501. We * hard-code the syscall here as it's arch-dependent. */ +#if defined(_NOLIBC_SYS_H) else if (my_syscall3(__NR_ioperm, 0x501, 1, 1) =3D=3D 0) +#else + else if (ioperm(0x501, 1, 1) =3D=3D 0) +#endif asm volatile ("outb %%al, %%dx" :: "d"(0x501), "a"(0)); /* if it does nothing, fall back to the regular panic */ #endif --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DD42ECAAD1 for ; Wed, 31 Aug 2022 18:27:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232680AbiHaS1C (ORCPT ); Wed, 31 Aug 2022 14:27:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232785AbiHaSZl (ORCPT ); Wed, 31 Aug 2022 14:25:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF83F2D55 for ; Wed, 31 Aug 2022 11:21:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9FA9C61CE7 for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9830BC4314F; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=2xQ5ecRyKfR7ptHCLyMP99aehKiar5JnTBnRAnso19o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s+q/JbhAYVX+CsSD2e5YBXtKSE8T/MmpXUOG78n9m2juOQohoMZ3bvWE+le5pPMbq xl4DX5AjyCW2YXcg6o8QaWBkoNMKiW7ejLALPrD6bPcnkpBh62aQRYKGqx5KGpwX0q 5JHqiubOx0U9bUrSVPo2OUxauLWT40HqThmgOS0f365wSZ69ACJM5depZke8jv3z+P 6GsFFpbJ5hLaQXtWOIyHBgwOisa4YmAacvnxKq0f9f7IwrtLEeiGM5U17NRHu/kbRg aqradmgQlJppWarSVjNcTM1cxI4a5Qe8dXxfb66W9QmljOSEBXUbAsC/HNXo6ii6Hy uaVSUsSJBLnOg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E93815C0DA6; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 13/18] selftests/nolibc: add a "kernel" target to build the kernel with the initramfs Date: Wed, 31 Aug 2022 11:21:43 -0700 Message-Id: <20220831182148.2698489-15-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau The "kernel" target rebuilds the kernel with the current config for the selected arch, with an initramfs containing the nolibc-test utility. Since image names depend on the architecture, the currently supported ones are referenced and resolved based on the architecture. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index fd0a670823340..4a2ab0e73ce2e 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -12,6 +12,16 @@ include $(srctree)/scripts/subarch.include ARCH =3D $(SUBARCH) endif =20 +# kernel image names by architecture +IMAGE_i386 =3D arch/x86/boot/bzImage +IMAGE_x86 =3D arch/x86/boot/bzImage +IMAGE_arm64 =3D arch/arm64/boot/Image +IMAGE_arm =3D arch/arm/boot/zImage +IMAGE_mips =3D vmlinuz +IMAGE_riscv =3D arch/riscv/boot/Image +IMAGE =3D $(IMAGE_$(ARCH)) +IMAGE_NAME =3D $(notdir $(IMAGE)) + # OUTPUT is only set when run from the main makefile, otherwise # it defaults to this nolibc directory. OUTPUT ?=3D $(CURDIR)/ @@ -36,6 +46,9 @@ initramfs: nolibc-test $(call QUIET_INSTALL, initramfs/init) $(Q)cp nolibc-test initramfs/init =20 +kernel: initramfs + $(Q)$(MAKE) -C $(srctree) ARCH=3D$(ARCH) CC=3D$(CC) CROSS_COMPILE=3D$(CRO= SS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=3D$(CURDIR)/initramfs + clean: $(call QUIET_CLEAN, nolibc-test) $(Q)rm -f nolibc-test --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81160ECAAD1 for ; Wed, 31 Aug 2022 18:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232970AbiHaS06 (ORCPT ); Wed, 31 Aug 2022 14:26:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232798AbiHaSZp (ORCPT ); Wed, 31 Aug 2022 14:25:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96BC6E9935 for ; Wed, 31 Aug 2022 11:21:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ADC8DB8227B for ; Wed, 31 Aug 2022 18:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC71FC43470; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=gnygS7VyDQKpNvDpWmORFPhy85HDq/0vqTL/ck01Zvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ah9tKkXq3vOEXguqAwL9NywK4DxyFHwX9Y9isgx/gbekxdaaxT1y8EjoIMBTS9x6O tRhG+mq4iFUbSuLrMU7mJWdRPrNLDlHJeSzpigFd1Kx0KHnX7+jR3np3iC23LqlXuw S3dbdP/by+W+QlooP/58luBseHeXe/pY0M+XPOUJmrd9NXi8aIKuEDypYfvsHMd/Li Z+zoUFUKZVd0UPcaZSWSWsLLkgFCoCasB837RCobOvjoMqj3YCrGsINIL/YbGi/S0a ivg+j87Bm9w5gGwq7GE1SI6bSLLvmLOLHB7Dv1higCQNuaP8Xw5qvl6np4jAKnwR/w 562c1H1plESFg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id EAEF85C0DE5; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 14/18] selftests/nolibc: add a "defconfig" target Date: Wed, 31 Aug 2022 11:21:44 -0700 Message-Id: <20220831182148.2698489-16-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau While most archs will work fine with "make defconfig", not all will do, and it's not always easy to remember the most suitable choice to use for a specific architecture. This adds a "defconfig" target to the Makefile so that one may easily run "make -C ... defconfig" and make sure to clean and rebuild a fresh config. This is *not* used by default because we want to preserve the user's config by default. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index 4a2ab0e73ce2e..c104719eae8b8 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -22,6 +22,15 @@ IMAGE_riscv =3D arch/riscv/boot/Image IMAGE =3D $(IMAGE_$(ARCH)) IMAGE_NAME =3D $(notdir $(IMAGE)) =20 +# default kernel configurations that appear to be usable +DEFCONFIG_i386 =3D defconfig +DEFCONFIG_x86 =3D defconfig +DEFCONFIG_arm64 =3D defconfig +DEFCONFIG_arm =3D multi_v7_defconfig +DEFCONFIG_mips =3D malta_defconfig +DEFCONFIG_riscv =3D defconfig +DEFCONFIG =3D $(DEFCONFIG_$(ARCH)) + # OUTPUT is only set when run from the main makefile, otherwise # it defaults to this nolibc directory. OUTPUT ?=3D $(CURDIR)/ @@ -46,6 +55,9 @@ initramfs: nolibc-test $(call QUIET_INSTALL, initramfs/init) $(Q)cp nolibc-test initramfs/init =20 +defconfig: + $(Q)$(MAKE) -C $(srctree) ARCH=3D$(ARCH) CC=3D$(CC) CROSS_COMPILE=3D$(CRO= SS_COMPILE) mrproper $(DEFCONFIG) prepare + kernel: initramfs $(Q)$(MAKE) -C $(srctree) ARCH=3D$(ARCH) CC=3D$(CC) CROSS_COMPILE=3D$(CRO= SS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=3D$(CURDIR)/initramfs =20 --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24861ECAAD3 for ; Wed, 31 Aug 2022 18:27:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232997AbiHaS1S (ORCPT ); Wed, 31 Aug 2022 14:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232807AbiHaSZq (ORCPT ); Wed, 31 Aug 2022 14:25:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26AF6F2433 for ; Wed, 31 Aug 2022 11:21:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B222CB82286 for ; Wed, 31 Aug 2022 18:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0BA0C43159; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=hXeiDn5SObJ18DT8fc6Pa6a9wr3LC/31YgOsnz8spKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=esKn2NT7MHuBE6iHrVUjMw3WR/bsaF9URjFUicPeI2JCHLi+3G/ZPIMYfMhYn8eVo aHYRw7eRLWDuAUyWyYu7liE9bG66/54Bv2A7CmsVSYRHaPoyaZFZ0rZ9NEZwGv+crE F+hd+eBu4PAjsWSBMIk4mtPlAedhyYpg7YKS1hxVNjQ7guOMYEJN/TwEjE4NbWz6k5 IyQ7horEW3nH6J8l99xrEBygytnoZf8+DBf3rmTTfU3z9nsUsCNG7Oelfx/NlOufhs 5g2Gg6aC1NKC94bBwbX2O1moSTUOdA+m2rb2qLnwTpNCaFYhp7wdqOIGfZfabFiWPo S0zMUnTb0caPw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id ECCF15C0DF4; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 15/18] selftests/nolibc: add a "run" target to start the kernel in QEMU Date: Wed, 31 Aug 2022 11:21:45 -0700 Message-Id: <20220831182148.2698489-17-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau The "run" target will build the kernel and start it in QEMU. The "rerun" target will not have the kernel dependency and will just try to start QEMU. The QEMU architecture used to start the kernel is derived from the configured ARCH. This might need to be improved for archs which include different variants under the same name (mips vs mipsel, +/-64, riscv32 vs riscv64). This could be tested for i386, x86, arm, arm64, mips and riscv (the later two reporting issues on some tests). It is possible to pass a test specification for nolibc-test in the TEST variable, which will be passed as-is as NOLIBC_TEST. On success, the number of successful tests is printed. On failure, failed lines are individually printed. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index c104719eae8b8..7c1f5360f454e 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -31,6 +31,27 @@ DEFCONFIG_mips =3D malta_defconfig DEFCONFIG_riscv =3D defconfig DEFCONFIG =3D $(DEFCONFIG_$(ARCH)) =20 +# optional tests to run (default =3D all) +TEST =3D + +# QEMU_ARCH: arch names used by qemu +QEMU_ARCH_i386 =3D i386 +QEMU_ARCH_x86 =3D x86_64 +QEMU_ARCH_arm64 =3D aarch64 +QEMU_ARCH_arm =3D arm +QEMU_ARCH_mips =3D mipsel # works with malta_defconfig +QEMU_ARCH_riscv =3D riscv64 +QEMU_ARCH =3D $(QEMU_ARCH_$(ARCH)) + +# QEMU_ARGS : some arch-specific args to pass to qemu +QEMU_ARGS_i386 =3D -M pc -append "console=3DttyS0,9600 i8042.noaux pani= c=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_x86 =3D -M pc -append "console=3DttyS0,9600 i8042.noaux pani= c=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_arm64 =3D -M virt -cpu cortex-a53 -append "panic=3D-1 $(TEST:%= =3DNOLIBC_TEST=3D%)" +QEMU_ARGS_arm =3D -M virt -append "panic=3D-1 $(TEST:%=3DNOLIBC_TEST= =3D%)" +QEMU_ARGS_mips =3D -M malta -append "panic=3D-1 $(TEST:%=3DNOLIBC_TEST= =3D%)" +QEMU_ARGS_riscv =3D -M virt -append "console=3DttyS0 panic=3D-1 $(TEST:%= =3DNOLIBC_TEST=3D%)" +QEMU_ARGS =3D $(QEMU_ARGS_$(ARCH)) + # OUTPUT is only set when run from the main makefile, otherwise # it defaults to this nolibc directory. OUTPUT ?=3D $(CURDIR)/ @@ -61,8 +82,20 @@ defconfig: kernel: initramfs $(Q)$(MAKE) -C $(srctree) ARCH=3D$(ARCH) CC=3D$(CC) CROSS_COMPILE=3D$(CRO= SS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=3D$(CURDIR)/initramfs =20 +# run the tests after building the kernel +run: kernel + $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)= /$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" + $(Q)grep -w FAIL "$(CURDIR)/run.out" && echo "See all results in $(CURDIR= )/run.out" || echo "$$(grep -c ^[0-9].*OK $(CURDIR)/run.out) test(s) passed= ." + +# re-run the tests from an existing kernel +rerun: + $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)= /$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" + $(Q)grep -w FAIL "$(CURDIR)/run.out" && echo "See all results in $(CURDIR= )/run.out" || echo "$$(grep -c ^[0-9].*OK $(CURDIR)/run.out) test(s) passed= ." + clean: $(call QUIET_CLEAN, nolibc-test) $(Q)rm -f nolibc-test $(call QUIET_CLEAN, initramfs) $(Q)rm -rf initramfs + $(call QUIET_CLEAN, run.out) + $(Q)rm -rf run.out --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6EDDECAAD3 for ; Wed, 31 Aug 2022 18:27:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232891AbiHaS1P (ORCPT ); Wed, 31 Aug 2022 14:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232804AbiHaSZp (ORCPT ); Wed, 31 Aug 2022 14:25:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96EF8F2432 for ; Wed, 31 Aug 2022 11:21:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CA3ED61CEF for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1489C433D6; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=CU73QDisjs/PRWOCwR+T0+q/eTYkk9fwbgXWId7CwWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tJy2tq89mR9IEZe4QbPiaq4VvQd3El7aXE3ZTo3k1+dysYtdAIum9IC4SxUqBpIqk OqXiCDCM4wZPy6cNRhEKBR2pL4odJdqww8giyHt4ujJkEFsyRVDcuGMI231R352BI0 lJA2XFbROC1NtwEvbOEMaOte2DqxSB69oKAiuuK3R5c4HGAJlMV9NOGLdDcLYHktsQ ZSfQ7ZRerfcM0eFUsj8O7zdrOj0FDYnMkAAuG8MM9xoBUgJ6knZpOsYB9oBHi3eSHW TPXuZ8PjUKwUBHaJsAP84tofhNHNnwtaicL1ryWD/YLhbbxQYCHnkNnmhVtFPx4Rt5 tgLBg3NGnr0TQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id EE91F5C0E4D; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 16/18] selftests/nolibc: "sysroot" target installs a local copy of the sysroot Date: Wed, 31 Aug 2022 11:21:46 -0700 Message-Id: <20220831182148.2698489-18-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau It's not convenient to rely on a sysroot built in another directory, especially when running cross-compilation tests, where one has to switch back and forth between directories. Let's make it possible to install the sysroot directly in the test directory. It's not big and even benefits from being copied by arch so that it's easier to switch between archs if needed. The new "sysroot" target does this, it just calls "headers_standalone" from nolibc to install the sysroot right here. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index 7c1f5360f454e..210f5369fdfc4 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -67,9 +67,16 @@ LDFLAGS :=3D -s =20 all: nolibc-test =20 -nolibc-test: nolibc-test.c +sysroot: sysroot/$(ARCH)/include + +sysroot/$(ARCH)/include: + $(QUIET_MKDIR)mkdir -p sysroot + $(Q)$(MAKE) -C ../../../include/nolibc ARCH=3D$(ARCH) OUTPUT=3D$(CURDIR)/= sysroot/ headers_standalone + $(Q)mv sysroot/sysroot sysroot/$(ARCH) + +nolibc-test: nolibc-test.c sysroot/$(ARCH)/include $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ - -nostdlib -static -include ../../../include/nolibc/nolibc.h $^ -lgcc + -nostdlib -static -Isysroot/$(ARCH)/include $< -lgcc =20 initramfs: nolibc-test $(QUIET_MKDIR)mkdir -p initramfs @@ -93,6 +100,8 @@ rerun: $(Q)grep -w FAIL "$(CURDIR)/run.out" && echo "See all results in $(CURDIR= )/run.out" || echo "$$(grep -c ^[0-9].*OK $(CURDIR)/run.out) test(s) passed= ." =20 clean: + $(call QUIET_CLEAN, sysroot) + $(Q)rm -rf sysroot $(call QUIET_CLEAN, nolibc-test) $(Q)rm -f nolibc-test $(call QUIET_CLEAN, initramfs) --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9464EECAAD3 for ; Wed, 31 Aug 2022 18:27:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232979AbiHaS1H (ORCPT ); Wed, 31 Aug 2022 14:27:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232799AbiHaSZp (ORCPT ); Wed, 31 Aug 2022 14:25:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96C7BEE68C for ; Wed, 31 Aug 2022 11:21:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C52F261CEE for ; Wed, 31 Aug 2022 18:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0BF3C4315A; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=hpw3dacwnLzPWl5y8Cq3vm7W0XF8HCMlGL9rQUzjRhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XwG15xQ84Pqok3dWN53SvRS0c71ccK6xdN94X/s2EA9txx3fA5/W7v7pN8PJH3aAp 1jqCLk313zaNhCtJ5i5jUc4jB6AyWc51fLis87H4MplTHfBYxUrOqx5UQN3IfRfBBa 2yzxgPHU4oLYatGUzpsQ9HYmeItCN/Q327hjKX2ZlgNLHYjSlVFLmkn0grHGc8Vhdh vIWB5TGlrPLOrEw98BxzKHcyBZrt3jvPigYqYgCcG8lhUCspnmZJERmvBCeUYLc8n2 4/PSAhnzqe3Bh3+BWBRjIqS4NvXD/YXEzyA7gNJn+GOaO0MHAcDF+2Pwd7JRtOokIU BLfpC2Bs7+8mw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id F046B5C0E68; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 17/18] selftests/nolibc: add a "help" target Date: Wed, 31 Aug 2022 11:21:47 -0700 Message-Id: <20220831182148.2698489-19-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau It presents the supported targets, and becomes the default target to save the user from having to read the makefile. The "all" target was placed after it and now points to "run" to do everything since it's no longer the default one. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index 210f5369fdfc4..69ea659caca98 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -65,7 +65,32 @@ endif CFLAGS ?=3D -Os -fno-ident -fno-asynchronous-unwind-tables LDFLAGS :=3D -s =20 -all: nolibc-test +help: + @echo "Supported targets under selftests/nolibc:" + @echo " all call the \"run\" target below" + @echo " help this help" + @echo " sysroot create the nolibc sysroot here (uses \$$ARCH)" + @echo " nolibc-test build the executable (uses \$$CC and \$$CROSS_COMPI= LE)" + @echo " initramfs prepare the initramfs with nolibc-test" + @echo " defconfig create a fresh new default config (uses \$$ARCH)" + @echo " kernel (re)build the kernel with the initramfs (uses \$$AR= CH)" + @echo " run runs the kernel in QEMU after building it (uses \$$= ARCH, \$$TEST)" + @echo " rerun runs a previously prebuilt kernel in QEMU (uses \$$= ARCH, \$$TEST)" + @echo " clean clean the sysroot, initramfs, build and output file= s" + @echo "" + @echo "The output file is \"run.out\". Test ranges may be passed using \$= $TEST." + @echo "" + @echo "Currently using the following variables:" + @echo " ARCH =3D $(ARCH)" + @echo " CROSS_COMPILE =3D $(CROSS_COMPILE)" + @echo " CC =3D $(CC)" + @echo " OUTPUT =3D $(OUTPUT)" + @echo " TEST =3D $(TEST)" + @echo " QEMU_ARCH =3D $(if $(QEMU_ARCH),$(QEMU_ARCH),UNKNOWN_ARCH) [= determined from \$$ARCH]" + @echo " IMAGE_NAME =3D $(if $(IMAGE_NAME),$(IMAGE_NAME),UNKNOWN_ARCH)= [determined from \$$ARCH]" + @echo "" + +all: run =20 sysroot: sysroot/$(ARCH)/include =20 --=20 2.31.1.189.g2e36527f23 From nobody Tue Apr 7 00:49:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24ED9ECAAD1 for ; Wed, 31 Aug 2022 18:27:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232573AbiHaS1X (ORCPT ); Wed, 31 Aug 2022 14:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232812AbiHaSZr (ORCPT ); Wed, 31 Aug 2022 14:25:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AAEDF325E for ; Wed, 31 Aug 2022 11:21:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D96EFB82289 for ; Wed, 31 Aug 2022 18:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9E2FC4315B; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=kvIGUGvWGjbnatoeWWWTTFZH4v3qpwz0HmIzMW+k0bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dMco6OtjNymKmvXqe4YO3uA2mhCo1vVXYbahavRhIjVb+2ZDbdtsG2T/x+3G3rDoi S1aoqaqmRwvSOps2WbWSv1x0kVu+RxCryZS5HbCadxXXpNjom4zqU39BI/HTjTAHzT GbkqpBy1iRqYLI6Eg7+vw+Kv279nEeTvWEHfmYjNXCP0t71SKO3zKRtxF5UkwSJaCn EPk19OwY3aq7DBmig38IOwtbagy/h30wicniiChKPtKRe/sY98Ur2KrJ9s6szrrsOf De4qUP8TOBkUnLXbW3dvPUs4XZj4aOMM37ynYvsJNbEjWX880Qhog3HqJDWiKariR4 PWSdRux+59RBg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id F24275C0EAC; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Fernanda Ma'rouf , Ammar Faizi , Fernanda Ma'rouf , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 18/18] selftests/nolibc: Avoid generated files being committed Date: Wed, 31 Aug 2022 11:21:48 -0700 Message-Id: <20220831182148.2698489-20-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Fernanda Ma'rouf After running the nolibc tests, the "git status" is not clean because the generated files are not ignored. Create a `.gitignore` inside the selftests/nolibc directory to ignore them. Cc: Ammar Faizi Cc: Fernanda Ma'rouf Signed-off-by: Fernanda Ma'rouf Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tools/testing/selftests/nolibc/.gitignore diff --git a/tools/testing/selftests/nolibc/.gitignore b/tools/testing/self= tests/nolibc/.gitignore new file mode 100644 index 0000000000000..4696df589d68e --- /dev/null +++ b/tools/testing/selftests/nolibc/.gitignore @@ -0,0 +1,4 @@ +/initramfs/ +/nolibc-test +/run.out +/sysroot/ --=20 2.31.1.189.g2e36527f23