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=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 2C08DC761A1 for ; Wed, 19 Feb 2020 22:18:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 031822465D for ; Wed, 19 Feb 2020 22:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582150692; bh=AXnbOh2nyCYDjmRNHp01cqLKWdZnvLDJhpOUR1uau9c=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-ID:From; b=hLcBy0a/rDzzavtTu14r0/2hWQJpvFRMA5QhTvvYlr77Jce7mfxhkD4872yoXlJ0b xQC+HqZIJvYEp6XtL5jrWDUH7g1LLiQcEtAp86AaPQOC9BGazQm9uehrV6P/cDvc4X ZfChcGHTVdJHRKwWh2C4hLaPweQqOIjV924DEers= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727740AbgBSWSK (ORCPT ); Wed, 19 Feb 2020 17:18:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:55014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727163AbgBSWSK (ORCPT ); Wed, 19 Feb 2020 17:18:10 -0500 Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B889206EF; Wed, 19 Feb 2020 22:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582150689; bh=AXnbOh2nyCYDjmRNHp01cqLKWdZnvLDJhpOUR1uau9c=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=a7CIckuq1biRb27wgRWDNoOXnMDB4iWPaM4U8gSN8tFPj9BxzFDKPJi3wMvAm+jn0 wrHzvOY7Zz7LszytwFLT4041qxJ8ddHV4FZqmX4RHQlrICpkOlgLQxNzPQKXzomQ1H noWT6Qas13+w30P+tFtc+f/rHuR1iKfOEHppzNOw= Subject: Re: [PATCH v2] kunit: run kunit_tool from any directory To: Heidi Fahim , brendanhiggins@google.com, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org Cc: frowand.list@gmail.com, shuah References: <20200218221916.239951-1-heidifahim@google.com> From: shuah Message-ID: Date: Wed, 19 Feb 2020 15:18:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200218221916.239951-1-heidifahim@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Heidi, On 2/18/20 3:19 PM, Heidi Fahim wrote: > 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 Thanks for the patch. In the future please include changes from v1 to v2. I am assuming this v2 addresses Frank's comments. > --- > 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 3f552e847a14..060d960a7029 100755 > --- a/tools/testing/kunit/kunit.py > +++ b/tools/testing/kunit/kunit.py > @@ -26,6 +26,8 @@ KunitResult = namedtuple('KunitResult', ['status','result']) > KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', > 'build_dir', 'defconfig', 'json']) > > +KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] > + > class KunitStatus(Enum): > SUCCESS = auto() > CONFIG_FAILURE = auto() > @@ -37,6 +39,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() > @@ -130,6 +139,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) > thanks, -- Shuah