mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Rowand <frowand.list@gmail.com>
To: Heidi Fahim <heidifahim@google.com>,
	brendanhiggins@google.com, linux-kselftest@vger.kernel.org,
	kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kunit: run kunit_tool from any directory
Date: Tue, 18 Feb 2020 14:08:42 -0600	[thread overview]
Message-ID: <757222d7-ab88-8298-2ff1-2ea8b2fafadf@gmail.com> (raw)
In-Reply-To: <20200211002551.147187-1-heidifahim@google.com>

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 <heidifahim@google.com>
> ---
>  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)
> 


      parent reply	other threads:[~2020-02-18 20:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11  0:25 Heidi Fahim
2020-02-11  0:31 ` Brendan Higgins
2020-02-11 18:26   ` Bird, Tim
2020-02-11 18:48     ` Brendan Higgins
2020-02-18 20:08 ` Frank Rowand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=757222d7-ab88-8298-2ff1-2ea8b2fafadf@gmail.com \
    --to=frowand.list@gmail.com \
    --cc=brendanhiggins@google.com \
    --cc=heidifahim@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®