From patchwork Mon Oct 12 10:26:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11832113 X-Patchwork-Delegate: brendanhiggins@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 470BE92C for ; Mon, 12 Oct 2020 10:30:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BD4921655 for ; Mon, 12 Oct 2020 10:30:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="DCDeCCol" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387521AbgJLKaD (ORCPT ); Mon, 12 Oct 2020 06:30:03 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:37041 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387461AbgJLKaD (ORCPT ); Mon, 12 Oct 2020 06:30:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1602498602; x=1634034602; h=from:to:cc:subject:date:message-id:mime-version; bh=kFB+hAuY3HYTUl9UemGcD/WxoJMOPU0+vmjpowmsqcc=; b=DCDeCColJJMzEnmc2sOU/Uy9qTZhaUGRhh/UMNaR3kwOF5tyHTa+rHR6 yF7V6aukwkaQzo8f6m+slLIWIlbnpEYKxCeuoIuhDUrMUkyZeUfy2tlIv iKxpB5tg2TELEia4V4pomxajPxPExUxZEj6x7s8ZSpk7NrEMOITHBn1HH 4=; X-IronPort-AV: E=Sophos;i="5.77,366,1596499200"; d="scan'208";a="60718120" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-e7be2041.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 12 Oct 2020 10:29:55 +0000 Received: from EX13D31EUA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2a-e7be2041.us-west-2.amazon.com (Postfix) with ESMTPS id 7F357A0298; Mon, 12 Oct 2020 10:26:46 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.160.185) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Oct 2020 10:26:42 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , Subject: [PATCH 1/2] kunit: tool: Fix LinuxSourceTree's missed handling of 'build_dir' Date: Mon, 12 Oct 2020 12:26:20 +0200 Message-ID: <20201012102621.32226-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.43.160.185] X-ClientProxiedBy: EX13D17UWC004.ant.amazon.com (10.43.162.195) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: SeongJae Park Because commit d43c7fb05765 ("kunit: tool: fix improper treatment of file location") removed 'kunit_kernel.kunitconfig_path' modification for the '--builddir' argument, running kunit with '--build_dir' now fails with below error message: Traceback (most recent call last): File "./tools/testing/kunit/kunit.py", line 325, in main(sys.argv[1:]) File "./tools/testing/kunit/kunit.py", line 245, in main linux = kunit_kernel.LinuxSourceTree() File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 109, in __init__ self._kconfig.read_from_file(kunitconfig_path) File "/home/sjpark/linux/tools/testing/kunit/kunit_config.py", line 88, in read_from_file with open(path, 'r') as f: FileNotFoundError: [Errno 2] No such file or directory: '.kunitconfig' As simply reverting the change now make the 'kunit_tool_test' fails again, this commit fixes the problem by passing the 'build_dir' argument to 'LinuxSourceTree' constructor. Fixes: d43c7fb05765 ("kunit: tool: fix improper treatment of file location") Signed-off-by: SeongJae Park --- tools/testing/kunit/kunit.py | 8 ++++---- tools/testing/kunit/kunit_kernel.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index 425ef40067e7..611c23e178f8 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -242,7 +242,7 @@ def main(argv, linux=None): os.mkdir(cli_args.build_dir) if not linux: - linux = kunit_kernel.LinuxSourceTree() + linux = kunit_kernel.LinuxSourceTree(cli_args.build_dir) request = KunitRequest(cli_args.raw_output, cli_args.timeout, @@ -259,7 +259,7 @@ def main(argv, linux=None): os.mkdir(cli_args.build_dir) if not linux: - linux = kunit_kernel.LinuxSourceTree() + linux = kunit_kernel.LinuxSourceTree(cli_args.build_dir) request = KunitConfigRequest(cli_args.build_dir, cli_args.make_options) @@ -275,7 +275,7 @@ def main(argv, linux=None): os.mkdir(cli_args.build_dir) if not linux: - linux = kunit_kernel.LinuxSourceTree() + linux = kunit_kernel.LinuxSourceTree(cli_args.build_dir) request = KunitBuildRequest(cli_args.jobs, cli_args.build_dir, @@ -293,7 +293,7 @@ def main(argv, linux=None): os.mkdir(cli_args.build_dir) if not linux: - linux = kunit_kernel.LinuxSourceTree() + linux = kunit_kernel.LinuxSourceTree(cli_args.build_dir) exec_request = KunitExecRequest(cli_args.timeout, cli_args.build_dir, diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index e20e2056cb38..16a997504317 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -104,9 +104,9 @@ def get_kconfig_path(build_dir): class LinuxSourceTree(object): """Represents a Linux kernel source tree with KUnit tests.""" - def __init__(self): + def __init__(self, build_dir): self._kconfig = kunit_config.Kconfig() - self._kconfig.read_from_file(kunitconfig_path) + self._kconfig.read_from_file(os.path.join(build_dir, kunitconfig_path)) self._ops = LinuxSourceTreeOperations() signal.signal(signal.SIGINT, self.signal_handler) From patchwork Mon Oct 12 10:26:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11832111 X-Patchwork-Delegate: brendanhiggins@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53D721580 for ; Mon, 12 Oct 2020 10:27:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3084A2145D for ; Mon, 12 Oct 2020 10:27:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="QuARfvkv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387466AbgJLK1B (ORCPT ); Mon, 12 Oct 2020 06:27:01 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:33902 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387463AbgJLK1B (ORCPT ); Mon, 12 Oct 2020 06:27:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1602498420; x=1634034420; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Vis5a8KRuMJ/9yIC3aGTX8Ith/0AYp1GJQc5VjFEZAY=; b=QuARfvkv5tSy6Gm1LPjCm/NPgBkdHVcrfVCfY/LPJ0T5pFMjVx5fI3US /yvwcO7znK3KVKBc2APG/JC/QtuZpzxRP3m7FrXkISUF7JjnYZ6QT3A9a PfQe5YkOtRmdcmuZg85PzIMGTFnCGrL9bii4lef316UUo9ddxgY3bMtTL Q=; X-IronPort-AV: E=Sophos;i="5.77,366,1596499200"; d="scan'208";a="82427578" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2c-456ef9c9.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 12 Oct 2020 10:26:53 +0000 Received: from EX13D31EUA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2c-456ef9c9.us-west-2.amazon.com (Postfix) with ESMTPS id C30C5A8440; Mon, 12 Oct 2020 10:26:52 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.160.185) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Oct 2020 10:26:47 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , Subject: [PATCH 2/2] kunit: tool: Mark 'kunittest_config' as constant again Date: Mon, 12 Oct 2020 12:26:21 +0200 Message-ID: <20201012102621.32226-2-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201012102621.32226-1-sjpark@amazon.com> References: <20201012102621.32226-1-sjpark@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.43.160.185] X-ClientProxiedBy: EX13D17UWC004.ant.amazon.com (10.43.162.195) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: SeongJae Park 'kunit_kernel.kunittest_config' was constant at first, and therefore it used UPPER_SNAKE_CASE naming convention that usually means it is constant in Python world. But, commit e3212513a8f0 ("kunit: Create default config in '--build_dir'") made it modifiable to fix a use case of the tool and thus the naming also changed to lower_snake_case. However, this resulted in a confusion. As a result, some successing changes made the tool unittest fail, and a fix[1] of it again incurred the '--build_dir' use case failure. As the previous commit fixed the '--build_dir' use case without modifying the variable again, this commit marks the variable as constant again with UPPER_SNAKE_CASE, to reduce future confusions. [1] Commit d43c7fb05765 ("kunit: tool: fix improper treatment of file location") Signed-off-by: SeongJae Park Reviewed-by: Brendan Higgins --- tools/testing/kunit/kunit.py | 4 ++-- tools/testing/kunit/kunit_kernel.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index 611c23e178f8..0a58c1fb87d9 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -44,9 +44,9 @@ class KunitStatus(Enum): TEST_FAILURE = auto() def create_default_kunitconfig(): - if not os.path.exists(kunit_kernel.kunitconfig_path): + if not os.path.exists(kunit_kernel.KUNITCONFIG_PATH): shutil.copyfile('arch/um/configs/kunit_defconfig', - kunit_kernel.kunitconfig_path) + kunit_kernel.KUNITCONFIG_PATH) def get_kernel_root_path(): parts = sys.argv[0] if not __file__ else __file__ diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index 16a997504317..42dca0163479 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -18,7 +18,7 @@ import kunit_config import kunit_parser KCONFIG_PATH = '.config' -kunitconfig_path = '.kunitconfig' +KUNITCONFIG_PATH = '.kunitconfig' BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config' class ConfigError(Exception): @@ -106,7 +106,7 @@ class LinuxSourceTree(object): def __init__(self, build_dir): self._kconfig = kunit_config.Kconfig() - self._kconfig.read_from_file(os.path.join(build_dir, kunitconfig_path)) + self._kconfig.read_from_file(os.path.join(build_dir, KUNITCONFIG_PATH)) self._ops = LinuxSourceTreeOperations() signal.signal(signal.SIGINT, self.signal_handler)