Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp704643rwd; Wed, 7 Jun 2023 06:00:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4IueezxpLQg7gYDtPKbJmNqvwuhjdR8rkXOamljhtNYDlxq8bpn6AFbysrBTAvSQzHo2Gg X-Received: by 2002:a05:6a20:d806:b0:10b:40a9:ec48 with SMTP id iv6-20020a056a20d80600b0010b40a9ec48mr3199938pzb.29.1686142809590; Wed, 07 Jun 2023 06:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686142809; cv=none; d=google.com; s=arc-20160816; b=RuAcgqf8n4R8fPlMzu6xP1Jn2f1KlHn/M8gQd2Vqca7njE3DL/oe8ajOxO2cMIX9P8 BJW7hqlN7/jxjb992cvDjYhLArfW43ehzA3UlOqzqAKz/YzB1+HBsKdn8It6QCjQas/L T2hrnXQkJGOZPSa1adAWti9BNHD/4wZEr8GYX9O/pf9/3CP2EMea34afrnZemwS0bBJ4 U8fYvtg7ADKO11341C/z8LLcSOB7BZoM6JIsnprsrm3UAQxxVl9vCnj0HsHD89bQgdC5 i9LrznFWRf5Rddyebm3j0H+0PQw8KADuXVImh0qalmKnOvBxre23DSPMz3RQ69j6fHRk mecw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=wdJQgGnjA9y8gJ9FDFhXYYuQ5vejWAXrPStuEGHWBgE=; b=FUfwks3Y0wkiWRtz7qMmvuZEWr+SThTwKx21yZLocucf+ffQWabVm2J3H11bZhDk2E /9WKNsAOYw1bnHPsC97jcw78umRFj29mkhGwtCNQP5u951YH9mmRwrxEIzyWr+f/M8QV ExkbdTUv5IeVLQ+RGZCh0nI4Q4949312cmSQKl4cUY0HVDmQhIP8bYTyMLRDfyFrgF/4 wLOulXjQHduN+geb9Gvmf7AUcGW+39ByP8YCnowNiQf6oSPLJHP5aYCZcLdd+eNoWsqC 0r1/DpDa6bLXdf046+P1eVC+C1MaLWEgf3Wa5ujfsKk3xkMtm1t7KAAy/KY/qX5VbSuI iW6g== 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 l184-20020a6388c1000000b00544c0bf5ffcsi709738pgd.219.2023.06.07.05.59.54; Wed, 07 Jun 2023 06:00:09 -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 S239740AbjFGMqR (ORCPT + 99 others); Wed, 7 Jun 2023 08:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234352AbjFGMqQ (ORCPT ); Wed, 7 Jun 2023 08:46:16 -0400 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7FDC6E6B; Wed, 7 Jun 2023 05:46:14 -0700 (PDT) Received: (from willy@localhost) by mail.home.local (8.17.1/8.17.1/Submit) id 357Cjhfj003458; Wed, 7 Jun 2023 14:45:43 +0200 Date: Wed, 7 Jun 2023 14:45:43 +0200 From: Willy Tarreau To: Zhangjin Wu Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: Re: [PATCH 1/4] selftests/nolibc: add a test-report target Message-ID: References: <20230605065459.153001-1-falcon@tinylab.org> <20230607055200.667447-1-falcon@tinylab.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230607055200.667447-1-falcon@tinylab.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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 > > > > --- > > > > 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