Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp188753iog; Fri, 24 Jun 2022 02:00:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s4UZCuU4Uh8u1OQiphM3nFWqI+3yoji++6o7Ic/LrDrsL1FPlvn0nSg65RMB2VpZ8InkEl X-Received: by 2002:a17:906:149b:b0:726:2968:e32a with SMTP id x27-20020a170906149b00b007262968e32amr6238529ejc.71.1656061220033; Fri, 24 Jun 2022 02:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656061220; cv=none; d=google.com; s=arc-20160816; b=gDC80Jvyv9mgUTjYkRCPxGvdAsJ1N2yAyBoBP/Eh0xZwUeyFnQEgOZ6PzdkFW5L38J Lo6fGFE3z4XgAonDeCGxCtlLSby5yWPG+EzaoOjLHVThPp3OYmCVzCiJxoWD0BzavlBq k5FCHr/2oe3y1RSEl/SRxN3lA6v/kRUYjGRtb90nEipGkrVHAz5+DALrgTC1hZcynmxO LHGiTgxv3E1RbkwNk6SikQiqRzKaHLkZSP13Ak806h3j9IzJ+se40PKEh4rdG7m8WNYy /qaiQWUJYahjKRYgnuOM9ZQNylDDf1lJo9fKZso941V9h4SZoXTNyryBRzmRkDkKesaV 2oEg== 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=71G3cfA5PBAKD0oF5OXbLK3/0rhXG8br391sycZlj8g=; b=Dg56z9Ovb55Y0teRjNbWW8xTB/gDFbosbxI7WrrDl6SBQpQ27qrPmvlrRR9vpjLkFP gM0CLK2dvPJh3xjYlD0R683SL4mMiMSXPChKWPGggpWHnihauBIBwVOOALVhBGUpQhbq 68OY6sj5Vg9GSgCRmtipAplsXRYJO5PmNtuKRFaLnpcrbpxQT2d+3RJYklqNZMpcb8Qe eVZVzO7AXlsuNpUpY1TSS5yqCL1/WQ5uQ8hBUSieXvK2UmUVerxxNYYPxC+FMN4wz7rF EYMWgsobgOTl7eHF0Xh4Lf6egR3cflGQiwmCd1+mxJEd51UCgzH9ASLi4aARlugpQH0y bldQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VFRYLEdS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt22-20020a170906f21600b00722e214e763si1730356ejb.633.2022.06.24.01.59.54; Fri, 24 Jun 2022 02:00:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VFRYLEdS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229925AbiFXIoJ (ORCPT + 99 others); Fri, 24 Jun 2022 04:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbiFXIoI (ORCPT ); Fri, 24 Jun 2022 04:44:08 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D06004F1C5 for ; Fri, 24 Jun 2022 01:44:06 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2dc7bdd666fso16544127b3.7 for ; Fri, 24 Jun 2022 01:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=71G3cfA5PBAKD0oF5OXbLK3/0rhXG8br391sycZlj8g=; b=VFRYLEdS0b6+2/SNRmN7NEt+1cayRbIyH+/liE9mT0KhTuKIvuO5zzRzedzFqX5j1Z f/IkR/Xrjgmz2fgNVgOgEiCECILWOa6MbBF7JAq/bX5TW4KhKb9GhK/6GeTRqX+efRaP CKHr5yTZWXOQdkCnGKrizG3p3dibqYZzXHGhi170jA8/tAx/T/3ojzQ/YRg0gNKGAdTf 9XOTd6Oihx8cF4yX/w+V30Q80ZxxbKxwfcLYfJVmFP7MSN3lA1qo55kcj4v0vWMvCARF YnC4J7kWn3nvCcC2K1a8kFG1SAgJLjsX0Qk5gmihONZsNwFJKPetrx4Cc5bM2BCcUyZh W84Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=71G3cfA5PBAKD0oF5OXbLK3/0rhXG8br391sycZlj8g=; b=h7mzG6bHFp8Z3P4hugnTGRapbXNDny+/D103zFjGCRa7apQHQLRkNLJJvXSmv63ryW FvIErF/5rqRE65Og/RuDAAA7MY+ubg+jLnHj5T3LAolMa+k3hPXhcdqdA51jX1YlkPtj mx3yFXl9LBn5Qa8vyU8oUFwyDGEdRG7TWbI6OdSVC3pZLP7E21+7DAJ6tTj3ZFFrv9HS kcWMZgjDgVQlzznsdhncRgb+idAhAXOcy7neKDdGornNWEbKnxczXKFv6Zh9Lmpw2n0o 9VVdGrIEB4K31nQdmrPlAdZfQnq84WPmAoQ7+wE90Ncbfg7tQnrf9vLwUmucd0ppLJcq sHgg== X-Gm-Message-State: AJIora9eN7B1TEy3Ehl4WjewLTzQvRbECiVQ4qPbPFNl+C3N/IrYmOUv GCbE4Hc5BBuBCTglRwXYD3bFlJfmIPUoCg== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a25:442:0:b0:669:b500:9474 with SMTP id 63-20020a250442000000b00669b5009474mr5619872ybe.376.1656060246169; Fri, 24 Jun 2022 01:44:06 -0700 (PDT) Date: Fri, 24 Jun 2022 16:43:59 +0800 Message-Id: <20220624084400.1454579-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH] kunit: tool: Enable virtio/PCI by default on UML From: David Gow To: Daniel Latypov , Brendan Higgins , Shuah Khan Cc: David Gow , "=?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?=" , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are several tests which depend on PCI, and hence need a bunch of extra options to run under UML. This makes it awkward to give configuration instructions (whether in documentation, or as part of a .kunitconfig file), as two separate, incompatible sets of config options are required for UML and "most other architectures". For non-UML architectures, it's possible to add default kconfig options via the qemu_config python files, but there's no equivalent for UML. Add a new tools/testing/kunit/configs/arch_uml.config file containing extra kconfig options to use on UML. Signed-off-by: David Gow --- NOTE: This has dependencies on the 'make --kunitconfig repeatable' series: https://lore.kernel.org/linux-kselftest/20220624001247.3255978-1-dlatypov@google.com/ which, in turn, depends on: https://lore.kernel.org/linux-kselftest/20220520224200.3764027-1-dlatypov@google.com/ Please apply those first. Changes since RFC: https://lore.kernel.org/linux-kselftest/20220622035326.759935-1-davidgow@google.com/ - Rebase on top of the previous kconfig patches. - Fix a missing make_arch_qemuconfig->make_arch_config rename (Thanks Brendan) - Fix the tests to use the base LinuxSourceTreeOperations class, which has no default kconfig options (and so won't conflict with those set in the tests). Only test_build_reconfig_existing_config actually failed, but I updated a few more in case the defaults changed. --- tools/testing/kunit/configs/arch_uml.config | 5 +++++ tools/testing/kunit/kunit_kernel.py | 14 ++++++++++---- tools/testing/kunit/kunit_tool_test.py | 12 ++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 tools/testing/kunit/configs/arch_uml.config diff --git a/tools/testing/kunit/configs/arch_uml.config b/tools/testing/kunit/configs/arch_uml.config new file mode 100644 index 000000000000..e824ce43b05a --- /dev/null +++ b/tools/testing/kunit/configs/arch_uml.config @@ -0,0 +1,5 @@ +# Config options which are added to UML builds by default + +# Enable virtio/pci, as a lot of tests require it. +CONFIG_VIRTIO_UML=y +CONFIG_UML_PCI_OVER_VIRTIO=y diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index fc415ff7530e..127598fb994b 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -26,6 +26,7 @@ KUNITCONFIG_PATH = '.kunitconfig' OLD_KUNITCONFIG_PATH = 'last_used_kunitconfig' DEFAULT_KUNITCONFIG_PATH = 'tools/testing/kunit/configs/default.config' BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config' +UML_KCONFIG_PATH = 'tools/testing/kunit/configs/arch_uml.config' OUTFILE_PATH = 'test.log' ABS_TOOL_PATH = os.path.abspath(os.path.dirname(__file__)) QEMU_CONFIGS_DIR = os.path.join(ABS_TOOL_PATH, 'qemu_configs') @@ -53,7 +54,7 @@ class LinuxSourceTreeOperations: except subprocess.CalledProcessError as e: raise ConfigError(e.output.decode()) - def make_arch_qemuconfig(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: + def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: return base_kunitconfig def make_allyesconfig(self, build_dir: str, make_options) -> None: @@ -109,7 +110,7 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOperations): self._kernel_command_line = qemu_arch_params.kernel_command_line + ' kunit_shutdown=reboot' self._extra_qemu_params = qemu_arch_params.extra_qemu_params - def make_arch_qemuconfig(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: + def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: kconfig = kunit_config.parse_from_string(self._kconfig) kconfig.merge_in_entries(base_kunitconfig) return kconfig @@ -138,6 +139,11 @@ class LinuxSourceTreeOperationsUml(LinuxSourceTreeOperations): def __init__(self, cross_compile=None): super().__init__(linux_arch='um', cross_compile=cross_compile) + def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: + kconfig = kunit_config.parse_file(UML_KCONFIG_PATH) + kconfig.merge_in_entries(base_kunitconfig) + return kconfig + def make_allyesconfig(self, build_dir: str, make_options) -> None: kunit_parser.print_with_timestamp( 'Enabling all CONFIGs for UML...') @@ -297,7 +303,7 @@ class LinuxSourceTree: if build_dir and not os.path.exists(build_dir): os.mkdir(build_dir) try: - self._kconfig = self._ops.make_arch_qemuconfig(self._kconfig) + self._kconfig = self._ops.make_arch_config(self._kconfig) self._kconfig.write_to_file(kconfig_path) self._ops.make_olddefconfig(build_dir, make_options) except ConfigError as e: @@ -328,7 +334,7 @@ class LinuxSourceTree: return self.build_config(build_dir, make_options) existing_kconfig = kunit_config.parse_file(kconfig_path) - self._kconfig = self._ops.make_arch_qemuconfig(self._kconfig) + self._kconfig = self._ops.make_arch_config(self._kconfig) if self._kconfig.is_subset_of(existing_kconfig) and not self._kunitconfig_changed(build_dir): return True diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py index e21ae1331350..08cb2dc8ef7d 100755 --- a/tools/testing/kunit/kunit_tool_test.py +++ b/tools/testing/kunit/kunit_tool_test.py @@ -430,6 +430,10 @@ class LinuxSourceTreeTest(unittest.TestCase): f.write('CONFIG_KUNIT=y') tree = kunit_kernel.LinuxSourceTree(build_dir) + # Stub out the source tree operations, so we don't have + # the defaults for any given architecture get in the + # way. + tree._ops = kunit_kernel.LinuxSourceTreeOperations(None, None) mock_build_config = mock.patch.object(tree, 'build_config').start() # Should generate the .config @@ -447,6 +451,10 @@ class LinuxSourceTreeTest(unittest.TestCase): f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y') tree = kunit_kernel.LinuxSourceTree(build_dir) + # Stub out the source tree operations, so we don't have + # the defaults for any given architecture get in the + # way. + tree._ops = kunit_kernel.LinuxSourceTreeOperations(None, None) mock_build_config = mock.patch.object(tree, 'build_config').start() self.assertTrue(tree.build_reconfig(build_dir, make_options=[])) @@ -463,6 +471,10 @@ class LinuxSourceTreeTest(unittest.TestCase): f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y') tree = kunit_kernel.LinuxSourceTree(build_dir) + # Stub out the source tree operations, so we don't have + # the defaults for any given architecture get in the + # way. + tree._ops = kunit_kernel.LinuxSourceTreeOperations(None, None) mock_build_config = mock.patch.object(tree, 'build_config').start() # ... so we should trigger a call to build_config() -- 2.37.0.rc0.161.g10f37bed90-goog