Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp147253pxj; Wed, 26 May 2021 18:45:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ7vIe0nMOQIR5tDlaTunwshK2nlv2861EeO+6/4g1meht5XGZHzRJ25nPrUaED/IOLdAq X-Received: by 2002:a05:6602:5cd:: with SMTP id w13mr878820iox.185.1622079915581; Wed, 26 May 2021 18:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622079915; cv=none; d=google.com; s=arc-20160816; b=rnnjn82Rrrv7CaMABH7wV904Uyy2nQX0nfHGCmCxA531WvyKinecRE9+YvWkkuooh1 a2RTR4HFlWhyf1InyYGyggAclxPmZ6R7vhXmjb3/WPUa39y7jn7MbKDmcCV1kIgyXCTo 9i3sipKQqomxYwZBqMI15sjySfLRLthIJXRsKyPhLeKiXP0KFdCarPlEhzMXWVU2HsOs kmDO6R3MPVzPyL+uAknJ/VxFvuqDYZfE89E2iLsNvotvc8mRKNksOlUfqGDeMh2ciWbC Q+u59WxIyqUxuI3qqkZgmJKR3biVd7HsgsKfxcUbY+yZmLANSgNqmHBWuIOLvbY7SLSw Y0Mw== 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=ob5N3fCbbDLB0UERbmW+vRDN/1QFz9ChAAVkpFKx6WE=; b=V7zh6xSW+yJDTB6HD6sV+HMaOylxH1XYIx+aaWwx0+9MYa8Y6Yk/IKYCguqUOoexuw WYQJRLEcLPKHuwwLqsCk25xue3zq6IzuDMVwMmlL4myJn5MHKRSrJOD3enrhzAzgRx7Q g4CMgHPGDuuFSeN5F5rzCGNRJ/ZTbKp4OfiRt02PIKE69t7OrSGk0MV4Bi4Goh4zyNwe SlKHBT509+ro9/axf2ANicq/K+YYKbL2K9IPn0r+SybeMi16cUdzGSRz66kwKkBXnFqg a+ZNbTVdEMWgfl28m7RX3VKeN6JDd4H84n+G70vcXKf3Zv6c56Guqv4YIhWbc180s6uc Z7+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PVRxPnxO; 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 d70si1026319iog.4.2021.05.26.18.45.01; Wed, 26 May 2021 18:45:15 -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=PVRxPnxO; 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 S233044AbhE0AzV (ORCPT + 99 others); Wed, 26 May 2021 20:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232692AbhE0AzU (ORCPT ); Wed, 26 May 2021 20:55:20 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E08CC061574 for ; Wed, 26 May 2021 17:53:47 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id w2so2615361ilo.7 for ; Wed, 26 May 2021 17:53:47 -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=ob5N3fCbbDLB0UERbmW+vRDN/1QFz9ChAAVkpFKx6WE=; b=PVRxPnxOEA+/JYbCOrw8gof/L0tDYA6KH+myRNCeNYJgvRZnXm7YSDr1t89NTga/hc ijECgrQkelx4cpC544ttqJR0QAVvxmRs+dcOJPy4A3W4WMcyX4l+ncMQx6L7QR5uqMzf RbQJkAG97zN9XoffEzawuX9uYdxNjc4G2ZQ/pKTdnbhlBMath7DaX7LzRHGFGlfqPEfP S3gS1OXtU2IkFHM+Y5AOHGuMkS+L5b6VmksQO5Lw/52GzjtcQOOEXSTUobgsEBn1xZAo 61bif5xinqeibBnCUHQTjTW1VcBiM6zpvtUTIe+BS1od64d0+I+TSJeeNJ9TeW1+pwDi hKiQ== 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=ob5N3fCbbDLB0UERbmW+vRDN/1QFz9ChAAVkpFKx6WE=; b=UGUR3HROQyowBT0HWm52xGkdQ4ExZwyjw9UTk8deWPsAmz7Jmuwk1vnk1dLwG3pEBK K6pjJqSWkHwhlJg1cXIl7Jo01LmYn3ByobW8YFIyg5c4KzXeir4KXCRBVv+fDidjjR7b FYztOQpjwmmenBMh6iRbZ7yPEqN2wM+YQlry95g53GFoJvgbHNYDJer7maff6I3pIDyn 8TjWqMpwPXmoahUZFeN2NWUpwTYDczZNbpt+DYIY+gWQhfuS09VnVDVzLO8tlv9qHovE khTQsEOo/xM5UDdOn1QAPQnI2zoYehpXtQgz7GZ57n19mVtNCn6YAGftqc/1NOEA0928 slPA== X-Gm-Message-State: AOAM533EJbMnPCmDHRUaDUl1WRNxjS9Ooz9LM7dezcMyVlMUDt9c5lq0 pFMQ9VbRPwqhpH7BvQ0LhgIUvtrFFNlThISbp0szeQ== X-Received: by 2002:a05:6e02:2188:: with SMTP id j8mr871603ila.194.1622076826115; Wed, 26 May 2021 17:53:46 -0700 (PDT) MIME-Version: 1.0 References: <20210526212407.2753879-1-brendanhiggins@google.com> <20210526212407.2753879-2-brendanhiggins@google.com> In-Reply-To: <20210526212407.2753879-2-brendanhiggins@google.com> From: Daniel Latypov Date: Wed, 26 May 2021 17:53:34 -0700 Message-ID: Subject: Re: [PATCH v2 1/4] kunit: Add 'kunit_shutdown' option To: Brendan Higgins Cc: shuah , David Gow , "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux Kernel Mailing List , Jonathan Corbet , "open list:DOCUMENTATION" , Stephen Boyd , Kees Cook , Frank Rowand Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 26, 2021 at 2:24 PM Brendan Higgins wrote: > > From: David Gow > > Add a new kernel command-line option, 'kunit_shutdown', which allows the > user to specify that the kernel poweroff, halt, or reboot after > completing all KUnit tests; this is very handy for running KUnit tests > on UML or a VM so that the UML/VM process exits cleanly immediately > after running all tests without needing a special initramfs. > > Signed-off-by: David Gow > Signed-off-by: Brendan Higgins > Reviewed-by: Stephen Boyd > Tested-By: Daniel Latypov Reviewed-by: Daniel Latypov Looks good, one optional nit below. Also, I tested this again on top of 5.13-r4 (7ac3a1c1ae51 ("Merge tag 'mtd/fixes-for-5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux")) $ echo -e "\nCONFIG_DEBUG_KERNEL=y\nCONFIG_DEBUG_INFO=y\nCONFIG_GCOV=y" >> .kunit/.kunitconfig $ run_kunit --make_options=CC=/usr/bin/gcc-6 $ Overall coverage rate: lines......: 13.8% (17286 of 125320 lines) functions..: 15.8% (1790 of 11336 functions) So coverage still seems to be fixed, no need to comment out the uml_abort() anymore and this sidesteps whatever weird issue I started running into these past few weeks. So that's very exciting. > --- > lib/kunit/executor.c | 20 ++++++++++++++++++++ > tools/testing/kunit/kunit_kernel.py | 2 +- > tools/testing/kunit/kunit_parser.py | 2 +- > 3 files changed, 22 insertions(+), 2 deletions(-) > > diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c > index 15832ed446685..7db619624437c 100644 > --- a/lib/kunit/executor.c > +++ b/lib/kunit/executor.c > @@ -1,5 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0 > > +#include > #include > #include > #include > @@ -18,6 +19,9 @@ module_param(filter_glob, charp, 0); > MODULE_PARM_DESC(filter_glob, > "Filter which KUnit test suites run at boot-time, e.g. list*"); > > +static char *kunit_shutdown; > +core_param(kunit_shutdown, kunit_shutdown, charp, 0644); > + > static struct kunit_suite * const * > kunit_filter_subsuite(struct kunit_suite * const * const subsuite) > { > @@ -82,6 +86,20 @@ static struct suite_set kunit_filter_suites(void) > return filtered; > } > > +static void kunit_handle_shutdown(void) > +{ > + if (!kunit_shutdown) > + return; > + > + if (!strcmp(kunit_shutdown, "poweroff")) > + kernel_power_off(); > + else if (!strcmp(kunit_shutdown, "halt")) > + kernel_halt(); > + else if (!strcmp(kunit_shutdown, "reboot")) > + kernel_restart(NULL); nit: should we complain about an unknown option here? > + > +} > + > static void kunit_print_tap_header(struct suite_set *suite_set) > { > struct kunit_suite * const * const *suites, * const *subsuite; > @@ -112,6 +130,8 @@ int kunit_run_all_tests(void) > kfree(suite_set.start); > } > > + kunit_handle_shutdown(); > + > return 0; > } > > diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py > index 89a7d4024e878..dbbceaee12305 100644 > --- a/tools/testing/kunit/kunit_kernel.py > +++ b/tools/testing/kunit/kunit_kernel.py > @@ -208,7 +208,7 @@ class LinuxSourceTree(object): > def run_kernel(self, args=None, build_dir='', filter_glob='', timeout=None) -> Iterator[str]: > if not args: > args = [] > - args.extend(['mem=1G', 'console=tty']) > + args.extend(['mem=1G', 'console=tty', 'kunit_shutdown=halt']) > if filter_glob: > args.append('kunit.filter_glob='+filter_glob) > self._ops.linux_bin(args, timeout, build_dir) > diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py > index e8bcc139702e2..8d8d4d70b39dd 100644 > --- a/tools/testing/kunit/kunit_parser.py > +++ b/tools/testing/kunit/kunit_parser.py > @@ -49,7 +49,7 @@ class TestStatus(Enum): > > kunit_start_re = re.compile(r'TAP version [0-9]+$') > kunit_end_re = re.compile('(List of all partitions:|' > - 'Kernel panic - not syncing: VFS:)') > + 'Kernel panic - not syncing: VFS:|reboot: System halted)') > > def isolate_kunit_output(kernel_output) -> Iterator[str]: > started = False > -- > 2.31.1.818.g46aad6cb9e-goog >