Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp651175ybg; Thu, 19 Mar 2020 06:25:47 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs79QFbd6p1Kr47O+Hfs3IaHMhfJq5Or/NzsqiDH7aMXNqyspHvEt6ww7v4l65baDh8Meoi X-Received: by 2002:a9d:27c7:: with SMTP id c65mr2352000otb.318.1584624347687; Thu, 19 Mar 2020 06:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584624347; cv=none; d=google.com; s=arc-20160816; b=OvP2kN2W/6sxtafqJBQirdgjRuVR89G5w8nhs6MuYe+7pC/7iexhHDCcWDhZyZzYeC weSphd720JfreN3oq3iy6rYRybcVdFwbirOoGiApB7Ekx/vk0MtfLIw7WsBv12eJaLzR 8U9vbTiJi7EZQo8TZzegV6utMQoz7US7wLlp5m3gazBxBwdW4Xg41ioC1J0u+Rxpy+K8 BESC2G1T9fZJ9fgBLnXEpQ26z3viN/gw/EfdUOdeyUWP8vxNE5aDIsg2Y7h3K7teqIJP /aiGSvAOgZ2qBiTwOPeHyUrISwB/qe8pTBiJD+K6BOqB/CAXbdfu5I1M2YeQR1Ni2YRq O3sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+okJKGObwLgMZigVctOPpR9mgiSe333sDmXPPZqpYYs=; b=lYND13Nr8Ee/g3ecFFlJFHv0pfCA09221PZY+bYxUjlVsj4cJAr6feEImcUss7g1IK fo5k4q9R8gu1slYxrkSXuItfhuILuOcT/rosQeYY5dxKTXHmmE3SO/UaYQBpm3kgBgyh JOmexJapz/pteTUp04yF1d6GbZc3NH9d9xgjV7aC4iO/vWAcdM6CGAmClfQ47dEeHzDW 1yO8izmHTOG3Pt5UVTZ1ZggnFq1CW2g3AguTA0TXmB2sKxXsIqBaY1NSeMX28Jl5iVe2 SI7TBIUDoPsZYWhJSTkJRkNaGKdbuMhBTOCl2pbiX0pIm44yEHK7o+55eZBaqCxBzZ64 aGhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UuzJuoAx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si1180888oig.174.2020.03.19.06.25.35; Thu, 19 Mar 2020 06:25:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UuzJuoAx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730354AbgCSNZU (ORCPT + 99 others); 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