From patchwork Wed May 18 17:01:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Latypov X-Patchwork-Id: 12853885 X-Patchwork-Delegate: brendanhiggins@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24A32C433EF for ; Wed, 18 May 2022 17:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240690AbiERRBp (ORCPT ); Wed, 18 May 2022 13:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240686AbiERRBk (ORCPT ); Wed, 18 May 2022 13:01:40 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 168CB56C2A for ; Wed, 18 May 2022 10:01:39 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f8398e99dcso24332497b3.9 for ; Wed, 18 May 2022 10:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=21gji5A7fyf+LOH7W7vX2Ngr8AGXxxWBQWpGLTWRGhA=; b=GTzkF8O5vkR1Lt+Fnw7LR/ngt2HqSyPnypaoqbXSyP+l0zND+UX2I0KppXnl1YZi6I 03baXp65KNEbOp+bqVWwVIBpZpkzPzYSrsYgzkjBGT3tSZ1qmttFgx3AwVGDCbEdJ8Nk TRVb/htkvdsqFa/k2tSEAefow55INRy1eJMxSjlVtQrpBLjC1y3k6B15D8J+y15khDS0 3sZ/3NciSAL4YcN5zUE2nW3wbrdeS0l7Y3vSQwU/XD6RNkKP3vR2rqYFzdno8wUK2PBK 9BCc2PRT+x06Z+qc/Tx+Db/tL9sxXLOz5VyT8X+kLlGTQ3l0efVDXJKBgpDhevgDT24b ocEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=21gji5A7fyf+LOH7W7vX2Ngr8AGXxxWBQWpGLTWRGhA=; b=kTFd33DvDq4esA1fya9SK3jngRlbcddo3FX5cqu5RmVjFJWNbqycU6VlULgy7SLHLQ kAv6nW2KjngBIOnzhVcrmTTpkUK9glbhydrkUVaIV7BuBR/aK/5AKaZyVVc1BQkYOOsH ZK6RrQjjsdGsSM+SRp39v5PZb1izJLhAId388ar4kaqHXi2SJ/DmtpQO0xZ+fwK+r4h/ KXouXpxNaZZyYklBfTmlHgVIu1WEO7uk6cy2beJpSNcADrBfN+3s9Rc4GeMo8kw9qO5G sfQ+OkiP3Bl590aSKuIAubF5P5wF9yxpDsqTkpI9BWqv4mCZjmR9WyXzx/csDYDrkt8s CiJA== X-Gm-Message-State: AOAM533QhBK/q9A2PzYqq33rk55XhgBhwCa7Qjp5biWjch2okJYKeTa4 vrfsuYiRRd7d9NmKeROhDXNswPmn3n6n1g== X-Google-Smtp-Source: ABdhPJy5L9IdIUF+kc9lONmkwtmBOtrGteA3jV3FIp+O1wzAgxcgJV3U+0y/By+Qa0bPGIbZ2l3+jMPy66fGaw== X-Received: from dlatypov.svl.corp.google.com ([2620:15c:2cd:202:a94f:2cb3:f298:ec1b]) (user=dlatypov job=sendgmr) by 2002:a81:2f8c:0:b0:2fe:ed42:21ca with SMTP id v134-20020a812f8c000000b002feed4221camr399767ywv.120.1652893298194; Wed, 18 May 2022 10:01:38 -0700 (PDT) Date: Wed, 18 May 2022 10:01:22 -0700 In-Reply-To: <20220518170124.2849497-1-dlatypov@google.com> Message-Id: <20220518170124.2849497-2-dlatypov@google.com> Mime-Version: 1.0 References: <20220518170124.2849497-1-dlatypov@google.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog Subject: [PATCH 1/3] Documentation: kunit: fix example run_kunit func to allow spaces in args From: Daniel Latypov To: brendanhiggins@google.com, davidgow@google.com Cc: elver@google.com, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org, Daniel Latypov Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Without the quoting, the example will mess up invocations like $ run_kunit "Something with spaces" Note: this example isn't valid, but if ever a usecase arises where a flag argument might have spaces in it, it'll break. Signed-off-by: Daniel Latypov Reviewed-by: David Gow Reviewed-by: Brendan Higgins --- Documentation/dev-tools/kunit/running_tips.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/dev-tools/kunit/running_tips.rst b/Documentation/dev-tools/kunit/running_tips.rst index c36f6760087d..da8677c32aee 100644 --- a/Documentation/dev-tools/kunit/running_tips.rst +++ b/Documentation/dev-tools/kunit/running_tips.rst @@ -15,7 +15,7 @@ It can be handy to create a bash function like: .. code-block:: bash function run_kunit() { - ( cd "$(git rev-parse --show-toplevel)" && ./tools/testing/kunit/kunit.py run $@ ) + ( cd "$(git rev-parse --show-toplevel)" && ./tools/testing/kunit/kunit.py run "$@" ) } .. note:: From patchwork Wed May 18 17:01:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Latypov X-Patchwork-Id: 12853886 X-Patchwork-Delegate: brendanhiggins@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FBF4C4332F for ; Wed, 18 May 2022 17:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240695AbiERRBr (ORCPT ); Wed, 18 May 2022 13:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240688AbiERRBo (ORCPT ); Wed, 18 May 2022 13:01:44 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3F526B7D6 for ; Wed, 18 May 2022 10:01:40 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2ff17535eabso23927407b3.20 for ; Wed, 18 May 2022 10:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=4p2OIzyLZf5DSGNOpJEFrH/AUMGocyU2gKg4RrUCI6s=; b=o5OhYnQd0/SVCrvlR6BDzl8uSzC29hs7YQvNz7dWRteQ/kcph4lfVshtJMcGVo8NbR 8oPMuS2Sy3hBVX0NlOaNEA1jYg1VVcAyjjB5W5GCnTurc+o6G6BnalBX94/qqs6hCzLs DctERLk5noT2qeLVnzOhKgBlIYCrTVRrvYb9LRF1DFeA5aXdX1vveh0/ZLWm258Bg5QT AqtIL3PC+7Dwsphqra6Pf2FpK5aG362O8TacCzJwMfbncnPDgIOlO3qFPVubRSYuK8yT mDb8PkHBaX+sR03HvwUcwMLP0EOOi2RoiJjRaOz2RMUvBc/Af3lA3sg/1OMeK5n6OeR3 sTfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4p2OIzyLZf5DSGNOpJEFrH/AUMGocyU2gKg4RrUCI6s=; b=oNbbY8Oj4pffliueuxOFLIHZ5G9PxT77VWlKdE2daUKLKXgkQ3waQ+g9oVmgrAO0LR c64/JhWhrMIhNfDo/3IcCWYYoMGAmonLQ7zl+6inxlt1iugMM7cMV9ilhIr9nMTojrBp Cr1Wlm0Gpdtb9MD7l3bB8QWRrQjfzTxCy6jtwgFiMsx9sgBPxF6wD1LNCSfN40jJcK4z jrYtmka+vo9e3oWJdgLZqZyKPYeadb7SlfOhnUYy0zO7OgUjkYH0Kh7NqT5tC6LQAJGy KxUDeNfdYssJNwB3rPobfrSj1sSm8NOU0CReZZmSr4lBBwiVgQW+MU7+ejWyKLeWz33A yDkg== X-Gm-Message-State: AOAM533KjU7RQGw2NAe4TfH8rjXDivOsTSTVFPyRBT+HBhORXhuDVkaO ZRlq/IGmrUAEGLYuCkZ4UYr0d8wbqVBEhw== X-Google-Smtp-Source: ABdhPJwzQoL+Dq+U5iIHnbnBF+QHziVBDA7Opsu9u46q835S42QBPgAJVd2R6NkKdXe9e7Mt9HkW5TVwAq+D1Q== X-Received: from dlatypov.svl.corp.google.com ([2620:15c:2cd:202:a94f:2cb3:f298:ec1b]) (user=dlatypov job=sendgmr) by 2002:a81:bb49:0:b0:2fe:e07b:9a6c with SMTP id a9-20020a81bb49000000b002fee07b9a6cmr415296ywl.136.1652893300072; Wed, 18 May 2022 10:01:40 -0700 (PDT) Date: Wed, 18 May 2022 10:01:23 -0700 In-Reply-To: <20220518170124.2849497-1-dlatypov@google.com> Message-Id: <20220518170124.2849497-3-dlatypov@google.com> Mime-Version: 1.0 References: <20220518170124.2849497-1-dlatypov@google.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog Subject: [PATCH 2/3] kunit: tool: simplify creating LinuxSourceTreeOperations From: Daniel Latypov To: brendanhiggins@google.com, davidgow@google.com Cc: elver@google.com, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org, Daniel Latypov Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Drop get_source_tree_ops() and just call what used to be get_source_tree_ops_from_qemu_config() in both cases. Also rename the functions to have shorter names and add a "_" prefix to note they're not meant to be used outside this function. Signed-off-by: Daniel Latypov Reviewed-by: David Gow Reviewed-by: Brendan Higgins --- tools/testing/kunit/kunit_kernel.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index 8bc8305ba817..e93f07ac0af1 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -178,19 +178,16 @@ def get_old_kunitconfig_path(build_dir: str) -> str: def get_outfile_path(build_dir: str) -> str: return os.path.join(build_dir, OUTFILE_PATH) -def get_source_tree_ops(arch: str, cross_compile: Optional[str]) -> LinuxSourceTreeOperations: +def _default_qemu_config_path(arch: str) -> str: config_path = os.path.join(QEMU_CONFIGS_DIR, arch + '.py') - if arch == 'um': - return LinuxSourceTreeOperationsUml(cross_compile=cross_compile) if os.path.isfile(config_path): - return get_source_tree_ops_from_qemu_config(config_path, cross_compile)[1] + return config_path options = [f[:-3] for f in os.listdir(QEMU_CONFIGS_DIR) if f.endswith('.py')] raise ConfigError(arch + ' is not a valid arch, options are ' + str(sorted(options))) -def get_source_tree_ops_from_qemu_config(config_path: str, - cross_compile: Optional[str]) -> Tuple[ - str, LinuxSourceTreeOperations]: +def _get_qemu_ops(config_path: str, + cross_compile: Optional[str]) -> Tuple[str, LinuxSourceTreeOperations]: # The module name/path has very little to do with where the actual file # exists (I learned this through experimentation and could not find it # anywhere in the Python documentation). @@ -226,11 +223,14 @@ class LinuxSourceTree: qemu_config_path=None) -> None: signal.signal(signal.SIGINT, self.signal_handler) if qemu_config_path: - self._arch, self._ops = get_source_tree_ops_from_qemu_config( - qemu_config_path, cross_compile) + self._arch, self._ops = _get_qemu_ops(qemu_config_path, cross_compile) else: self._arch = 'um' if arch is None else arch - self._ops = get_source_tree_ops(self._arch, cross_compile) + if self._arch == 'um': + self._ops = LinuxSourceTreeOperationsUml(cross_compile=cross_compile) + else: + qemu_config_path = _default_qemu_config_path(self._arch) + _, self._ops = _get_qemu_ops(qemu_config_path, cross_compile) if kunitconfig_path: if os.path.isdir(kunitconfig_path): From patchwork Wed May 18 17:01:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Latypov X-Patchwork-Id: 12853887 X-Patchwork-Delegate: brendanhiggins@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFF39C433FE for ; Wed, 18 May 2022 17:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240693AbiERRBr (ORCPT ); Wed, 18 May 2022 13:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240678AbiERRBo (ORCPT ); Wed, 18 May 2022 13:01:44 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD2A9D4C8 for ; Wed, 18 May 2022 10:01:42 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f7dbceab08so24083587b3.10 for ; Wed, 18 May 2022 10:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pKq+ukUxGkB6N6xyDoqejZhxcnXMWWmls9VVeK1R/Co=; b=koWCgoV1+MzTaKj/y22npaD+DdjzHh6Dbk7mkNniJz6uKmYvQ9qXIUXqNAzit8kFgu m7zqD0ahN9O2rZeJd3P37WQrl4F9/18LjkVzjy2yPb8Z9nq38rVRPpkZ9S55wW2XrqZt DeWqVQ56J4Z/f+AftuozcAsFA7KCH79iIEUDMzbUMeQBnSXjiBGTeZcbC10noIXYdN3W LJKzsW4QXHOll7EiuoF5BOI9oycp6Twn90IFYWHGxbmqB869wfWN6DyGimoaI8EjvzAj gCascF0By6cm3O9mu9P0UKv/W0Qd7DRczimmpmOWkLWNyfUU7HeVjUzdKAyVCdl6cMDW 7mhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pKq+ukUxGkB6N6xyDoqejZhxcnXMWWmls9VVeK1R/Co=; b=rpTcbd5mcK6ZgFIkzbuR21s8pzY5IJuApqXjLQ0jzdF9shddxcvY0WNnLBsNJKDEKt h7ruP8lRq8XQWumiDGUKcUJTrcqAKFgu15fE7nmiW3rqI9Ct5gWkIhk2+9j5yLou3xDo RoWpH1efn5Dxj35N5ekM3Q6KOgJnDSgnE5i5uKVLFuyMLWjxt3DMztbozUHKTD/CAftb 05IfOjrhmL8nE7Xlu39SaY1X6ECH+H8u7wFd7FH3Qcj8G04/IHndPbTHU51K5Cjhn+w5 Sld+q/F4t3m8n6L0RoRg7LJHnEnOGExz0rw8SVLWQmx92MSl0cL7qSb6oaNyfmiTUp6w btgg== X-Gm-Message-State: AOAM531THmFtu0A4Sw3sMBR+joNfvkRJLeAXKEg1VPDS68kGtIPh+6ef 37DI/EqokNQ4UcoIAK33//G8t7JxPVJcHQ== X-Google-Smtp-Source: ABdhPJyuqW2JlcYLahFvkPX3B0HO+rtDjIyM60zRUbOt0Biapvoofm0Ldrxjk1Y+yn8ZRVVPYC+nLz7dDY8KOw== X-Received: from dlatypov.svl.corp.google.com ([2620:15c:2cd:202:a94f:2cb3:f298:ec1b]) (user=dlatypov job=sendgmr) by 2002:a25:186:0:b0:64d:7067:226 with SMTP id 128-20020a250186000000b0064d70670226mr560357ybb.446.1652893302212; Wed, 18 May 2022 10:01:42 -0700 (PDT) Date: Wed, 18 May 2022 10:01:24 -0700 In-Reply-To: <20220518170124.2849497-1-dlatypov@google.com> Message-Id: <20220518170124.2849497-4-dlatypov@google.com> Mime-Version: 1.0 References: <20220518170124.2849497-1-dlatypov@google.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog Subject: [PATCH 3/3] kunit: tool: introduce --qemu_args From: Daniel Latypov To: brendanhiggins@google.com, davidgow@google.com Cc: elver@google.com, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org, Daniel Latypov Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Example usage: $ ./tools/testing/kunit/kunit.py run --arch=x86_64 \ --kconfig_add=CONFIG_SMP=y --qemu_args='-smp 8' Looking in the test.log, one can see > smp: Bringing up secondary CPUs ... > .... node #0, CPUs: #1 #2 #3 #4 #5 #6 #7 > smp: Brought up 1 node, 8 CPUs This flag would allow people to make tweaks like this without having to create custom qemu_config files. For consistency with --kernel_args, we allow users to repeat this argument, e.g. you can tack on a --qemu_args='-m 2048', or you could just append it to the first string ('-smp 8 -m 2048'). Signed-off-by: Daniel Latypov Reviewed-by: David Gow Reviewed-by: Brendan Higgins --- tools/testing/kunit/kunit.py | 14 +++++++++++++- tools/testing/kunit/kunit_kernel.py | 10 +++++++--- tools/testing/kunit/kunit_tool_test.py | 20 +++++++++++++++++--- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index 8a90d80ee66e..e01c7964f744 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -10,6 +10,7 @@ import argparse import os import re +import shlex import sys import time @@ -323,6 +324,10 @@ def add_common_opts(parser) -> None: 'a QemuArchParams object.'), type=str, metavar='FILE') + parser.add_argument('--qemu_args', + help='Additional QEMU arguments, e.g. "-smp 8"', + action='append', metavar='') + def add_build_opts(parser) -> None: parser.add_argument('--jobs', help='As in the make command, "Specifies the number of ' @@ -368,12 +373,19 @@ def add_parse_opts(parser) -> None: def tree_from_args(cli_args: argparse.Namespace) -> kunit_kernel.LinuxSourceTree: """Returns a LinuxSourceTree based on the user's arguments.""" + # Allow users to specify multiple arguments in one string, e.g. '-smp 8' + qemu_args: List[str] = [] + if cli_args.qemu_args: + for arg in cli_args.qemu_args: + qemu_args.extend(shlex.split(arg)) + return kunit_kernel.LinuxSourceTree(cli_args.build_dir, kunitconfig_path=cli_args.kunitconfig, kconfig_add=cli_args.kconfig_add, arch=cli_args.arch, cross_compile=cli_args.cross_compile, - qemu_config_path=cli_args.qemu_config) + qemu_config_path=cli_args.qemu_config, + extra_qemu_args=qemu_args) def main(argv): diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index e93f07ac0af1..a791073d25f9 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -187,6 +187,7 @@ def _default_qemu_config_path(arch: str) -> str: raise ConfigError(arch + ' is not a valid arch, options are ' + str(sorted(options))) def _get_qemu_ops(config_path: str, + extra_qemu_args: Optional[List[str]], cross_compile: Optional[str]) -> Tuple[str, LinuxSourceTreeOperations]: # The module name/path has very little to do with where the actual file # exists (I learned this through experimentation and could not find it @@ -207,6 +208,8 @@ def _get_qemu_ops(config_path: str, if not hasattr(config, 'QEMU_ARCH'): raise ValueError('qemu_config module missing "QEMU_ARCH": ' + config_path) params: qemu_config.QemuArchParams = config.QEMU_ARCH # type: ignore + if extra_qemu_args: + params.extra_qemu_params.extend(extra_qemu_args) return params.linux_arch, LinuxSourceTreeOperationsQemu( params, cross_compile=cross_compile) @@ -220,17 +223,18 @@ class LinuxSourceTree: kconfig_add: Optional[List[str]]=None, arch=None, cross_compile=None, - qemu_config_path=None) -> None: + qemu_config_path=None, + extra_qemu_args=None) -> None: signal.signal(signal.SIGINT, self.signal_handler) if qemu_config_path: - self._arch, self._ops = _get_qemu_ops(qemu_config_path, cross_compile) + self._arch, self._ops = _get_qemu_ops(qemu_config_path, extra_qemu_args, cross_compile) else: self._arch = 'um' if arch is None else arch if self._arch == 'um': self._ops = LinuxSourceTreeOperationsUml(cross_compile=cross_compile) else: qemu_config_path = _default_qemu_config_path(self._arch) - _, self._ops = _get_qemu_ops(qemu_config_path, cross_compile) + _, self._ops = _get_qemu_ops(qemu_config_path, extra_qemu_args, cross_compile) if kunitconfig_path: if os.path.isdir(kunitconfig_path): diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py index baee11d96474..7fe5c8b0fb57 100755 --- a/tools/testing/kunit/kunit_tool_test.py +++ b/tools/testing/kunit/kunit_tool_test.py @@ -649,7 +649,8 @@ class KUnitMainTest(unittest.TestCase): kconfig_add=None, arch='um', cross_compile=None, - qemu_config_path=None) + qemu_config_path=None, + extra_qemu_args=[]) def test_config_kunitconfig(self): kunit.main(['config', '--kunitconfig=mykunitconfig']) @@ -659,7 +660,8 @@ class KUnitMainTest(unittest.TestCase): kconfig_add=None, arch='um', cross_compile=None, - qemu_config_path=None) + qemu_config_path=None, + extra_qemu_args=[]) def test_run_kconfig_add(self): kunit.main(['run', '--kconfig_add=CONFIG_KASAN=y', '--kconfig_add=CONFIG_KCSAN=y']) @@ -669,7 +671,19 @@ class KUnitMainTest(unittest.TestCase): kconfig_add=['CONFIG_KASAN=y', 'CONFIG_KCSAN=y'], arch='um', cross_compile=None, - qemu_config_path=None) + qemu_config_path=None, + extra_qemu_args=[]) + + def test_run_qemu_args(self): + kunit.main(['run', '--arch=x86_64', '--qemu_args', '-m 2048']) + # Just verify that we parsed and initialized it correctly here. + self.mock_linux_init.assert_called_once_with('.kunit', + kunitconfig_path=None, + kconfig_add=None, + arch='x86_64', + cross_compile=None, + qemu_config_path=None, + extra_qemu_args=['-m', '2048']) def test_run_kernel_args(self): kunit.main(['run', '--kernel_args=a=1', '--kernel_args=b=2'])