Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp760242pxp; Fri, 11 Mar 2022 14:23:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYr6XF55AZmsahzmZX0i+T0VJdvthF+15AtYAIr2Z/T5JGMKYCS4igIotIQuxZ2XHORDl/ X-Received: by 2002:a05:6a00:9a9:b0:4f7:876e:1e83 with SMTP id u41-20020a056a0009a900b004f7876e1e83mr6860728pfg.71.1647037436773; Fri, 11 Mar 2022 14:23:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647037436; cv=none; d=google.com; s=arc-20160816; b=RzeADdwliSOxJMdjI3MXn9um5LMR7fGTOYvzvbDZ/vwfU8FgAyU+HLYhuLgvQqKsCi yAFpli/dFs1URgEckQGsmXDZsDfqltB+EIxfa27j7SHdno6E6UD5RfLN8cB2S7uA0Ouk me2N0YthixjTTy3au49t/u4Gc9X7Zuo8w1lp/P5IY290xhAI3LbkEhaydHyJgPLD32A+ whCJMjvDR137RzXlnbt6M3K5pIjJMKM5Vku7aNzekKK+xHwTCw26tSLa3T53nplE3Y6v R8S5QTdBrY9gGScw/mYOhe4VwA7x1Rw0C4zIcKTWWgy3kfU+GX/qYAcGWZhoAqWqlDQ6 GJoA== 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:references :in-reply-to:mime-version:dkim-signature; bh=X1pCWOxN1ukIne/lto86DuwN95tdGaxh3GRtyvz2dIg=; b=m+XiHw0RrN+w8Q87qXmlxg2mVUoHa2yDs+IPLM3iM0+gf5tY2jD6d5+zTfVnjjAIqj ZewIpEKUAMsd2UJB/X+ncFvNZJ4vDP/r6Z8w+94RX0ki0y5eStkA6CbO++tN9YOSMQGB uBrpm/EsY4xq/bfwP/d8eLnl8zbrjdpYeUI856sxJY3xAwUnFB1LF1eWVztMlErbdj6Q UdR0HGn1M7teMb199jSGB/tBFmuLcGNydvhbe6eGSmXyix+W9Fhk9Qx2HWkSbfUU/8lq 1LUjcn5+sDos4GNC17xDaVe+ZM+AFiA7m5kOApuhRUUAJKFzMGhJkCwky4oZ0+jtVeUN 1w3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eclypsium.com header.s=google header.b=J4suHYHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=eclypsium.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p20-20020a170902ead400b00153042562b1si8144115pld.296.2022.03.11.14.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:23:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@eclypsium.com header.s=google header.b=J4suHYHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=eclypsium.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 66EEB30892C; Fri, 11 Mar 2022 13:33:31 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343593AbiCJVnS (ORCPT + 99 others); Thu, 10 Mar 2022 16:43:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241488AbiCJVnQ (ORCPT ); Thu, 10 Mar 2022 16:43:16 -0500 Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE3BA19417D for ; Thu, 10 Mar 2022 13:42:12 -0800 (PST) Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-2db569555d6so73531457b3.12 for ; Thu, 10 Mar 2022 13:42:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eclypsium.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=X1pCWOxN1ukIne/lto86DuwN95tdGaxh3GRtyvz2dIg=; b=J4suHYHMFQjki4DGGqcv+lWRKy1XqEZBaZFqAcg73gjqA2x+qHjWNvBNR8c8ZCyecS /0H6mm0cFlOfnSNiEu1xl/wyjhmnoae4XDhKSHta/Jrcn1Iupn2lo+C3myyzgAZrHmjL Xpn8dYzBtFltgSHuPERecyg3SUr+3DdlwhxhNshY2hNqtC1vHLx3Q9hRYaKpOuEFNvpl yh9jTU6wHiVdDLM/A4xXitM+ySjsXQ74tJFpYax1dUdKptwopQN/gzTTmvIePUuJRYPo Kw7KpLFxEj7UMU1HALiedRdoeLdU9Q6lWCQvo7K09/4n6vHWQgW4VkKbhO8jyf6hG2qD 6FHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=X1pCWOxN1ukIne/lto86DuwN95tdGaxh3GRtyvz2dIg=; b=sUSe5x3blA8rCaRealU9rHbklE2Np08ORrK9hLhQqgyH2GByGDPhUOKP6iQIr9YLGa DWM6WktzjqabhY6r0jnF20c5sN2oU2fDvCVBy1lrzl4DJJoluWsxaz4WAOCG11J24xZ9 a0KuHHjr8xSuPyR43n/nCU/SuNcwHf9bdCGh+G0pOEUL1cpLoxlVPrwb1jEabD6c/q50 +eAirzP+1lTDC65H3v7LfFgsYi6UrAR7PzvHQvHP2QCyW8F6z15D/j25DT8L8X/+BUvs Vgcr7gA57cACiH6BZSmuljOYQJX+yqzYnnamz8gN2Gi2yf6753+UdPu02R1YgoDDYCTb +NFQ== X-Gm-Message-State: AOAM533strrVYHjUWPNV4fVUzB5aKB3QVbJuyQPGSGF2kfEgf/+SHXlx 1sPBFeC/XzKHAa/6rH2RVNfdTewbJZEpaRgS38YnUA== X-Received: by 2002:a81:983:0:b0:2dc:62af:71eb with SMTP id 125-20020a810983000000b002dc62af71ebmr5848548ywj.9.1646948531807; Thu, 10 Mar 2022 13:42:11 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a0d:df06:0:0:0:0:0 with HTTP; Thu, 10 Mar 2022 13:42:11 -0800 (PST) In-Reply-To: <20220310210210.2124637-1-brendanhiggins@google.com> References: <20220310210210.2124637-1-brendanhiggins@google.com> From: Martin Fernandez Date: Thu, 10 Mar 2022 18:42:11 -0300 Message-ID: Subject: Re: [RFC v1] kunit: add support for kunit_suites that reference init code To: Brendan Higgins Cc: shuah@kernel.org, davidgow@google.com, dlatypov@google.com, daniel.gutson@eclypsium.com, 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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On 3/10/22, 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 > > Thanks for the feature :) Tested-by: Martin Fernandez