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 X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E26AC433DF for ; Wed, 24 Jun 2020 20:15:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FC6D20823 for ; Wed, 24 Jun 2020 20:15:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LAgCJBjw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406411AbgFXUP3 (ORCPT ); Wed, 24 Jun 2020 16:15:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406384AbgFXUP1 (ORCPT ); Wed, 24 Jun 2020 16:15:27 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6CECC061795 for ; Wed, 24 Jun 2020 13:15:26 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id k1so1557204pls.2 for ; Wed, 24 Jun 2020 13:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IdPEcGBnqX+qJ5FRufYsC8Fmx34kZgyoik6khE35S6c=; b=LAgCJBjwd1W/QzoEvVFv6uT/xdusvMrDmvZmLReTUlSLsK29qb2r44fWyhO1UhPjLz uCqW0klYugm6yeBpcqwbanjBuPn8Y4d1Tu+ugG6egYFyGEsuoDAliH69triCGqr36dmi BMDc2ZPjjlfibF6w3Ngt7Ai+eI0QCED0XjXlZ9iFn4S8F1kjfO+ZbKzEVcatJwMuVMIJ QzCxLBIbzHXagWgFw39ff0eRVBOF+fHHz/VqrbQU+1mjgX/mE+n7M899/K/IafH7EGgM IhB3AOn5dcpYIYEwgO3/nAL0oNHI/8GAMY6MwEGOhWPMzMzE8W8bLyDD9+yilUzPos45 Mszw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IdPEcGBnqX+qJ5FRufYsC8Fmx34kZgyoik6khE35S6c=; b=Pyy5QZ4Wt/MNtlEpxOTFib9au1+G5jLS9OZj4SXOINQFTBiiQuxx0gu3Ry/k5aDxw6 c1F5Z7xAuQ3ZK2dApw1WluuxMjetHACo+nu3NpQrNbqZxd3EVilPRvRAe8xsmZZ7YUH2 2V0Hmpzubj1e/yjxxAzwaMgR5QRS4YOUqmuns0ISsdWoVvZONtNXjIj387POXhrQ5Zo+ Wdg3LBegnWs34RwOGrzcAqFS657XMly1wEsfvtbOmwWIG+gqBUfXHDMbrUOE0R2Ckaiv kOe4ke06NTSIGC1WdZZaALD/4mfMEP6sjO3QxAN10jpx+/Dwko1n0myMjI/NxM1JEzGM ne6Q== X-Gm-Message-State: AOAM532J2hTpYik2UcbW9XkRP8zVP/5Kj+hVUf/T/hl4AZuFq6njkVwM SRBoLZoZHA+AB6vMXzIYkz6RIQAw/N+FV2MsdYUNpw== X-Google-Smtp-Source: ABdhPJwWls4hrMzUFcn8SBHGpHRCDnSeZUXTbN8ExG/y1RAi8xwaghxvTb/oqHElrII6pYkocNgNnEUPoflPuaWhmtc= X-Received: by 2002:a17:90a:3321:: with SMTP id m30mr30079924pjb.20.1593029725879; Wed, 24 Jun 2020 13:15:25 -0700 (PDT) MIME-Version: 1.0 References: <20200228012036.15682-1-brendanhiggins@google.com> <20200228012036.15682-5-brendanhiggins@google.com> In-Reply-To: From: Brendan Higgins Date: Wed, 24 Jun 2020 13:15:14 -0700 Message-ID: Subject: Re: [PATCH v3 4/7] init: main: add KUnit to kernel init To: Frank Rowand Cc: Jeff Dike , Richard Weinberger , Anton Ivanov , Arnd Bergmann , Kees Cook , Shuah Khan , Alan Maguire , Iurii Zaikin , David Gow , Andrew Morton , rppt@linux.ibm.com, Greg KH , Stephen Boyd , Logan Gunthorpe , Luis Chamberlain , linux-um , linux-arch@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux Kernel Mailing List , "open list:DOCUMENTATION" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 2, 2020 at 11:13 AM Frank Rowand wrote: Sorry it took so long to respond. I am reviving this patchset now, about to send out a new revision and I just saw this comment. > On 2/27/20 7:20 PM, Brendan Higgins wrote: > > Remove KUnit from init calls entirely, instead call directly from > > kernel_init(). > > > > Co-developed-by: Alan Maguire > > Signed-off-by: Alan Maguire > > Signed-off-by: Brendan Higgins > > Reviewed-by: Stephen Boyd > > --- > > include/kunit/test.h | 9 +++++++++ > > init/main.c | 4 ++++ > > lib/kunit/executor.c | 4 +--- > > 3 files changed, 14 insertions(+), 3 deletions(-) > > > > diff --git a/include/kunit/test.h b/include/kunit/test.h > > index 8a02f93a6b505..8689dd1459844 100644 > > --- a/include/kunit/test.h > > +++ b/include/kunit/test.h > > @@ -197,6 +197,15 @@ void kunit_init_test(struct kunit *test, const char *name); > > > > int kunit_run_tests(struct kunit_suite *suite); > > > > +#if IS_BUILTIN(CONFIG_KUNIT) > > I suspected this would not work if a unittest was builtin but CONFIG_KUNIT > was set to module. > > So I decided to experiment a bit to verify my assumptions (before applying > this patch series). I tried to set CONFIG_KUNIT to module, then set > CONFIG_KUNIT_EXAMPLE_TEST to built in. Kconfig does not let me do this > because KUNIT_EXAMPLE_TEST is inside a 'if KUNIT' in lib/kunit/Kconfig, > but instead switches KUNIT_EXAMPLE_TEST to a module, and warns that it > has done so. This was a bit of a surprise, but seems reasonable. > > So my next assumption is that the architecture of KUnit expects > each individual unit test config option to depend upon CONFIG_KUNIT. > If this is the case, please clearly document that requirement in > the KUnit documentation. Your assumption is correct. I will fix this in the Kconfig documentation in a separate patch. > > +int kunit_run_all_tests(void); > > +#else > > +static inline int kunit_run_all_tests(void) > > +{ > > + return 0; > > +} > > +#endif /* IS_BUILTIN(CONFIG_KUNIT) */ > > + > > /* > > * If a test suite is built-in, module_init() gets translated into > > * an initcall which we don't want as the idea is that for builtins > > diff --git a/init/main.c b/init/main.c > > index ee4947af823f3..7875a5c486dc4 100644 > > --- a/init/main.c > > +++ b/init/main.c > > @@ -104,6 +104,8 @@ > > #define CREATE_TRACE_POINTS > > #include > > > > +#include > > + > > static int kernel_init(void *); > > > > extern void init_IRQ(void); > > @@ -1444,6 +1446,8 @@ static noinline void __init kernel_init_freeable(void) > > > > do_basic_setup(); > > > > + kunit_run_all_tests(); > > + > > console_on_rootfs(); > > > > /* > > diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c > > index 6429927d598a5..b75a46c560847 100644 > > --- a/lib/kunit/executor.c > > +++ b/lib/kunit/executor.c > > @@ -11,7 +11,7 @@ extern struct kunit_suite * const * const __kunit_suites_end[]; > > > > #if IS_BUILTIN(CONFIG_KUNIT) > > > > -static int kunit_run_all_tests(void) > > +int kunit_run_all_tests(void) > > { > > struct kunit_suite * const * const *suites, * const *subsuite; > > bool has_test_failed = false; > > @@ -31,6 +31,4 @@ static int kunit_run_all_tests(void) > > return 0; > > } > > > > -late_initcall(kunit_run_all_tests); > > - > > #endif /* IS_BUILTIN(CONFIG_KUNIT) */ > > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brendan Higgins Subject: Re: [PATCH v3 4/7] init: main: add KUnit to kernel init Date: Wed, 24 Jun 2020 13:15:14 -0700 Message-ID: References: <20200228012036.15682-1-brendanhiggins@google.com> <20200228012036.15682-5-brendanhiggins@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406318AbgFXUP1 (ORCPT ); Wed, 24 Jun 2020 16:15:27 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C1AC061573 for ; Wed, 24 Jun 2020 13:15:26 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id b92so1672324pjc.4 for ; Wed, 24 Jun 2020 13:15:26 -0700 (PDT) In-Reply-To: Sender: linux-arch-owner@vger.kernel.org List-ID: To: Frank Rowand Cc: Jeff Dike , Richard Weinberger , Anton Ivanov , Arnd Bergmann , Kees Cook , Shuah Khan , Alan Maguire , Iurii Zaikin , David Gow , Andrew Morton , rppt@linux.ibm.com, Greg KH , Stephen Boyd , Logan Gunthorpe , Luis Chamberlain , linux-um , linux-arch@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux On Mon, Mar 2, 2020 at 11:13 AM Frank Rowand wrote: Sorry it took so long to respond. I am reviving this patchset now, about to send out a new revision and I just saw this comment. > On 2/27/20 7:20 PM, Brendan Higgins wrote: > > Remove KUnit from init calls entirely, instead call directly from > > kernel_init(). > > > > Co-developed-by: Alan Maguire > > Signed-off-by: Alan Maguire > > Signed-off-by: Brendan Higgins > > Reviewed-by: Stephen Boyd > > --- > > include/kunit/test.h | 9 +++++++++ > > init/main.c | 4 ++++ > > lib/kunit/executor.c | 4 +--- > > 3 files changed, 14 insertions(+), 3 deletions(-) > > > > diff --git a/include/kunit/test.h b/include/kunit/test.h > > index 8a02f93a6b505..8689dd1459844 100644 > > --- a/include/kunit/test.h > > +++ b/include/kunit/test.h > > @@ -197,6 +197,15 @@ void kunit_init_test(struct kunit *test, const char *name); > > > > int kunit_run_tests(struct kunit_suite *suite); > > > > +#if IS_BUILTIN(CONFIG_KUNIT) > > I suspected this would not work if a unittest was builtin but CONFIG_KUNIT > was set to module. > > So I decided to experiment a bit to verify my assumptions (before applying > this patch series). I tried to set CONFIG_KUNIT to module, then set > CONFIG_KUNIT_EXAMPLE_TEST to built in. Kconfig does not let me do this > because KUNIT_EXAMPLE_TEST is inside a 'if KUNIT' in lib/kunit/Kconfig, > but instead switches KUNIT_EXAMPLE_TEST to a module, and warns that it > has done so. This was a bit of a surprise, but seems reasonable. > > So my next assumption is that the architecture of KUnit expects > each individual unit test config option to depend upon CONFIG_KUNIT. > If this is the case, please clearly document that requirement in > the KUnit documentation. Your assumption is correct. I will fix this in the Kconfig documentation in a separate patch. > > +int kunit_run_all_tests(void); > > +#else > > +static inline int kunit_run_all_tests(void) > > +{ > > + return 0; > > +} > > +#endif /* IS_BUILTIN(CONFIG_KUNIT) */ > > + > > /* > > * If a test suite is built-in, module_init() gets translated into > > * an initcall which we don't want as the idea is that for builtins > > diff --git a/init/main.c b/init/main.c > > index ee4947af823f3..7875a5c486dc4 100644 > > --- a/init/main.c > > +++ b/init/main.c > > @@ -104,6 +104,8 @@ > > #define CREATE_TRACE_POINTS > > #include > > > > +#include > > + > > static int kernel_init(void *); > > > > extern void init_IRQ(void); > > @@ -1444,6 +1446,8 @@ static noinline void __init kernel_init_freeable(void) > > > > do_basic_setup(); > > > > + kunit_run_all_tests(); > > + > > console_on_rootfs(); > > > > /* > > diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c > > index 6429927d598a5..b75a46c560847 100644 > > --- a/lib/kunit/executor.c > > +++ b/lib/kunit/executor.c > > @@ -11,7 +11,7 @@ extern struct kunit_suite * const * const __kunit_suites_end[]; > > > > #if IS_BUILTIN(CONFIG_KUNIT) > > > > -static int kunit_run_all_tests(void) > > +int kunit_run_all_tests(void) > > { > > struct kunit_suite * const * const *suites, * const *subsuite; > > bool has_test_failed = false; > > @@ -31,6 +31,4 @@ static int kunit_run_all_tests(void) > > return 0; > > } > > > > -late_initcall(kunit_run_all_tests); > > - > > #endif /* IS_BUILTIN(CONFIG_KUNIT) */ > > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406318AbgFXUP1 (ORCPT ); Wed, 24 Jun 2020 16:15:27 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C1AC061573 for ; Wed, 24 Jun 2020 13:15:26 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id b92so1672324pjc.4 for ; Wed, 24 Jun 2020 13:15:26 -0700 (PDT) MIME-Version: 1.0 References: <20200228012036.15682-1-brendanhiggins@google.com> <20200228012036.15682-5-brendanhiggins@google.com> In-Reply-To: From: Brendan Higgins Date: Wed, 24 Jun 2020 13:15:14 -0700 Message-ID: Subject: Re: [PATCH v3 4/7] init: main: add KUnit to kernel init Content-Type: text/plain; charset="UTF-8" Sender: linux-arch-owner@vger.kernel.org List-ID: To: Frank Rowand Cc: Jeff Dike , Richard Weinberger , Anton Ivanov , Arnd Bergmann , Kees Cook , Shuah Khan , Alan Maguire , Iurii Zaikin , David Gow , Andrew Morton , rppt@linux.ibm.com, Greg KH , Stephen Boyd , Logan Gunthorpe , Luis Chamberlain , linux-um , linux-arch@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux Kernel Mailing List , "open list:DOCUMENTATION" Message-ID: <20200624201514.Qb93C01HFS-XlSbRNqblshBNPJl3GEeFIPI5SBBQch4@z> On Mon, Mar 2, 2020 at 11:13 AM Frank Rowand wrote: Sorry it took so long to respond. I am reviving this patchset now, about to send out a new revision and I just saw this comment. > On 2/27/20 7:20 PM, Brendan Higgins wrote: > > Remove KUnit from init calls entirely, instead call directly from > > kernel_init(). > > > > Co-developed-by: Alan Maguire > > Signed-off-by: Alan Maguire > > Signed-off-by: Brendan Higgins > > Reviewed-by: Stephen Boyd > > --- > > include/kunit/test.h | 9 +++++++++ > > init/main.c | 4 ++++ > > lib/kunit/executor.c | 4 +--- > > 3 files changed, 14 insertions(+), 3 deletions(-) > > > > diff --git a/include/kunit/test.h b/include/kunit/test.h > > index 8a02f93a6b505..8689dd1459844 100644 > > --- a/include/kunit/test.h > > +++ b/include/kunit/test.h > > @@ -197,6 +197,15 @@ void kunit_init_test(struct kunit *test, const char *name); > > > > int kunit_run_tests(struct kunit_suite *suite); > > > > +#if IS_BUILTIN(CONFIG_KUNIT) > > I suspected this would not work if a unittest was builtin but CONFIG_KUNIT > was set to module. > > So I decided to experiment a bit to verify my assumptions (before applying > this patch series). I tried to set CONFIG_KUNIT to module, then set > CONFIG_KUNIT_EXAMPLE_TEST to built in. Kconfig does not let me do this > because KUNIT_EXAMPLE_TEST is inside a 'if KUNIT' in lib/kunit/Kconfig, > but instead switches KUNIT_EXAMPLE_TEST to a module, and warns that it > has done so. This was a bit of a surprise, but seems reasonable. > > So my next assumption is that the architecture of KUnit expects > each individual unit test config option to depend upon CONFIG_KUNIT. > If this is the case, please clearly document that requirement in > the KUnit documentation. Your assumption is correct. I will fix this in the Kconfig documentation in a separate patch. > > +int kunit_run_all_tests(void); > > +#else > > +static inline int kunit_run_all_tests(void) > > +{ > > + return 0; > > +} > > +#endif /* IS_BUILTIN(CONFIG_KUNIT) */ > > + > > /* > > * If a test suite is built-in, module_init() gets translated into > > * an initcall which we don't want as the idea is that for builtins > > diff --git a/init/main.c b/init/main.c > > index ee4947af823f3..7875a5c486dc4 100644 > > --- a/init/main.c > > +++ b/init/main.c > > @@ -104,6 +104,8 @@ > > #define CREATE_TRACE_POINTS > > #include > > > > +#include > > + > > static int kernel_init(void *); > > > > extern void init_IRQ(void); > > @@ -1444,6 +1446,8 @@ static noinline void __init kernel_init_freeable(void) > > > > do_basic_setup(); > > > > + kunit_run_all_tests(); > > + > > console_on_rootfs(); > > > > /* > > diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c > > index 6429927d598a5..b75a46c560847 100644 > > --- a/lib/kunit/executor.c > > +++ b/lib/kunit/executor.c > > @@ -11,7 +11,7 @@ extern struct kunit_suite * const * const __kunit_suites_end[]; > > > > #if IS_BUILTIN(CONFIG_KUNIT) > > > > -static int kunit_run_all_tests(void) > > +int kunit_run_all_tests(void) > > { > > struct kunit_suite * const * const *suites, * const *subsuite; > > bool has_test_failed = false; > > @@ -31,6 +31,4 @@ static int kunit_run_all_tests(void) > > return 0; > > } > > > > -late_initcall(kunit_run_all_tests); > > - > > #endif /* IS_BUILTIN(CONFIG_KUNIT) */ > > >