Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp11306pxv; Wed, 14 Jul 2021 18:15:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUekx4EIz6kq2HLZkIz1kBEaGo5p1h/rcQuoeOficQDviqHl+DRkSqJ/ZX3S6CEuQKZBdf X-Received: by 2002:a05:6402:1a25:: with SMTP id be5mr1807507edb.123.1626311744992; Wed, 14 Jul 2021 18:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626311744; cv=none; d=google.com; s=arc-20160816; b=pXZr+xZxnfP3fffWy3qpdAaxLnpqr3XCHwkmrW1j3oX9BYAksh8+pMk6M/T80GGSjW rrZEYf6pPE2jXjiw3a3X3Y//u7xs1x0PJ6VhTx8Lt/cs4NdlmX4iHKVNGyiNaZyXOl6Z 3TduPKwf1t/CuP/BtYhVaDHpwbZ6ZnX2/AyLt9OJVxLIG8dLEoPk2j9h87rvIvbHNyhf FHasK5BZaiAsj/QT6wv+KRMnDqGlmkPtIp4B/Knihm1D+WQPIbIpCBIwL25SsMx+vGDV 7ZKyB60P7ZQYcw4tEIR5AB3yAhzmBLOep5E7W5YMOB5kAFiDrAKLN7feh3n5edFGC7HE LtvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=DqMZpra5Z3HRb0F6ypU+rLLPpHVX8T6pVPn9AM2au8E=; b=GY4jLVeMvo9tqq3vpYfY2DAvf75Em8Tf8V4qTt48b4C5ywh1xw/5HaCqJy9QN3EkQB gMrUe28gpip6fikUz1rjuEsMWofsyHzTU8XYceGgJ3nFfzO3abH7w8ce2HcnxTRZ9lbj ViBOoN3pmp/3koKR/Vd4Mhwx0rW8Y/2ibIeFl41cdbaixnAft8zRt45qi3NyZbEN0cAZ h2vcl33IeehWzV+RFnsyIPm2/EhW50DRmzKghvuHVNGGr2qJsIYe5bpeEPG9SPvW3lVe evZl0Upjsd+WTG28vc9xo+YgOJ9EIFdXq/dI6nPYrmTlmINswOHilGvsjS+Xmf8p967N agOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ofaJESsl; 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 p23si4792770edw.135.2021.07.14.18.15.22; Wed, 14 Jul 2021 18:15:44 -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=ofaJESsl; 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 S236253AbhGNXSH (ORCPT + 99 others); Wed, 14 Jul 2021 19:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbhGNXSG (ORCPT ); Wed, 14 Jul 2021 19:18:06 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C2EDC06175F for ; Wed, 14 Jul 2021 16:15:14 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id w5-20020a0569021005b029055b51419c7dso4862620ybt.23 for ; Wed, 14 Jul 2021 16:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=DqMZpra5Z3HRb0F6ypU+rLLPpHVX8T6pVPn9AM2au8E=; b=ofaJESsl8XfjG0V8ICG0P2YoedRTAkO26xasRPXkDyVVOt7Dw1IxYMkY32FsVtu1iu XzTV3h8H1rSzW8FOJKuYVjyGyyzvKa5kBX2vwMlhGcneIVOSpIBLldJ1udHVWTVh8FpH snmFEJqDfRJ7/wT8OhdRhbV/eUZkVlhLXbcNlWCRy4/apFPpB5O3q+LVHUHRSEH7AkjE MaAn1XGaqgCgF9VXQg2xF8V5jVCkcb4Yyptj3YiLKhxdqVo7/BGc4Qn6PRa6No1aaTPI CvgGbDr2Jd2CNdY4flP1utFxoRtfK/T39+60I3v9Idy9H5QtPo2Rlm5tXAQT75f1i9w/ W0fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=DqMZpra5Z3HRb0F6ypU+rLLPpHVX8T6pVPn9AM2au8E=; b=G6jPI8WL2aEg+wrz2A9m5oZgSLcPV7b0E+hyQoGWYbSpf3SMdOwpMRo0XVUlEfucr1 R8XtLsCYNpQtTXSRKU6FBKJOmicQeCoHrrtaLYfWOcRaomQbg56wTIVT6W84F21V0N98 7g1NDMS8hRYL70hFv0iHzX17GUsOJNjbBmjocoG35xMv5ookSpWnWyyvQe6vKwGPr45x q6caPwDR4+WFyIqsoVxI8z8H8hjNqwCDc0LmQiJ2aQ4ljGwVoTCAkvwXmbq77xo3EEOM o8o5Yf03HHu/B1PluIQvmhKBaqgEyid6U3crKo2beqkquOYUvM5no8vZeSBXQG40xIEW 0yFA== X-Gm-Message-State: AOAM530SSP9h/ejZ7rHQjKVaj60BsFD1II7odcfkfM58MIilF8Tw71ey kl1/irsDZdJTZPVXWt+azMCkXag4q+gdEA== X-Received: from dlatypov.svl.corp.google.com ([2620:15c:2cd:202:1109:2a1e:ff11:1796]) (user=dlatypov job=sendgmr) by 2002:a25:68ce:: with SMTP id d197mr500955ybc.317.1626304513677; Wed, 14 Jul 2021 16:15:13 -0700 (PDT) Date: Wed, 14 Jul 2021 16:15:06 -0700 Message-Id: <20210714231506.886386-1-dlatypov@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog Subject: [PATCH v2] kunit: tool: add --kernel_args to allow setting module params From: Daniel Latypov To: brendanhiggins@google.com, davidgow@google.com Cc: linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org, Daniel Latypov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kunit.py currently does not make it possible for users to specify module parameters (/kernel arguments more generally) unless one directly tweaks the kunit.py code itself. This hasn't mattered much so far, but this would make it easier to port existing tests that expose module parameters over to KUnit and/or let current KUnit tests take advantage of them. Tested using an kunit internal parameter: $ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit \ --kernel_args=kunit.filter_glob=kunit_status ... Testing complete. 2 tests run. 0 failed. 0 crashed. 0 skipped. Signed-off-by: Daniel Latypov --- v1 -> v2: s/kernel_arg/kernel_args in documentation --- Documentation/dev-tools/kunit/running_tips.rst | 10 ++++++++++ tools/testing/kunit/kunit.py | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Documentation/dev-tools/kunit/running_tips.rst b/Documentation/dev-tools/kunit/running_tips.rst index 7d99386cf94a..ebaaa2764207 100644 --- a/Documentation/dev-tools/kunit/running_tips.rst +++ b/Documentation/dev-tools/kunit/running_tips.rst @@ -80,6 +80,16 @@ file ``.kunitconfig``, you can just pass in the dir, e.g. automagically, but tests could theoretically depend on incompatible options, so handling that would be tricky. +Setting kernel commandline parameters +------------------------------------- + +You can use ``--kernel_args`` to pass arbitrary kernel arguments, e.g. + +.. code-block:: bash + + $ ./tools/testing/kunit/kunit.py run --kernel_args=param=42 --kernel_args=param2=false + + Generating code coverage reports under UML ------------------------------------------ diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index be8d8d4a4e08..03f3bc406955 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -28,12 +28,13 @@ KunitBuildRequest = namedtuple('KunitBuildRequest', ['jobs', 'build_dir', 'alltests', 'make_options']) KunitExecRequest = namedtuple('KunitExecRequest', - ['timeout', 'build_dir', 'alltests', 'filter_glob']) + ['timeout', 'build_dir', 'alltests', + 'filter_glob', 'kernel_args']) KunitParseRequest = namedtuple('KunitParseRequest', ['raw_output', 'input_data', 'build_dir', 'json']) KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', 'build_dir', 'alltests', 'filter_glob', - 'json', 'make_options']) + 'kernel_args', 'json', 'make_options']) KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] @@ -92,6 +93,7 @@ def exec_tests(linux: kunit_kernel.LinuxSourceTree, kunit_parser.print_with_timestamp('Starting KUnit Kernel ...') test_start = time.time() result = linux.run_kernel( + args=request.kernel_args, timeout=None if request.alltests else request.timeout, filter_glob=request.filter_glob, build_dir=request.build_dir) @@ -150,7 +152,8 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree, return build_result exec_request = KunitExecRequest(request.timeout, request.build_dir, - request.alltests, request.filter_glob) + request.alltests, request.filter_glob, + request.kernel_args) exec_result = exec_tests(linux, exec_request) if exec_result.status != KunitStatus.SUCCESS: return exec_result @@ -236,6 +239,9 @@ def add_exec_opts(parser) -> None: nargs='?', default='', metavar='filter_glob') + parser.add_argument('--kernel_args', + help='Kernel command-line parameters. Maybe be repeated', + action='append') def add_parse_opts(parser) -> None: parser.add_argument('--raw_output', help='don\'t format output from kernel', @@ -307,6 +313,7 @@ def main(argv, linux=None): cli_args.build_dir, cli_args.alltests, cli_args.filter_glob, + cli_args.kernel_args, cli_args.json, cli_args.make_options) result = run_tests(linux, request) @@ -361,7 +368,8 @@ def main(argv, linux=None): exec_request = KunitExecRequest(cli_args.timeout, cli_args.build_dir, cli_args.alltests, - cli_args.filter_glob) + cli_args.filter_glob, + cli_args.kernel_args) exec_result = exec_tests(linux, exec_request) parse_request = KunitParseRequest(cli_args.raw_output, exec_result.result, base-commit: 8096acd7442e613fad0354fc8dfdb2003cceea0b -- 2.32.0.93.g670b81a890-goog