From patchwork Sat Jan 21 08:53:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 645263 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 BE679C004D4 for ; Sat, 21 Jan 2023 08:54:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbjAUIyB (ORCPT ); Sat, 21 Jan 2023 03:54:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjAUIyA (ORCPT ); Sat, 21 Jan 2023 03:54:00 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0FF1B65F17; Sat, 21 Jan 2023 00:53:59 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 30L8rhrs011765; 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 1/2] selftests/nolibc: support "x86_64" for arch name Date: Sat, 21 Jan 2023 09:53:19 +0100 Message-Id: <20230121085320.11712-2-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> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Building the kernel with ARCH=x86_64 is perfectly supported, but the nolibc-test only supports "x86", which causes errors when reusing existing build environment. Let's permit it to be used as well. Signed-off-by: Willy Tarreau --- tools/testing/selftests/nolibc/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 2bf613ee363d..423598045ff1 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -14,6 +14,7 @@ endif # kernel image names by architecture IMAGE_i386 = arch/x86/boot/bzImage +IMAGE_x86_64 = arch/x86/boot/bzImage IMAGE_x86 = arch/x86/boot/bzImage IMAGE_arm64 = arch/arm64/boot/Image IMAGE_arm = arch/arm/boot/zImage @@ -25,6 +26,7 @@ IMAGE_NAME = $(notdir $(IMAGE)) # default kernel configurations that appear to be usable DEFCONFIG_i386 = defconfig +DEFCONFIG_x86_64 = defconfig DEFCONFIG_x86 = defconfig DEFCONFIG_arm64 = defconfig DEFCONFIG_arm = multi_v7_defconfig @@ -38,6 +40,7 @@ TEST = # QEMU_ARCH: arch names used by qemu QEMU_ARCH_i386 = i386 +QEMU_ARCH_x86_64 = x86_64 QEMU_ARCH_x86 = x86_64 QEMU_ARCH_arm64 = aarch64 QEMU_ARCH_arm = arm @@ -48,6 +51,7 @@ QEMU_ARCH = $(QEMU_ARCH_$(ARCH)) # QEMU_ARGS : some arch-specific args to pass to qemu QEMU_ARGS_i386 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" +QEMU_ARGS_x86_64 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_x86 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_arm64 = -M virt -cpu cortex-a53 -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_arm = -M virt -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" From patchwork Sat Jan 21 08:53:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 645262 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 1AB0FC004D4 for ; Sat, 21 Jan 2023 08:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbjAUIyO (ORCPT ); Sat, 21 Jan 2023 03:54:14 -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> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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)