Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp662684iob; Wed, 18 May 2022 10:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTFZiKYDTgY0o0qJlKRd+S9Dek6KgU9VBJiSp4tlDncgbZeTxh0rmF19/o+Hz090O90OA1 X-Received: by 2002:a63:2c91:0:b0:3c6:bd44:6719 with SMTP id s139-20020a632c91000000b003c6bd446719mr365348pgs.516.1652893597344; Wed, 18 May 2022 10:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652893597; cv=none; d=google.com; s=arc-20160816; b=XSPHG3osqNZcRUzRc26wjq3ftQHlxP0XAKapqbRttpO8ub5yrjZ0NA4cAwCA64P+1k xE2V61R1V3etNIfhbjJe2HKcC//BIazAmeuz3zwC4oM673MguhiLIvk9d8mQ2zrpJt7R B6dora/Vv9U5m76vPFnkrOByK8iC/I5hYQg/auxK9x0fimJIiRwERKpsoZChxM9gzkB6 fkReDqPYtxT4ujXxazA6EONF4dVHx8NXdpt9tcrltOGCA0TQ3F7qVFcxYGJx6g6lrg5h TGCERbSLGKY4ZdFPaX0CO4nZVL2pX4DMP1I1QkSVlV7Q2luHZy/ncBbEXvxVI//mtZOO K2VA== 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:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=4p2OIzyLZf5DSGNOpJEFrH/AUMGocyU2gKg4RrUCI6s=; b=PZLxVWsdU4AzigHUdelYCuMwaq7eory9Qd2HxXUr22rxe5fnV3rVEjmQKMg9mbSo17 IH9EW2Z/f8gdJ5je+WhRH9TdBUVNPh0jsGSTrktVK5et6YCy8jT09QEhXUQwm/D0ijBv ssfPCp+GH4pTVtstu1OCc+lb1OJ54ewaMYsPU27uOfvzq0wQTvvy7G4b6bK6i+znFrzk fFIV3y9wjR1OjQSHVTYULUnHSbLc3pccIdjArkmu0eFljPtMILlETZHypP0O7ph+B9y7 g6XX9t8OWbw/yD2KlOKveI93w63CI13ALcxVZ56JAeYz+4rEUXw8gxs+Va6KZpOrQkNB cVRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=o5OhYnQd; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id nu13-20020a17090b1b0d00b001d97ad1c408si7913972pjb.147.2022.05.18.10.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 10:06:37 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=o5OhYnQd; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 531501A04A1; Wed, 18 May 2022 10:02:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240704AbiERRB5 (ORCPT + 99 others); Wed, 18 May 2022 13:01:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240687AbiERRBn (ORCPT ); Wed, 18 May 2022 13:01:43 -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 DC6866B0A7 for ; Wed, 18 May 2022 10:01:40 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2fef1441caaso24215037b3.6 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=4w95kfiue1zfkFQ71iYJg15junwkaSb0vLw2pBEETCZ5deRYoOI+tnWK4BJkjHUWKl PA8C/OV4ikpaitl0bxEVSHGhnf1k/NHfhlpat2h70Oqb++MaRr2egOxKNfnRERitX9V0 VIym35RDRsv5DC6Rux1vqhOVJXPRRR0aNHMsfV3YgD9LEiDH0cdgmVMVNctik39mfXDB FV6lbg94P938HFRmPSsjnsy3PrfpcPmy59nRF684+FXdyV3bADMDmCQieEFCierrfIUd Yii6MJIem35l1vYT3LIPr6LKY/mrGWKGU6nsyclpAQQmYJvoA9Wt7ELQdFfO4XaK/cXl UvlA== X-Gm-Message-State: AOAM531/g970Divv2cLmg1QA1yMSj6frSsuL0PXQypac7KUt7/Zwbb7M FjNaAxOzWWx8liQnqRi7DGcIM+tPovF/Yw== 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 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 --- 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): -- 2.36.1.124.g0e6072fb45-goog