Message ID | 291c5437db94057a3b045a6f036b02658380b05b.1685936428.git.falcon@tinylab.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2443518vqr; Sun, 4 Jun 2023 21:14:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5/Dz5nWUgI/iNQanCIoxbeqRwYTVjhOkyUWBZL1Z3YUhP1kBMjrO9FBoTp6ATHQHqmXv4k X-Received: by 2002:a17:90a:5604:b0:256:3191:640f with SMTP id r4-20020a17090a560400b002563191640fmr7061035pjf.4.1685938475641; Sun, 04 Jun 2023 21:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685938475; cv=none; d=google.com; s=arc-20160816; b=llo7wb1tAGYBtyPR6YOXz+/UwiCXrxP7Ze+aM9aIHNLxZ2U2hS0FDIXN8Rp6PcGAiY uFzO7PhbWKOmgeMRhbmssQCebqHR0CYFmKYfLMVMoiath8z9tdFBIZACIJGIfxHUSdBq oco88Y1aHSOjTL50y4Q2BPaNoEyUxKfFlsdJFxVfMFWF2bTlzL+6m+vQPUGuENj3IlA3 PxSOV/kleS2riaY9KyToC6/Q2cmI5hG2fAI8+EIYH0vXTd6NvKyhBGsGvAuzqdf2ykLI z/C0YPI3lz5rFrVRfN1lu72yvzWORoAylbN/0ji0MFnyj3N0w+/wBN5RxFm2WNPKcdq3 Unkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=e8jM4YxXphtsv1nitRIyzj7w2moZ7COA1YZvbnjfPbQ=; b=wkqTbIBrQ1rlaUjDpu9KeLAhlFY5+xRtGMghtIau9P2RHVyTJZHc8ANwbL46DZ3FKg tS5UsCGWF8uJFdl4WD3AO2YWqHlqiTvvkEaQcL/11Qi77kMiB59TpWX7iK3YBfu1Q7Ir FJLGEOJPZXU/ODaRvsMM2jM+WH9UWOxTBsuBPMR8xilxhXjRpBRWE+NOnZbV98KdqeNm WCzN6lXpwFFsQz+X6tg6WE9BBM68KUqbKwFq0orIa/MJ1eXvpvYM8Q6paPdXYxjehrDl l40p4BWsrXcTz6oGdFgoAdqHey0YSTUjy8BU17PfvCrxeemZDDlIRbf3jI+V7F95sWbi 9zug== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a656a8f000000b0052c2b1efee2si5015510pgu.339.2023.06.04.21.14.22; Sun, 04 Jun 2023 21:14:35 -0700 (PDT) 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 S232799AbjFEDtL (ORCPT <rfc822;pfffrao@gmail.com> + 99 others); Sun, 4 Jun 2023 23:49:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbjFEDtJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 4 Jun 2023 23:49:09 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E1FB8; Sun, 4 Jun 2023 20:49:06 -0700 (PDT) X-QQ-mid: bizesmtp81t1685936936tm3qiisk Received: from linux-lab-host.localdomain ( [61.141.77.49]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 05 Jun 2023 11:48:55 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: PS/N6jJLnDbUhcG1tckp2UkFkb6Y4PEy7Kf4nOh/3d2cGqfkeUq0q6+sKvs5r 4d/2AhXp1+1Ke3XxAEpTe4xrbrIDxn6kk4nhbiHJNnZVr+RNd9/wfD9i5Gg/NvF44ptXKAf M7/nom8UB9c7Sel4L85G5RjmPuXwka10IPIQeZ37y7u2Hfk3Fk8yZIkoCkz89r30XOFk/fQ CboWKF/ON91qEsDHmEaJpy/YHJKw9vefCoivanIsUcYrZLxS/VnW/4VO3ap36W8i7vIuPGu FB4ZLSuv3PsjBuf8cs71QZ8o+IgsJDPqeRbQcHEy7NqFxHl7oEiwZosr8XuNoHHE3ODeXFC p/s1Jq3A6+bNSgZAzUcm+k/W2k64vxSIgijB2BtMEaXGClTr/tVw2Vy2qGk5A== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17656311057048569074 From: Zhangjin Wu <falcon@tinylab.org> To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH 1/4] selftests/nolibc: add a test-report target Date: Mon, 5 Jun 2023 11:48:52 +0800 Message-Id: <291c5437db94057a3b045a6f036b02658380b05b.1685936428.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <cover.1685936428.git.falcon@tinylab.org> References: <cover.1685936428.git.falcon@tinylab.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767834623192249049?= X-GMAIL-MSGID: =?utf-8?q?1767834623192249049?= |
Series | selftests/nolibc: fix up and improve test report | |
Commit Message
Zhangjin Wu
June 5, 2023, 3:48 a.m. UTC
A standalone test-report target is added to let the run, run-user and
rerun targets share them.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
tools/testing/selftests/nolibc/Makefile | 26 ++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
Comments
On Mon, Jun 05, 2023 at 11:48:52AM +0800, Zhangjin Wu wrote: > A standalone test-report target is added to let the run, run-user and > rerun targets share them. > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > --- > tools/testing/selftests/nolibc/Makefile | 26 ++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile > index be4159837494..8149ace2938a 100644 > --- a/tools/testing/selftests/nolibc/Makefile > +++ b/tools/testing/selftests/nolibc/Makefile > @@ -127,14 +127,18 @@ nolibc-test: nolibc-test.c sysroot/$(ARCH)/include > libc-test: nolibc-test.c > $(QUIET_CC)$(CC) -o $@ $< > > -# qemu user-land test > -run-user: nolibc-test > - $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > +test-report: > $(Q)awk '/\[OK\]$$/{p++} /\[FAIL\]$$/{f++} /\[SKIPPED\]$$/{s++} \ > END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ > if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ > $(CURDIR)/run.out > > +# qemu user-land test > +_run-user: nolibc-test > + $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > + > +run-user: _run-user test-report > + This will not reliably work, there's no ordering here, nothing guarantees that test-report will run *after* _run-user (e.g. make -j). Another approach is needed if you want to factor this, but in general creating sequences in makefiles is difficult and often more painful than having 3 times the same 3 lines. Willy
> On Mon, Jun 05, 2023 at 11:48:52AM +0800, Zhangjin Wu wrote: > > A standalone test-report target is added to let the run, run-user and > > rerun targets share them. > > > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > > --- > > tools/testing/selftests/nolibc/Makefile | 26 ++++++++++++------------- > > 1 file changed, 13 insertions(+), 13 deletions(-) > > > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile > > index be4159837494..8149ace2938a 100644 > > --- a/tools/testing/selftests/nolibc/Makefile > > +++ b/tools/testing/selftests/nolibc/Makefile > > @@ -127,14 +127,18 @@ nolibc-test: nolibc-test.c sysroot/$(ARCH)/include > > libc-test: nolibc-test.c > > $(QUIET_CC)$(CC) -o $@ $< > > > > -# qemu user-land test > > -run-user: nolibc-test > > - $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > > +test-report: > > $(Q)awk '/\[OK\]$$/{p++} /\[FAIL\]$$/{f++} /\[SKIPPED\]$$/{s++} \ > > END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ > > if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ > > $(CURDIR)/run.out > > > > +# qemu user-land test > > +_run-user: nolibc-test > > + $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > > + > > +run-user: _run-user test-report > > + > > This will not reliably work, there's no ordering here, nothing guarantees > that test-report will run *after* _run-user (e.g. make -j). Another > approach is needed if you want to factor this, but in general creating > sequences in makefiles is difficult and often more painful than having > 3 times the same 3 lines. > Ok, thanks, what about this? # LOG_REPORT: report the test results LOG_REPORT := awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{f++} /\[SKIPPED\][\r]*$$/{s++} \ END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ printf(" See all results in %s\n", ARGV[1]); }' run-user: nolibc-test $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : $(Q)$(LOG_REPORT) $(CURDIR)/run.out run: kernel $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" $(Q)$(LOG_REPORT) $(CURDIR)/run.out rerun: $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" $(Q)$(LOG_REPORT) $(CURDIR)/run.out Or we directly add a standalone test report script? something like tools/testing/selftests/nolibc/report.sh #!/bin/sh # # report.sh -- report the test results of nolibc-test # LOG_FILE=$1 [ ! -f "$LOG_FILE" ] && echo "Usage: $0 /path/to/run.out" awk ' /\[OK\][\r]*$$/{ p++ } /\[FAIL\][\r]*$$/{ f++ } /\[SKIPPED\][\r]*$$/{ s++ } END { printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); printf(" See all results in %s\n", ARGV[1]); }' $LOG_FILE And use it like this: LOG_REPORT = $(CURDIR)/report.sh Best regards, Zhangjin > Willy
Hi, Willy > > On Mon, Jun 05, 2023 at 11:48:52AM +0800, Zhangjin Wu wrote: > > > A standalone test-report target is added to let the run, run-user and > > > rerun targets share them. > > > > > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > > > --- > > > tools/testing/selftests/nolibc/Makefile | 26 ++++++++++++------------- > > > 1 file changed, 13 insertions(+), 13 deletions(-) > > > > > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile > > > index be4159837494..8149ace2938a 100644 > > > --- a/tools/testing/selftests/nolibc/Makefile > > > +++ b/tools/testing/selftests/nolibc/Makefile > > > @@ -127,14 +127,18 @@ nolibc-test: nolibc-test.c sysroot/$(ARCH)/include > > > libc-test: nolibc-test.c > > > $(QUIET_CC)$(CC) -o $@ $< > > > > > > -# qemu user-land test > > > -run-user: nolibc-test > > > - $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > > > +test-report: > > > $(Q)awk '/\[OK\]$$/{p++} /\[FAIL\]$$/{f++} /\[SKIPPED\]$$/{s++} \ > > > END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ > > > if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ > > > $(CURDIR)/run.out > > > > > > +# qemu user-land test > > > +_run-user: nolibc-test > > > + $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > > > + > > > +run-user: _run-user test-report > > > + > > > > This will not reliably work, there's no ordering here, nothing guarantees > > that test-report will run *after* _run-user (e.g. make -j). Another > > approach is needed if you want to factor this, but in general creating > > sequences in makefiles is difficult and often more painful than having > > 3 times the same 3 lines. > > > > Ok, thanks, what about this? > > # LOG_REPORT: report the test results > LOG_REPORT := awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{f++} /\[SKIPPED\][\r]*$$/{s++} \ > END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ > printf(" See all results in %s\n", ARGV[1]); }' > > run-user: nolibc-test > $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > $(Q)$(LOG_REPORT) $(CURDIR)/run.out > > run: kernel > $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" > $(Q)$(LOG_REPORT) $(CURDIR)/run.out > > rerun: > $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" > $(Q)$(LOG_REPORT) $(CURDIR)/run.out > > Or we directly add a standalone test report script? something like > tools/testing/selftests/nolibc/report.sh > > #!/bin/sh > # > # report.sh -- report the test results of nolibc-test > # > > LOG_FILE=$1 > [ ! -f "$LOG_FILE" ] && echo "Usage: $0 /path/to/run.out" > > awk ' > /\[OK\][\r]*$$/{ p++ } > /\[FAIL\][\r]*$$/{ f++ } > /\[SKIPPED\][\r]*$$/{ s++ } > > END { > printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); > printf(" See all results in %s\n", ARGV[1]); > }' $LOG_FILE > > And use it like this: > > LOG_REPORT = $(CURDIR)/report.sh > I plan to renew this patchset, which one of the above methods do you prefer? For the always print statement: printf(" See all results in %s\n", ARGV[1]); }' I will paste the reason why I need it, as mentioned in [1], if you still need a clean test report, I will give up this change ;-) Thanks, Zhangjin --- [1]: https://lore.kernel.org/linux-riscv/20230605070508.153407-1-falcon@tinylab.org/ > Best regards, > Zhangjin > > > Willy
Hi Zhangjin, On Wed, Jun 07, 2023 at 01:52:00PM +0800, Zhangjin Wu wrote: > Hi, Willy > > > > On Mon, Jun 05, 2023 at 11:48:52AM +0800, Zhangjin Wu wrote: > > > > A standalone test-report target is added to let the run, run-user and > > > > rerun targets share them. > > > > > > > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > > > > --- > > > > tools/testing/selftests/nolibc/Makefile | 26 ++++++++++++------------- > > > > 1 file changed, 13 insertions(+), 13 deletions(-) > > > > > > > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile > > > > index be4159837494..8149ace2938a 100644 > > > > --- a/tools/testing/selftests/nolibc/Makefile > > > > +++ b/tools/testing/selftests/nolibc/Makefile > > > > @@ -127,14 +127,18 @@ nolibc-test: nolibc-test.c sysroot/$(ARCH)/include > > > > libc-test: nolibc-test.c > > > > $(QUIET_CC)$(CC) -o $@ $< > > > > > > > > -# qemu user-land test > > > > -run-user: nolibc-test > > > > - $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > > > > +test-report: > > > > $(Q)awk '/\[OK\]$$/{p++} /\[FAIL\]$$/{f++} /\[SKIPPED\]$$/{s++} \ > > > > END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ > > > > if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ > > > > $(CURDIR)/run.out > > > > > > > > +# qemu user-land test > > > > +_run-user: nolibc-test > > > > + $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > > > > + > > > > +run-user: _run-user test-report > > > > + > > > > > > This will not reliably work, there's no ordering here, nothing guarantees > > > that test-report will run *after* _run-user (e.g. make -j). Another > > > approach is needed if you want to factor this, but in general creating > > > sequences in makefiles is difficult and often more painful than having > > > 3 times the same 3 lines. > > > > > > > Ok, thanks, what about this? > > > > # LOG_REPORT: report the test results > > LOG_REPORT := awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{f++} /\[SKIPPED\][\r]*$$/{s++} \ > > END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ > > printf(" See all results in %s\n", ARGV[1]); }' > > > > run-user: nolibc-test > > $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > > $(Q)$(LOG_REPORT) $(CURDIR)/run.out > > > > run: kernel > > $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" > > $(Q)$(LOG_REPORT) $(CURDIR)/run.out > > > > rerun: > > $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" > > $(Q)$(LOG_REPORT) $(CURDIR)/run.out > > > > Or we directly add a standalone test report script? something like > > tools/testing/selftests/nolibc/report.sh > > > > #!/bin/sh > > # > > # report.sh -- report the test results of nolibc-test > > # > > > > LOG_FILE=$1 > > [ ! -f "$LOG_FILE" ] && echo "Usage: $0 /path/to/run.out" > > > > awk ' > > /\[OK\][\r]*$$/{ p++ } > > /\[FAIL\][\r]*$$/{ f++ } > > /\[SKIPPED\][\r]*$$/{ s++ } > > > > END { > > printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); > > printf(" See all results in %s\n", ARGV[1]); > > }' $LOG_FILE > > > > And use it like this: > > > > LOG_REPORT = $(CURDIR)/report.sh > > > > I plan to renew this patchset, which one of the above methods do you > prefer? IFF it needs to be done I prefer the macro in the Makefile to avoid depending on external scripts that are useless outside of the makefile. BUT, my point remains that I adopted this so that I could quickly and visually check that everything was OK. I'm fine with any other method but I do not want to have to carefully read all these lines to make sure I'm not mixing a "8" with a "0" (I'm mentioning this one because it's exactly the one I had when I decided to add the extra values). For example if you prepend "FAILURE: ", "WARNING: ", "SUCCESS: " in front of these lines to summarize them depending on the highest level encountered (success, skipped, failed), then I'm fine because it's easy to check that all lines show the same word. > For the always print statement: > > printf(" See all results in %s\n", ARGV[1]); }' Then please put it on its own line without the leading space, this will be even more readable. > I will paste the reason why I need it, as mentioned in [1], if you still > need a clean test report, I will give up this change ;-) No worries, I don't want to be annoying if you need something, but I don't want to be annoyed by changes either :-) thanks, Willy
On Wed, Jun 07, 2023 at 01:52:00PM +0800, Zhangjin Wu wrote: > > Hi, Willy > > > (...) > > > > > > Ok, thanks, what about this? > > > > > > # LOG_REPORT: report the test results > > > LOG_REPORT := awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{f++} /\[SKIPPED\][\r]*$$/{s++} \ > > > END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ > > > printf(" See all results in %s\n", ARGV[1]); }' > > > > > > run-user: nolibc-test > > > $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : > > > $(Q)$(LOG_REPORT) $(CURDIR)/run.out > > > > > > run: kernel > > > $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" > > > $(Q)$(LOG_REPORT) $(CURDIR)/run.out > > > > > > rerun: > > > $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" > > > $(Q)$(LOG_REPORT) $(CURDIR)/run.out > > > > > > Or we directly add a standalone test report script? something like > > > tools/testing/selftests/nolibc/report.sh > > > > > > #!/bin/sh > > > # > > > # report.sh -- report the test results of nolibc-test > > > # > > > > > > LOG_FILE=$1 > > > [ ! -f "$LOG_FILE" ] && echo "Usage: $0 /path/to/run.out" > > > > > > awk ' > > > /\[OK\][\r]*$$/{ p++ } > > > /\[FAIL\][\r]*$$/{ f++ } > > > /\[SKIPPED\][\r]*$$/{ s++ } > > > > > > END { > > > printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); > > > printf(" See all results in %s\n", ARGV[1]); > > > }' $LOG_FILE > > > > > > And use it like this: > > > > > > LOG_REPORT = $(CURDIR)/report.sh > > > > > > > I plan to renew this patchset, which one of the above methods do you > > prefer? > > IFF it needs to be done I prefer the macro in the Makefile to avoid > depending on external scripts that are useless outside of the makefile. > BUT, my point remains that I adopted this so that I could quickly and > visually check that everything was OK. I'm fine with any other method > but I do not want to have to carefully read all these lines to make > sure I'm not mixing a "8" with a "0" (I'm mentioning this one because > it's exactly the one I had when I decided to add the extra values). > For example if you prepend "FAILURE: ", "WARNING: ", "SUCCESS: " in > front of these lines to summarize them depending on the highest level > encountered (success, skipped, failed), then I'm fine because it's > easy to check that all lines show the same word. > Ok. > > For the always print statement: > > > > printf(" See all results in %s\n", ARGV[1]); }' > > Then please put it on its own line without the leading space, this > will be even more readable. > It is a good balance. This may be more useful if we run this from the kselftest framework, seems it is not able to run it from the 'kselftest' target currently, here shares something I have tried: I tried something like this, seems run-user works, but defconfig and run not. diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 4a3a105e1fdf..70693f6501c6 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -83,6 +83,8 @@ CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ $(CFLAGS_$(ARCH)) $(CFLAGS_STACKPROTECTOR) LDFLAGS := -s +NOLIBC_SUBTARGETS ?= run-user + help: @echo "Supported targets under selftests/nolibc:" @echo " all call the \"run\" target below" @@ -110,7 +112,9 @@ help: @echo " IMAGE_NAME = $(if $(IMAGE_NAME),$(IMAGE_NAME),UNKNOWN_ARCH) [determined from \$$ARCH]" @echo "" -all: run +run_tests: $(NOLIBC_SUBTARGETS) + +all: $(NOLIBC_SUBTARGETS) This can be triggered from the top-level kselftest framework: $ make -C /path/to/linux-stable kselftest TARGETS=nolibc NOLIBC_SUBTARGETS=run-user And seems we still not support O= currently either. > > I will paste the reason why I need it, as mentioned in [1], if you still > > need a clean test report, I will give up this change ;-) > > No worries, I don't want to be annoying if you need something, but I > don't want to be annoyed by changes either :-) > Thanks, Zhangjin > thanks, > Willy
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index be4159837494..8149ace2938a 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -127,14 +127,18 @@ nolibc-test: nolibc-test.c sysroot/$(ARCH)/include libc-test: nolibc-test.c $(QUIET_CC)$(CC) -o $@ $< -# qemu user-land test -run-user: nolibc-test - $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : +test-report: $(Q)awk '/\[OK\]$$/{p++} /\[FAIL\]$$/{f++} /\[SKIPPED\]$$/{s++} \ END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ $(CURDIR)/run.out +# qemu user-land test +_run-user: nolibc-test + $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : + +run-user: _run-user test-report + initramfs: nolibc-test $(QUIET_MKDIR)mkdir -p initramfs $(call QUIET_INSTALL, initramfs/init) @@ -147,20 +151,16 @@ kernel: initramfs $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs # run the tests after building the kernel -run: kernel +_run: kernel $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" - $(Q)awk '/\[OK\]$$/{p++} /\[FAIL\]$$/{f++} /\[SKIPPED\]$$/{s++} \ - END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ - if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ - $(CURDIR)/run.out + +run: _run test-report # re-run the tests from an existing kernel -rerun: +_rerun: $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" - $(Q)awk '/\[OK\]$$/{p++} /\[FAIL\]$$/{f++} /\[SKIPPED\]$$/{s++} \ - END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ - if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ - $(CURDIR)/run.out + +rerun: _rerun test-report clean: $(call QUIET_CLEAN, sysroot)