Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp867893ybt; Wed, 24 Jun 2020 13:17:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ74okTXvr8N0Lsws4KMERbYbxUWcsG0lzc0ZNehzyn+P9R+NODeK756Y9XL0BaxAHx2nF X-Received: by 2002:a17:906:ef2:: with SMTP id x18mr3133849eji.547.1593029874596; Wed, 24 Jun 2020 13:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593029874; cv=none; d=google.com; s=arc-20160816; b=oLvhUMfIM0pIiuYXnnZqUGAzja77bAyTTWcSr2sIMcQ0HSJGdiDRDfeM8GZkIW/r0R cepy95c/z05zaCt44BBoiL54WuxNpvtvwUEW5n9un98v0xK9WAJNZyMdV9sdHp5G/9xF yRAoPP1dJZFojIWVKySuQmRpJgMbv/ZCMUYXUoaEd+PFk5xPogP4uEI7EShWpb8NR8ML PyRdlNGYFftPOAV95xarXo6PMBJMSyiBM0vTXnEnnJvH6vpMqA30oj6lCiltcDTHTrJJ EdvZ0JDtRr4HsUu5KNAbgvVsg8HELNLHaw93UmWsWEGTOOuWGMfcH9RWT6FOV+Tsqk2x 69tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IdPEcGBnqX+qJ5FRufYsC8Fmx34kZgyoik6khE35S6c=; b=c6lu3FoF83G/8QJ3JJ7tFl9BO621JX17OLg8doS1M3uUbb2CnPT6W0vsU2u4TwPb2c vTf7vgMNUBxECYBt9bFbfSxSKnmQm/lCRs7kf9fUz4T5rSS52qTMpj5pq8f1/f42nvJU blTLJjTf4cUCyLJVBOXxbvn/Z0dULztqgXcDu8NqdZXitHkXnUuqE+c+FjirEhw6j33+ rf6G2YA7hZQcDE3TynMVeVmVYFN5qkL23qEvf0kNUbs1zhyYy4+brvPeg3b+ngARZUKx g/deMiYkkbOV2SkLK79eZTfa+hN11/PvgpZak9Xb5VLz9+8tKDKSu1UmkpcebY0VWSbF /bzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LAgCJBjw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pj20si13085828ejb.158.2020.06.24.13.17.30; Wed, 24 Jun 2020 13:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LAgCJBjw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2406385AbgFXUP2 (ORCPT + 99 others); Wed, 24 Jun 2020 16:15:28 -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-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) */ > > >