Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4298372ybv; Mon, 10 Feb 2020 16:33:52 -0800 (PST) X-Google-Smtp-Source: APXvYqzfOTCV2XrcIP3LC40bkYldiCmaHcJgHWsmmZa0ATnY6qGBUT1axkng9Vf3TcFbWww2zCUe X-Received: by 2002:aca:50cd:: with SMTP id e196mr1237549oib.178.1581381232294; Mon, 10 Feb 2020 16:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581381232; cv=none; d=google.com; s=arc-20160816; b=qbc0FSZUS+1m8eIuzQsuLF1Q1bR1f6HRywH6VHwUP+Dqvj3NuiljaY8nQ7h/iyCejM UQgKwjtDRnwQ30fiBEVSR2LMMXkOkz3zhgZ3/oWzlEhGDGSgfQo2+zCvVYREDotNKt2K 7xKmHuSU00KiZnfV96awuqU8ZaxroXN1PaLFrX+/CZFK+5XR64MN30h0e/1K96XPFkAX 1IxHU7Hpr23CGYlqg3OhybEDaT1pBtNBZZEZA80ue7ERAguxhq4OCaj/dEjBKH/9kf+j sOWJc85PfZ249TXmPdEik3VCjKB/cJShfp9buRE1+wDHoZwDq0J/KwDT08V/2kJ2u6Ub xV2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wTD7KLfgNlcO5TldUCo2W66GWZWNBDU2Nh1U6Y8rvDo=; b=jiJh8IcY2KwO0Gfl4blR2+4UkhQl6ADr1yC2GxIWN0T3C+UsViJJRPNp1ZibeAU8Xz 1bXQKcNxoq59nJgmI1HKRYKgFQznbEUHfshPgLVo+V/LidnMZfHdKzX28wNN3Glma8au aLuhjktA7nnFkwbgANdH6BG+RsxfBRn55GX8N4TPrRuBLxkfZ07QTEKMPsfrax0voo5Y IsjnE2iLht3OgaNg5mm0qLS5eCPbAZ5MgBl8IU9zvgltPg/J7BFakM0zxMVluCzrjBXc /G2qRk4yCVv4D+iP4QzTTt/h9FTlGCgS0SpuvJjtNHiuJGfDxqdIzAHgvmxoW/U9MR66 Iyqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uaAIWqJS; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a22si978147otp.84.2020.02.10.16.33.38; Mon, 10 Feb 2020 16:33:52 -0800 (PST) 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=@google.com header.s=20161025 header.b=uaAIWqJS; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727684AbgBKAb6 (ORCPT + 99 others); Mon, 10 Feb 2020 19:31:58 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45023 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727628AbgBKAb6 (ORCPT ); Mon, 10 Feb 2020 19:31:58 -0500 Received: by mail-pg1-f194.google.com with SMTP id g3so4762281pgs.11 for ; Mon, 10 Feb 2020 16:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wTD7KLfgNlcO5TldUCo2W66GWZWNBDU2Nh1U6Y8rvDo=; b=uaAIWqJSfi6jxhANMhO9SKzdRBl4fHthnjWBFFYu3OqcCXlHg6vW5P5ib6vXtuAGe6 SN/QoxaUKMIuIzydImDfxngn+9IM7BhNHpLF9IShTGKsW/y/CNBmOVvwdeN8lSOpjI3O EETr6cBMC5FY842BDbMARD6y/hQk7qo3cejZZ4yJU9llGfdM5JnVhqjTMTVRlGK8AiCj endtjwPanzcbc2W7vUuVlvr1+twK+7FruGCpxmgNGkYTXLo5ZYqYcFkXyOEmOxnlJl4h puzWKjvrHge400ZoAm4U4N7LM6gaO5IYSbDWmffefI9EbW8xzdtZxyABeGxC5HVCvx2E 7BzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wTD7KLfgNlcO5TldUCo2W66GWZWNBDU2Nh1U6Y8rvDo=; b=ZvA86yF0g9vzZDssMbf4h7pPf8QkS/Tx7qJ1S8Yhj8EVnhmfxDO/jaEKfgNAxvTG8B IoxmQh+dKA7SSwjwLLYRh/UkjtFT/eSmWFIYd9drQSDe4J+7nuvhNq5BpzkkzwRvjVnK YOiqIfl7KozExGibFQIHUO2lQeKdx5HecXMYUOVaF7xQ5S9IJM9zZpQLJ3DpBIqEC+KR qxPiwx4hBuTm6uEW/K0fc2WumuFwddTKwKHJK7FlIsQpdEDeNKCVCHj8jXMqa7s6i+w0 SFVo4p9ja0rR+8H6XYb7Xht3PoTV0PDNlKCLedyX/6g4JKvOwAbsLzASEl63Zhl6gPD/ hzaQ== X-Gm-Message-State: APjAAAX9VMg3qYQ/fC4jy4ZxL3vacpG5LxRt5Tq6EL2uMYjf5ev8hIax yjcx7gCuS3B1KYhwGTveNCoZ0njdY80Ng8mWgpj2Lg== X-Received: by 2002:a63:480f:: with SMTP id v15mr4118291pga.201.1581381116183; Mon, 10 Feb 2020 16:31:56 -0800 (PST) MIME-Version: 1.0 References: <20200211002551.147187-1-heidifahim@google.com> In-Reply-To: <20200211002551.147187-1-heidifahim@google.com> From: Brendan Higgins Date: Mon, 10 Feb 2020 16:31:45 -0800 Message-ID: Subject: Re: [PATCH] kunit: run kunit_tool from any directory To: Heidi Fahim , David Gow , Daniel Latypov Cc: "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 10, 2020 at 4:26 PM Heidi Fahim wrote: > > Implemented small fix so that the script changes work directories to the > linux directory where 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! > --- > tools/testing/kunit/kunit.py | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py > index e59eb9e7f923..3cc7be7b28a0 100755 > --- a/tools/testing/kunit/kunit.py > +++ b/tools/testing/kunit/kunit.py > @@ -35,6 +35,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 +121,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.25.0.341.g760bfbb309-goog >