From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D892C4332B for ; Thu, 19 Mar 2020 13:25:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D01EA2098B for ; Thu, 19 Mar 2020 13:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584624322; bh=n60fiqQit++r2dt9ETpVJeF3WsCOgv/ioz+JBtX7UoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=f9gbm9u4mub+eAX0CS8O1iP7madAlg5ydyXN0+ZV2LxpZES1XwQ1x8UZcfS5bAcVS GyTVJlFccDtqQ5xOPN1epY2/LsyYQXhBAWx065gOWg8yq1f2L4p1qvxD6gkqPFh/kP WArA+cNa9PdJIPPNk7oArQNVASbNUf/3Y5D/Yick= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730624AbgCSNZU (ORCPT ); Thu, 19 Mar 2020 09:25:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:52832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730615AbgCSNZT (ORCPT ); Thu, 19 Mar 2020 09:25:19 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5255A214D8; Thu, 19 Mar 2020 13:25:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584624318; bh=n60fiqQit++r2dt9ETpVJeF3WsCOgv/ioz+JBtX7UoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UuzJuoAxfvyZpvKokQiERcdZC/nB3dp/POBI3vWA5tFGIQ5/+tFV8fxK3ZYCXYyhu Fvh63/JpjsZckXZvqTNk5lJR5Q4sBLPUE0SB+jASCFSKErvSHEVcIPBHxkM/Zhh6ZP OSPK3vKCM7q0TV4lA9BS5p9GvKGi8yrLv4tmVNx0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heidi Fahim , Brendan Higgins , Shuah Khan , Sasha Levin Subject: [PATCH 5.5 21/65] kunit: run kunit_tool from any directory Date: Thu, 19 Mar 2020 14:04:03 +0100 Message-Id: <20200319123933.067141799@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123926.466988514@linuxfoundation.org> References: <20200319123926.466988514@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heidi Fahim [ Upstream commit be886ba90cce2fb2f5a4dbcda8f3be3fd1b2f484 ] Implemented small fix so that the script changes work directories to the root of the linux kernel source tree from which kunit.py is run. This enables the user to run kunit from any working directory. Originally considered using os.path.join but this is more error prone as we would have to find all file path usages and modify them accordingly. Using os.chdir ensures that the entire script is run within /linux. Signed-off-by: Heidi Fahim Reviewed-by: Brendan Higgins Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin --- tools/testing/kunit/kunit.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index e59eb9e7f9236..180ad1e1b04f9 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -24,6 +24,8 @@ KunitResult = namedtuple('KunitResult', ['status','result']) KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', 'build_dir', 'defconfig']) +KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] + class KunitStatus(Enum): SUCCESS = auto() CONFIG_FAILURE = auto() @@ -35,6 +37,13 @@ def create_default_kunitconfig(): shutil.copyfile('arch/um/configs/kunit_defconfig', kunit_kernel.kunitconfig_path) +def get_kernel_root_path(): + parts = sys.argv[0] if not __file__ else __file__ + parts = os.path.realpath(parts).split('tools/testing/kunit') + if len(parts) != 2: + sys.exit(1) + return parts[0] + def run_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitRequest) -> KunitResult: config_start = time.time() @@ -114,6 +123,9 @@ def main(argv, linux=None): cli_args = parser.parse_args(argv) if cli_args.subcommand == 'run': + if get_kernel_root_path(): + os.chdir(get_kernel_root_path()) + if cli_args.build_dir: if not os.path.exists(cli_args.build_dir): os.mkdir(cli_args.build_dir) -- 2.20.1