Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1934929pxp; Thu, 10 Mar 2022 15:27:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyG0bj59UD7jvMfQsWv4heRmeOWnN/hLPWB/dZMrYLFeo5uHRt+F5f+2IkMqUn1BczPpbaX X-Received: by 2002:a17:907:94c1:b0:6db:67:7214 with SMTP id dn1-20020a17090794c100b006db00677214mr6204803ejc.180.1646954827998; Thu, 10 Mar 2022 15:27:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646954827; cv=none; d=google.com; s=arc-20160816; b=MTvLHLgEpIsrw5mlfRm/OF5+JaLP/PqXUrev5AlUOOICUxSnPAKjE0o8dwD6vJklRg uxCSmv5UJyvfEUjDUh7TtZa3Y8KC2W6vujATQDEO91OHji3FbK7drP7Exz8TtzpiImD7 bohFSmtin1V71swPeCSRIXes89EebwMd7MzpPUJ2ZwKnGN6dowIeRUMPaWkHyXExERIY ETKFMbweWq3UpJYT7HBPTmQN+tjjiv20dDBeQFNL0QHj11MadiuUqNYHUFZQ8CmE6Hgk cniLzvVL+3xmKXcpMAl2bo8KJr7Ff8TYzdOQRNK/P7dzNzNzptW8WkCJjVozpKMWWrgw vDQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=X/rtu54ntkVXnZ8WzhCGXP7Ng7Fgx6ahBoAiWoEdfPI=; b=vc3WGhC7BgfkQQLurx5p8oHmnq5mJa0Wc5wc4zEwotkVqzyxJXh2O6GhIiBuy4eGQJ Y+W7skCMZuXFGUwXgCEVpHqnHhYb3kd6grTT1VbLr8x+UqO4V2JhDhmOALgqIsN9dRMm N93DrXJYX4T9fHey7VFpDGtQ1cEdJvfk0C4fNRIcJObeIAdlErtetr1PediDMG9MN5e6 LkXW9GMnZ83/XE1GNFd3qTW8r01CLzGIa8/pYiAVrYdL3c67xSPYcSG14LPntt9yBtwU V5dfHWKOnTY+236yrYG3JkH/CcIQR/blBWZcgJutPaBmcjaSwUer/06Wo3GyLtOL1X0x OaKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Tzc/GE6O"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga5-20020a1709070c0500b006dab77a8ffdsi4884852ejc.54.2022.03.10.15.26.32; Thu, 10 Mar 2022 15:27:07 -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; dkim=pass header.i=@google.com header.s=20210112 header.b="Tzc/GE6O"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245752AbiCJWuZ (ORCPT + 99 others); Thu, 10 Mar 2022 17:50:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343931AbiCJWuY (ORCPT ); Thu, 10 Mar 2022 17:50:24 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2FC9CFB94 for ; Thu, 10 Mar 2022 14:49:21 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id qa43so15201957ejc.12 for ; Thu, 10 Mar 2022 14:49:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X/rtu54ntkVXnZ8WzhCGXP7Ng7Fgx6ahBoAiWoEdfPI=; b=Tzc/GE6Ob61G7++79zVEuQGKO+ogy/3CB20AUrZdJUjo1sx41vjLvG+BMIGTdZoxB1 Erf7uWEqzMBZb2IoSJC/G2Ca4Xi/oPJKvDIWf7s8Py+FL6LIb2g/4VQuTDsFBgXF3n5H 4Z79gfx785IaI419QwidGq/mlIJ5ubUpuL8AKRkkokYS6pb/ku3dbtr5vK2CQxZwRBOy aEZxnbOXpvp8N20npvalpFp89W8dhnrTqiCIxmLGZkimL27HeAmHQhRXuahcpJmUJ9sw YPL+GFZ1uWa4nb1oFe0rtrUBQwChHvRd42wsy/ngQ+slNDpqK2d61m8R+Wqe6Il1JmwO bqNA== 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=X/rtu54ntkVXnZ8WzhCGXP7Ng7Fgx6ahBoAiWoEdfPI=; b=Cz/Pn62z1ORe59BHJw68rvspmUG3pT9p1PArfC8AjJvXOFSsRdIIpMfgR4repHxyIf dWh6Gezatdh/vLJKP7KpM54at5QZ54b8/kbRq6amrlWzL170mYeeh8ULhDUO6O5h26Xt U+7EsiaKoU6LpkCZ1HcVz9E2jz3qU0rCXbKEfd60VM8+dF3LIYniI1IVsVkDkKWWiQF0 M7YUgDuQZIDOqSb4g2pvDoL8duoadO0GNdrzR5rpphLjz2gkew8p/R5Z6DGcy04nbGfQ wP9cnvr6TVnD+T6ig9GoG7+yhIY4k4LCG2ixXeaRUUs8T/MBtDzgfMFEn8UMwuIIyTSO rXaQ== X-Gm-Message-State: AOAM530bLZLxnwcy9rU43fYZ0idVU6WgXq9YADj3lQFZjrQ0b1/0Ue0O Q4pUefgbDJoZyyBVpeVAPnpTup+EGhhepXLqadUb9Q== X-Received: by 2002:a17:907:eab:b0:6da:8ec5:d386 with SMTP id ho43-20020a1709070eab00b006da8ec5d386mr6264799ejc.668.1646952560219; Thu, 10 Mar 2022 14:49:20 -0800 (PST) MIME-Version: 1.0 References: <20220310210210.2124637-1-brendanhiggins@google.com> In-Reply-To: <20220310210210.2124637-1-brendanhiggins@google.com> From: Brendan Higgins Date: Thu, 10 Mar 2022 17:49:08 -0500 Message-ID: Subject: Re: [RFC v1] kunit: add support for kunit_suites that reference init code To: shuah , David Gow , Daniel Latypov , Martin Fernandez , Daniel Gutson Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, keescook@chromium.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 +Jeremy Kerr - Just remembered that Jeremy is doing some work here and might be somewhat interested. On Thu, Mar 10, 2022 at 4:02 PM Brendan Higgins wrote: > > Add support for a new kind of kunit_suite registration macro called > kunit_test_init_suite(); this new registration macro allows the > registration of kunit_suites that reference functions marked __init and > data marked __initdata. > > Signed-off-by: Brendan Higgins > --- > > This patch is in response to a KUnit user issue[1] in which the user was > attempting to test some init functions; although this is a functional > solution as long as KUnit tests only run during the init phase, we will > need to do more work if we ever allow tests to run after the init phase > is over; it is for this reason that this patch adds a new registration > macro rather than simply modifying the existing macros. > > [1] https://groups.google.com/g/kunit-dev/c/XDjieRHEneg/m/D0rFCwVABgAJ > > --- > include/kunit/test.h | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/include/kunit/test.h b/include/kunit/test.h > index b26400731c02..1878e585f6d3 100644 > --- a/include/kunit/test.h > +++ b/include/kunit/test.h > @@ -379,6 +379,27 @@ static inline int kunit_run_all_tests(void) > > #define kunit_test_suite(suite) kunit_test_suites(&suite) > > +/** > + * kunit_test_init_suites() - used to register one or more &struct kunit_suite > + * containing init functions or init data. > + * > + * @__suites: a statically allocated list of &struct kunit_suite. > + * > + * This functions identically as &kunit_test_suites() except that it suppresses > + * modpost warnings for referencing functions marked __init or data marked > + * __initdata; this is OK because currently KUnit only runs tests upon boot > + * during the init phase or upon loading a module during the init phase. > + * > + * NOTE TO KUNIT DEVS: If we ever allow KUnit tests to be run after boot, these > + * tests must be excluded. > + */ > +#define kunit_test_init_suites(__suites...) \ > + __kunit_test_suites(CONCATENATE(__UNIQUE_ID(array), _probe), \ > + CONCATENATE(__UNIQUE_ID(suites), _probe), \ > + ##__suites) > + > +#define kunit_test_init_suite(suite) kunit_test_init_suites(&suite) > + > #define kunit_suite_for_each_test_case(suite, test_case) \ > for (test_case = suite->test_cases; test_case->run_case; test_case++) > > > base-commit: 330f4c53d3c2d8b11d86ec03a964b86dc81452f5 > -- > 2.35.1.723.g4982287a31-goog >