Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3877051rwb; Sat, 21 Jan 2023 01:52:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXsNEs4g0JZ11M84SfoiHrriNyfZhzSXknub74bmY7mE2w9wvcdU37NGowWMj2735qRZ2Jk0 X-Received: by 2002:a17:907:629c:b0:86e:9345:e701 with SMTP id nd28-20020a170907629c00b0086e9345e701mr25463581ejc.2.1674294776751; Sat, 21 Jan 2023 01:52:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674294776; cv=none; d=google.com; s=arc-20160816; b=NP/+C2MrR8QX5lRCkVTpybJkCby8ev5oTvO6vn/feqbQNWHGdhaTDAdiRrqMBUcbtu 52Y6D1LqNEXgIdQO9M5kOQRbWKF86EuWf9313LfnKV7fT0Q/118K3fz6mF2bv04rUaZ/ BYjQpFmsY5UGSNw1uDZs1p5paybOIFBThLkKt64W+A4vHMyzwD0LsCyjPpQmTb4gY96Q 37smhFnmQFZawKWuxuWA8G3vRphiCu1N75sAxQJ7kNsPW37L7IYGjzNghKD2QFHslwyq G+s147gElzbehq1V0yRma4uETGNB64A/XVZzvr/oP8KF2YYOVuLC23KHLIVFdcy5gpsL h6eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=9pQLsAJZQQBT3Z0Au6MCEtmRz40S1THSeTHjX/j5spA=; b=eyJdmk0xVdLt9fLjB9VRFDAOJdwAIGrqHPOA/FQK1CnP8CU9ARSnd8qoXa9DAJjF43 v5sm9s6nF+eQ4o7+9pNtflDDa0NugMRCvlqWBWdAVn5xjXPjeBu9PHG2TqEeBUvXRQ4Z iujOIu453ePWUxCZcwvubxnvu/8uhroQ8Lr7ynMHZ6NPUs5vrcFZ0tMtIsKkSPd2Qdy4 lluyeak+aXm0p/hZfwmj4HSWxPU6szpwHFrXKatTLY8uXVNLBSHD+Cn0mnQRrm6CxnYb KEBf728wDPwioA3tzmkalsFESofQIHvxYB7OVmkR7x+NLcs96gIf7pV4NMgteXWVQgvH 5hig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xj4-20020a170906db0400b0084c6c09e713si49743298ejb.464.2023.01.21.01.52.44; Sat, 21 Jan 2023 01:52:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229762AbjAUIyQ (ORCPT + 50 others); Sat, 21 Jan 2023 03:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbjAUIyI (ORCPT ); Sat, 21 Jan 2023 03:54:08 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BCD616E0E2; Sat, 21 Jan 2023 00:54:06 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 30L8rhCt011766; Sat, 21 Jan 2023 09:53:43 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Shuah Khan , linux-kselftest@vger.kernel.org, Ammar Faizi , Willy Tarreau Subject: [PATCH 2/2] selftests/nolibc: add a "run-user" target to test the program in user land Date: Sat, 21 Jan 2023 09:53:20 +0100 Message-Id: <20230121085320.11712-3-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230121085320.11712-1-w@1wt.eu> References: <20230121085320.11712-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I found that when developing tests I'm not that often building kernels, and instead I'm often using the much quicker QEMU Linux emulator instead of the system emulator. It is sufficient to test startup code, stdlib code and syscall calling convention. As such it is expected that other users will value this, so let's add a "run-user" target that immediately executes the prebuilt executable with the user's privilege (thus some tests may fail due to insufficient permissions or missing features in the local kernel). Now running a userland test is as simple as issuing: make ARCH=xxx CROSS_COMPILE=xxx run-user Signed-off-by: Willy Tarreau --- tools/testing/selftests/nolibc/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 423598045ff1..8fe61d3e3cce 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -80,6 +80,7 @@ help: @echo " help this help" @echo " sysroot create the nolibc sysroot here (uses \$$ARCH)" @echo " nolibc-test build the executable (uses \$$CC and \$$CROSS_COMPILE)" + @echo " run-user runs the executable under QEMU (uses \$$ARCH, \$$TEST)" @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 \$$ARCH)" @@ -113,6 +114,11 @@ nolibc-test: nolibc-test.c sysroot/$(ARCH)/include $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ -nostdlib -static -Isysroot/$(ARCH)/include $< -lgcc +# qemu user-land test +run-user: nolibc-test + $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(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." + initramfs: nolibc-test $(QUIET_MKDIR)mkdir -p initramfs $(call QUIET_INSTALL, initramfs/init) -- 2.17.5