Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6213544ybv; Tue, 18 Feb 2020 12:09:02 -0800 (PST) X-Google-Smtp-Source: APXvYqw3Y9ORYkOJek9oXC8eEQKwRqU/yXQc6kf+k0zjESWJiPZM78H1YVdn38fpcDurQl4EQJQN X-Received: by 2002:a05:6830:16d0:: with SMTP id l16mr17453954otr.83.1582056542500; Tue, 18 Feb 2020 12:09:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582056542; cv=none; d=google.com; s=arc-20160816; b=x7FP+K5YIgseufIn5siZzfOD1b8FICtL/ZOKjJCzqkKfrVQ06mwG+zu+6S3qhVe0KU DHWVAlDreZdZsrUn9g7QRwrIcNIHE0wedFgmOlyM/YwNqaTPsRf+GlQG9X1p8WWqvra5 wq7D5OVJ/xtldFD5Uj5hmx6RskwTg4rqUqQvRcooekYv+bG5BbHBaCBvG6VZEWxq+9YH pbAgSW4+xlFP0Lgjj+nPdnxopRT2sH9Zx9rRj8sxMDKqBUrF33Z4Aif3Osdqeodok33S 65pDQA6HHgtnAmIBY/IGcFFMmoYU1anc1PUtPNpR8qNngtljyrcVaQMn86hVRo/h+2DW 8k+g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=GA0KuIfGABhOq0CUZZFDmrHlxV/p9BLpPzwXbBYkT6w=; b=tGk+JNzhQMh7IkmH2OREH+gKpetWsuUDdoHsial7pdryab2eGALm/WakoC+5S/KVRv jS8enK4Vi5PlEF6KfWKW//B8RU5RyUdtmimze/rUhaj9BvITI2PmGyK5aUNLIBL3BiCP 6r0ZnoeFOfJurYtGWZuX8MdwPvDgKyezDBM7y/LcLlzbxHL8fEZqtwHt4uNkaLW/ICWt 2qXWXRponaru5vQudtJM9O6t/YkHMUi5OZd61Hc/+wG8G5oiB4wM1gzb/brDdPB5NW9Y db7qR0K3Hz15CB4YHaXsGky4k4WEoVxGgpk+gIwEyXOySQl9qx+vOtl+hXKDWJU0AMuH trkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="VH+/6iyQ"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si2214264oto.169.2020.02.18.12.08.50; Tue, 18 Feb 2020 12:09:02 -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=@gmail.com header.s=20161025 header.b="VH+/6iyQ"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728087AbgBRUIr (ORCPT + 99 others); Tue, 18 Feb 2020 15:08:47 -0500 Received: from mail-yb1-f193.google.com ([209.85.219.193]:41958 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727918AbgBRUIp (ORCPT ); Tue, 18 Feb 2020 15:08:45 -0500 Received: by mail-yb1-f193.google.com with SMTP id j11so11123940ybt.8; Tue, 18 Feb 2020 12:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=GA0KuIfGABhOq0CUZZFDmrHlxV/p9BLpPzwXbBYkT6w=; b=VH+/6iyQaWXpOVM/tksOiDfVtqV+g3zIewTJ3+yv5g79algXW8S4fAiRQTZIf57bWT bc8azjUHSpQI6aQnkQcBbk+V6+0wKC97Tq2d4lMHVT3ynMip6mu8r1TPZwdZ9SJ126qv C4RsYJtMpMxz9RKof7t/MZ/1cDhSe1czy1msd0E4mJTASIyJ/Y6pOS2s8W3xcQJ/ZMIE SFfu2qiOyBcNTfFBBk9vsxxZUQahY0GPZF+GscB6WSOadwxM7ptUpxkgK6eI+xemycfZ 3Rq29xowj1BJST62mg5Nc0/pzQk5iNIbN5k1jWN6unjzn+0nKNQS0txBaZJ2EmqoT65e qwWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=GA0KuIfGABhOq0CUZZFDmrHlxV/p9BLpPzwXbBYkT6w=; b=Sb1f+y5t9fDJeZOsZ8YziHPcuXpFrRHP6N72x/uO59jDi3TlZwF9uxGcUyIvUFKynO Dgl94bdza/+fmY+Tiv1IhcAQ4FjnXkSj2JBLEFAk2T23kXiZPxZB/anw1NtgUrJlGJoH 8p7NRg7P2751dFnMy9BOXEMkgqXmQfq9tCR3iKpdPyaTHeMMU8WeemjKUyIkl5xj01dE O5nWG4Jy1hqQcPfLWl3fY2M1NMNpRgS++1/fjgjm3jKFZIqB6Ouh4wELLcM+ftjxiw+S lKMHjRobCSfMLSnMTzXbuP2mIgiGDdJZQ5AH3Hv3mhr4Z9fAgQAks51GpRvzJ2Mx++Hp o9Yw== X-Gm-Message-State: APjAAAW4fbFf8eWOq/2yMf71J0YzlI8ihogbnzntgqTMBXfNSyulIutl 0tErqxqaMDgD7hZW/Ykx0I4= X-Received: by 2002:a05:6902:4b1:: with SMTP id r17mr19257720ybs.38.1582056523819; Tue, 18 Feb 2020 12:08:43 -0800 (PST) Received: from [192.168.1.46] (c-73-88-245-53.hsd1.tn.comcast.net. [73.88.245.53]) by smtp.gmail.com with ESMTPSA id e63sm1933970ywd.64.2020.02.18.12.08.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Feb 2020 12:08:43 -0800 (PST) Subject: Re: [PATCH] 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 References: <20200211002551.147187-1-heidifahim@google.com> From: Frank Rowand Message-ID: <757222d7-ab88-8298-2ff1-2ea8b2fafadf@gmail.com> Date: Tue, 18 Feb 2020 14:08:42 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200211002551.147187-1-heidifahim@google.com> Content-Type: text/plain; charset=utf-8 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 On 2/10/20 6:25 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 s/linux directory where/root of the linux kernel source tree from which/ The existing wording implies that the cd is to .../tools/testing/kunit/ -Frank > 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 > --- > 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) >