From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2339EC433F5 for ; Mon, 25 Oct 2021 21:09:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0591B61076 for ; Mon, 25 Oct 2021 21:09:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234952AbhJYVLl (ORCPT ); Mon, 25 Oct 2021 17:11:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234961AbhJYVLj (ORCPT ); Mon, 25 Oct 2021 17:11:39 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 178B2C061348 for ; Mon, 25 Oct 2021 14:09:17 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id v7so29554924ybq.0 for ; Mon, 25 Oct 2021 14:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fMOs6cxMHZeY7p7bnLVrVa+nRYtiWwqokE5opzamm5s=; b=qSOuZF0SKslyezv3ziYUivJgvvV5MqNlrELCCyjObUDtajwbaRdXuDEeS0gzWK6RVv kaXKVeeo5VAttaOVOammEDiQHMnc0vMjShI2qD/Qx0V05Br087dZFVAZfATJe8+1nxL0 gfHvxNE0wWebxzsftiI/4yv+v0Hvx+8BhF6y3W/87MPRuDXhoqNj/odWgFYUUnmCTNbd 0FHfnV+kRZOlMAILuQd4hOM+xNVXY+GtUgumwq2r4gKV3fTNZXKc4iWaiMp8Vo2bT8Bf fKdu8AxnI7ewxYsqwrByBQmZ3nIXwQAaPTU+DYSkAxMrmw5LywF84yiWThYbylAsxIug TzrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fMOs6cxMHZeY7p7bnLVrVa+nRYtiWwqokE5opzamm5s=; b=28N2+m1+W18aJlOOPIN5/2OjjCDjHNVSxv+6N9SthZftfCctm+dpBbdYAlb+oPSq2g Swjmo69e18t2Nf5XxG/wukrjLV8VdUkdjeJEP2C3V+Qory2hQfbqBPRbaL7rPW91wikW df398+X+shf+K7VZRTLPdi83zgsiLkTSjwobTpEzkCufME2ZW5VbNNTb3pysanJZZKkS qpgB1m3pbExl316L3CnDNfmNuBqUXq4PhntGxJKMuVID+KSqfOpltmhEDu5V8K7xFeeU W75xO4CK1zNkpTQICRZG83IqYlqjdzOI/PCBgGx33pHzWfWyEFFqvaED2Yn/3VN57cZZ Gfvg== X-Gm-Message-State: AOAM530gCHdeAU1uppf5GElyOCtoevce0bmzwsm6R7CkNF9ZB6VRNfq2 nqpbbN01Xw1nEk2WaT3c3kGWUNbrRU8g6Lv84iQ= X-Google-Smtp-Source: ABdhPJwfHm+EQ5md579aZoNLdY/sGMU3AriFORSuQub+hP34o4wAIepuNtmwct+09J6si10PcPKBj6BVkL/L1hGGtkQ= X-Received: by 2002:a25:afcd:: with SMTP id d13mr20745586ybj.504.1635196156332; Mon, 25 Oct 2021 14:09:16 -0700 (PDT) MIME-Version: 1.0 References: <20211022223228.99920-1-andrii@kernel.org> <20211022223228.99920-3-andrii@kernel.org> In-Reply-To: From: Andrii Nakryiko Date: Mon, 25 Oct 2021 14:09:05 -0700 Message-ID: Subject: Re: [PATCH bpf-next 2/4] selftests/bpf: support multiple tests per file To: "sunyucong@gmail.com" Cc: Andrii Nakryiko , bpf , Alexei Starovoitov , Daniel Borkmann , Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Mon, Oct 25, 2021 at 1:56 PM sunyucong@gmail.com wrote: > > On Mon, Oct 25, 2021 at 1:39 PM Andrii Nakryiko > wrote: > > > > On Mon, Oct 25, 2021 at 1:13 PM sunyucong@gmail.com wrote: > > > > > > On Fri, Oct 22, 2021 at 3:33 PM Andrii Nakryiko wrote: > > > > > > > > Revamp how test discovery works for test_progs and allow multiple test > > > > entries per file. Any global void function with no arguments and > > > > serial_test_ or test_ prefix is considered a test. > > > > > > > > Signed-off-by: Andrii Nakryiko > > > > --- > > > > tools/testing/selftests/bpf/Makefile | 7 +++---- > > > > 1 file changed, 3 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > > > > index 498222543c37..ac47cf9760fc 100644 > > > > --- a/tools/testing/selftests/bpf/Makefile > > > > +++ b/tools/testing/selftests/bpf/Makefile > > > > @@ -421,10 +421,9 @@ ifeq ($($(TRUNNER_TESTS_DIR)-tests-hdr),) > > > > $(TRUNNER_TESTS_DIR)-tests-hdr := y > > > > $(TRUNNER_TESTS_HDR): $(TRUNNER_TESTS_DIR)/*.c > > > > $$(call msg,TEST-HDR,$(TRUNNER_BINARY),$$@) > > > > - $$(shell ( cd $(TRUNNER_TESTS_DIR); \ > > > > - echo '/* Generated header, do not edit */'; \ > > > > - ls *.c 2> /dev/null | \ > > > > - sed -e 's@\([^\.]*\)\.c@DEFINE_TEST(\1)@'; \ > > > > + $$(shell (echo '/* Generated header, do not edit */'; \ > > > > + sed -n -E 's/^void (serial_)?test_([a-zA-Z0-9_]+)\((void)?\).*/DEFINE_TEST(\2)/p' \ > > > > > > probably not that important : allow \s* before void and after void. > > > Or, maybe we can just (?!static) instead of anchoring to line > > > start. > > > > Selftests source code is pretty strict with formatting, so I don't > > think we'll deviate from the strict `^void ` pattern (and we > > certainly don't want to deviate). So I didn't want to overcomplicate > > regexes unnecessarily. > > > > > > > > > + $(TRUNNER_TESTS_DIR)/*.c | sort ; \ > > > > > > to be super safe : maybe add a check here to ensure each file contains > > > at least one test function. > > > > It's actually a useful property to have .c files that don't have > > tests. This can be used for adding various shared helpers. Currently > > all *_helpers.c are in selftests/bpf/ directory and have to be > > explicitly wired in Makefile, which is a bit annoying. With this setup > > we can just put a new .c file in the selftests/bpf/prog_tests/ and it > > will be automatically compiled and linked. > > > > It also will significantly hurt readability to add some sort of > > per-file check in there, do you think it's worth it? > > You are right, probably not really worth it. we just have to watch the > total test numbers, it should always goes up :-D Yep. We should be able to automate this once we have some sort of baseline comparison functionality in BPF CI. > > > > > > > > > > ) > $$@) > > > > endif > > > > > > > > -- > > > > 2.30.2 > > > >