Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp701645imw; Fri, 8 Jul 2022 10:07:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ta9yB411Z9GeIGHKY3aItwWyy9od74fgNbc+KDCXyGog2labFOdyc1ytzIctm/Vs9T0oE+ X-Received: by 2002:a17:903:1ca:b0:16b:edb8:e34e with SMTP id e10-20020a17090301ca00b0016bedb8e34emr4771071plh.158.1657300029485; Fri, 08 Jul 2022 10:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657300029; cv=none; d=google.com; s=arc-20160816; b=RkqX7blp5xQh8OA4vvzINo30DZN05lGOOi5UKoSqZd5CAwh/Bf0QOsLshr40DwW5sN VUi/6EH4Eisqj+jDlyRAEyJZI2ESf6Isz+tayeEb1fVCnALQGwyEt1pZwffERaYYkfmQ TQWSU2fRmza2noYPokZB+JGyTp9gD5U98r/PkWATrczRx13gvf/mWiu4ro9Z3oUWW3CT zUTuxH3kVOpluPT39O1O7/Vi+jIBXufgSDgRuUfm0rYe9O9X9Fq36fmwWXuuMRIWwNG/ O0TUkFhI8ZAlk7iuNra3vhO7WUCHPbudIr/ZQUfG8uazRuX5ctJGcXMidcmnoybhkoOb LJ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :mime-version:message-id:date:dkim-signature; bh=Q/iRyvoXPEz0OuK0jrrOflnyHMomDksx7PC4C85yLGg=; b=wuxozaQFWlaDK6ODSTCAoixpiTPu8xd3F6Wb3XAYF/TnJZpg36vz2RAZY0rvrrnB7t 7i/2gMhEug/2kYrUlq1PNlCjk/M+rVCXH9hHnRPbZXZaMT8gl7Fqp8wry4c7psG8HlRn t+VVJWg88ZmxVaCzMLdDgT4BiAAfhsz28k21CSNcpNitOZL/CI7jkMst647hMSkB9d+7 14Z9H8bGEJDwv78IvvtCXo5rQOWz2NrE610f7zRX0tZGtuOJWayGdtXT/bAV/n9rJ7n+ HQPHqECn5fCA1kA5/Wru0oV+Qk5wiKqFQADTbiqDn7HEau/msiADoywBc2xCxhT4EWTc MHdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mfBiGkWG; 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 z64-20020a636543000000b004126d5fa836si6053675pgb.182.2022.07.08.10.06.47; Fri, 08 Jul 2022 10:07:09 -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=mfBiGkWG; 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 S239078AbiGHQ2b (ORCPT + 99 others); Fri, 8 Jul 2022 12:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239346AbiGHQ1p (ORCPT ); Fri, 8 Jul 2022 12:27:45 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F1E68736E for ; Fri, 8 Jul 2022 09:27:21 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id o20-20020a17090a9f9400b001ef92404bd0so1426140pjp.6 for ; Fri, 08 Jul 2022 09:27:20 -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 :content-transfer-encoding; bh=Q/iRyvoXPEz0OuK0jrrOflnyHMomDksx7PC4C85yLGg=; b=mfBiGkWGOPGNvfiac/hpFafX2LM9jWCc0WY9c6vJOJfpstMLiLkb32FtdShieTEyVQ 68qP7JoiNdSOxOWe3Dwk8PARy+E82wHl1aCGKQm7TgZsrZKFOtz2r3SaCWAnqFVP6Rzy m228zMJFM4aa7ovr4UFKqW93g2alQFj/WhRyf/M/lKSfiaUAEhvePi2kdGNjhZENDS55 d/SeC62Qs+uGbkFceHmBBGb0F2XRgmMgHYeu7oRdc8JT+Ciw71jNfFAkhbVOXxwCGEvd NqHlPCCdXzayANXA3TEDRSUB2Nk/Hg14+if46xh3RViixlh9AvPK+WXDQ1aH8HnmaoIc yZKA== 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 :content-transfer-encoding; bh=Q/iRyvoXPEz0OuK0jrrOflnyHMomDksx7PC4C85yLGg=; b=JfOmnmf5CIj0E+S4Ak+n1fh7rXWwAB1QzwYSphtLJpbgnDUACnIUAztAvb3fMiDEHn kaCVP3tUXZIqlHtvnWjqRbZaX29TQx1yhScN4pWHJPO3ljjc54qzYTmlCFcddS/z47OI +vT7IFCGYoZK4uZkkOFBhVGMfk8ULQ/b75pRu0lY2weRTWFzGHFd4yUXvB5z+xqK4mnl lcLQACpkPRkdkkHliXizPuz+mh4vUv+ia4r7a6Deb8U7UNj28iqv65peYqVrUqSOVGdt 05L14Oc57V2lj89d7FTRUlEragpycyt7YzQCPNgTbZH7WmPjINACmVy8yoY26ufu7B+M XR4A== X-Gm-Message-State: AJIora9Rd0DHJbDJ+B0RK/Holnx8Xfwk+EQ20V3364kG/rVvBEenyhxv BagiJg0mZN5EBtO/X3VbKyfbS+wezcou4w== X-Received: from dlatypov-spec.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:3f35]) (user=dlatypov job=sendgmr) by 2002:a17:902:ea47:b0:16b:997b:5fd6 with SMTP id r7-20020a170902ea4700b0016b997b5fd6mr4426982plg.16.1657297639986; Fri, 08 Jul 2022 09:27:19 -0700 (PDT) Date: Fri, 8 Jul 2022 16:27:11 +0000 Message-Id: <20220708162711.1309633-1-dlatypov@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v3] kunit: tool: Enable virtio/PCI by default on UML 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, "=?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?=" , Daniel Latypov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=unavailable 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 From: David Gow 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. Tested-by: Jos=C3=A9 Exp=C3=B3sito Reviewed-by: Daniel Latypov Signed-off-by: David Gow Reviewed-by: Brendan Higgins Signed-off-by: Daniel Latypov --- NOTE: This depends on v4 of the repeatable --kunitconfig patch here: https://patchwork.kernel.org/project/linux-kselftest/patch/20220708013632.1= 210466-1-dlatypov@google.com/ Please apply it first first. Changes since v2: (dlatypov@google.com) - Rebase on top of the -kselftest kunit branch + v4 of the --kunitconfig patch. It rebased cleanly, but it evidently would not apply cleanly due to all the conflicts v4 --kunitconfig had with --qemu_args Changes since v1: https://lore.kernel.org/linux-kselftest/20220624084400.1454579-1-davidgow@g= oogle.com/ - (Hopefully) fix a pytype warning re: architecture being None in the tests. (Thanks, Daniel) - Rebase on top of the new combined v3 of the kconfig/kunitconfig patchset. - Add Jos=C3=A9's Tested-by and Daniel's Reviewed-by. Changes since RFC: https://lore.kernel.org/linux-kselftest/20220622035326.759935-1-davidgow@go= ogle.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/ku= nit/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=3Dy +CONFIG_UML_PCI_OVER_VIRTIO=3Dy diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kuni= t_kernel.py index 56492090e28e..f5c26ea89714 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -26,6 +26,7 @@ KUNITCONFIG_PATH =3D '.kunitconfig' OLD_KUNITCONFIG_PATH =3D 'last_used_kunitconfig' DEFAULT_KUNITCONFIG_PATH =3D 'tools/testing/kunit/configs/default.config' BROKEN_ALLCONFIG_PATH =3D 'tools/testing/kunit/configs/broken_on_uml.confi= g' +UML_KCONFIG_PATH =3D 'tools/testing/kunit/configs/arch_uml.config' OUTFILE_PATH =3D 'test.log' ABS_TOOL_PATH =3D os.path.abspath(os.path.dirname(__file__)) QEMU_CONFIGS_DIR =3D os.path.join(ABS_TOOL_PATH, 'qemu_configs') @@ -53,7 +54,7 @@ class LinuxSourceTreeOperations: except subprocess.CalledProcessError as e: raise ConfigError(e.output.decode()) =20 - def make_arch_qemuconfig(self, base_kunitconfig: kunit_config.Kconfig) ->= kunit_config.Kconfig: + def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kun= it_config.Kconfig: return base_kunitconfig =20 def make_allyesconfig(self, build_dir: str, make_options) -> None: @@ -109,7 +110,7 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOper= ations): self._kernel_command_line =3D qemu_arch_params.kernel_command_line + ' k= unit_shutdown=3Dreboot' self._extra_qemu_params =3D qemu_arch_params.extra_qemu_params =20 - def make_arch_qemuconfig(self, base_kunitconfig: kunit_config.Kconfig) ->= kunit_config.Kconfig: + def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kun= it_config.Kconfig: kconfig =3D kunit_config.parse_from_string(self._kconfig) kconfig.merge_in_entries(base_kunitconfig) return kconfig @@ -138,6 +139,11 @@ class LinuxSourceTreeOperationsUml(LinuxSourceTreeOper= ations): def __init__(self, cross_compile=3DNone): super().__init__(linux_arch=3D'um', cross_compile=3Dcross_compile) =20 + def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kun= it_config.Kconfig: + kconfig =3D 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: stdout.print_with_timestamp( 'Enabling all CONFIGs for UML...') @@ -298,7 +304,7 @@ class LinuxSourceTree: if build_dir and not os.path.exists(build_dir): os.mkdir(build_dir) try: - self._kconfig =3D self._ops.make_arch_qemuconfig(self._kconfig) + self._kconfig =3D 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: @@ -329,7 +335,7 @@ class LinuxSourceTree: return self.build_config(build_dir, make_options) =20 existing_kconfig =3D kunit_config.parse_file(kconfig_path) - self._kconfig =3D self._ops.make_arch_qemuconfig(self._kconfig) + self._kconfig =3D self._ops.make_arch_config(self._kconfig) =20 if self._kconfig.is_subset_of(existing_kconfig) and not self._kunitconfi= g_changed(build_dir): return True diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/k= unit_tool_test.py index ad63d0d34f3f..446ac432d9a4 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=3Dy') =20 tree =3D 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 =3D kunit_kernel.LinuxSourceTreeOperations('none', None) mock_build_config =3D mock.patch.object(tree, 'build_config').start() =20 # Should generate the .config @@ -447,6 +451,10 @@ class LinuxSourceTreeTest(unittest.TestCase): f.write('CONFIG_KUNIT=3Dy\nCONFIG_KUNIT_TEST=3Dy') =20 tree =3D 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 =3D kunit_kernel.LinuxSourceTreeOperations('none', None) mock_build_config =3D mock.patch.object(tree, 'build_config').start() =20 self.assertTrue(tree.build_reconfig(build_dir, make_options=3D[])) @@ -463,6 +471,10 @@ class LinuxSourceTreeTest(unittest.TestCase): f.write('CONFIG_KUNIT=3Dy\nCONFIG_KUNIT_TEST=3Dy') =20 tree =3D 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 =3D kunit_kernel.LinuxSourceTreeOperations('none', None) mock_build_config =3D mock.patch.object(tree, 'build_config').start() =20 # ... so we should trigger a call to build_config() base-commit: cbb6bc7059151df198b45e883ed731d8f528b65b --=20 2.37.0.rc0.161.g10f37bed90-goog