Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1912930pxp; Thu, 10 Mar 2022 14:57:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyR+iqX4gE8+x59IVURTBjfCnaDDnmSIfFVBliTSaaNVMXimnlGCGx1VLP8GcKR9pn0U4HE X-Received: by 2002:a05:6402:254b:b0:417:200e:d6f1 with SMTP id l11-20020a056402254b00b00417200ed6f1mr170782edb.322.1646953030186; Thu, 10 Mar 2022 14:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646953030; cv=none; d=google.com; s=arc-20160816; b=n+idMhBW49y9hmYQDuxBtERI2rt+kTQuhIK9/s10FcONN1e+S9BgCGVks6VS/5hfDz 19oOq8JRN8LmO0P89BCQfI7pav+z2vvvquXLE73KpTmWYF6IVdKLG7cowhuhNluT+bgM 4QtKEriG12vlCyoORO894tIjDG8N1PnaugKozgbpUoU2jd4GqN0W1eVNL4tAW9ZE8Oqc XGQoVLt8cxf8c96Fj4b9npIuuDHwiZmxqjnmACJqRYwYjLHRYXcdhxXXuqfBSMVIMNMG +fWmT5w1AAVqxtkxWAuc9ySSLxvYcKJRc3TOn0DNpwCJNg7BBqKUqDOOahYFfC1ahG9T HswQ== 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=+6DiS3HvNB3XgupfAzrlzQDEfuL1+s8kw8SCCmZzvX8=; b=tM9VvlOIxUltANs8EQ41K237wvZJVoe7/aN4qNFhGsqrGDxMn9ilRv0NG91bOwyXKq MhZNfR2QSAtN1QXVsJQ8IMoCzCLz3v8ItcBwPgDkw4ckHOv9OXxDtYIJhRx4C7z7boda kgfbNcaD/TSLIuAEP07uRZwy5fZQgsnOA+vi3n0xXdEHaHcNCT/gJO81kB4tD9GePt5L nlXhS2Vbh6RkklPBRUMUi+WnEkXV+v7cerxLY9Ie+fppZMDETqHq/uyN39CEK+1DzUDD fp1bYZ19iQ29jq31DRYmRYeInP43R4tXnUUkrWx4FBDaOV7YHQ5MrsoZglvgbplyX/7O sldA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fpYxgk9R; 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 w11-20020a1709062f8b00b006d09e9a37d8si3672731eji.801.2022.03.10.14.56.45; Thu, 10 Mar 2022 14:57:10 -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=fpYxgk9R; 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 S1344487AbiCJWvi (ORCPT + 99 others); Thu, 10 Mar 2022 17:51:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344486AbiCJWvg (ORCPT ); Thu, 10 Mar 2022 17:51:36 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29C83F744C for ; Thu, 10 Mar 2022 14:50:35 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id qa43so15207781ejc.12 for ; Thu, 10 Mar 2022 14:50:35 -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=+6DiS3HvNB3XgupfAzrlzQDEfuL1+s8kw8SCCmZzvX8=; b=fpYxgk9RH2ab6hvmVb9/ov9lQ+JgBzr5TqAaihSEmiJ3D57s0jIjbcABmlkmovhSO2 qD2xfiQl2FtTaWXnWEX9OwSJBDVIPAO+uVMyh1npheHkqAuxbNKTvTBjrY201Yxm2rbj 1kv4UGFVHi9t0OITt44ijiJTvojiEKAZeM3VcBXUEO5r4VcM7BInDliaGemJkHw7cZ6W Rm0gLXSqRfegKgtJiooWXgiMrvZwEYK4ed4BWsGaTjH0Y1qRIAsXGURQYWrr/s8S/89i lK40eOrGfNViYgDwMOwDOK2eICeUaaldQjmdsFmbPxyczsq8ZtSTmAkXf4NGr+z1rYdE 1gHw== 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=+6DiS3HvNB3XgupfAzrlzQDEfuL1+s8kw8SCCmZzvX8=; b=BgxFdLyqMjZNLUdliLNnoqR9YJifSlkGOk4Plf9IoxAwWGA3sImYl6cGgUIlAsiiDw 37Qw1tDEjCY87QQ9KBnZ6B/8nkT9IfLXkAtux1lfkG+GaoMeiLXbj1AJ9ogy1Fgt6jkb 25ni0kWPr9eEzqQt9wIyBwimokLtJA8ofhmTlBa4PmpEH67BXSJoRejrs/OC85u65RXz e6OjeShRd8f0N0Fc9glsUEnuSkP7L3ZpSzMQhQYa7INZXb9C3075Fola8np4S22B/joN qIKImb64YttuNtnXdR+G6moJ2F2riOP9zdrwHhczkIvDmJyrAg+AnPr0VaMwyvNcv8p8 tRyQ== X-Gm-Message-State: AOAM530jyd1HkaaWoyMUpuIAIfQllcH8qFNO5pcycyKVmT4IGs9JWGRG JSgqp0bkLj5XEiJL6QH3qOnG//w7nXsT9Nb9jS8lDQ== X-Received: by 2002:a17:906:2899:b0:6d6:e479:1fe2 with SMTP id o25-20020a170906289900b006d6e4791fe2mr6278183ejd.394.1646952633447; Thu, 10 Mar 2022 14:50:33 -0800 (PST) MIME-Version: 1.0 References: <20220310210210.2124637-1-brendanhiggins@google.com> In-Reply-To: From: Brendan Higgins Date: Thu, 10 Mar 2022 17:50:22 -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 , Jeremy Kerr 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 Actually add Jeremy this time. Sorry for the spam. On Thu, Mar 10, 2022 at 5:49 PM Brendan Higgins wrote: > > +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 > >