Skip to content

Commit

Permalink
kunit: tool: fix improper treatment of file location
Browse files Browse the repository at this point in the history
Commit 01397e8 ("kunit: Fix TabError, remove defconfig code and
handle when there is no kunitconfig") and commit 45ba7a8 ("kunit:
kunit_tool: Separate out config/build/exec/parse") introduced two
closely related issues which built off of each other: they excessively
created the build directory when not present and modified a constant
(constants in Python only exist by convention).

Together these issues broken a number of unit tests for KUnit tool, so
fix them.

Fixed up commit log to fic checkpatch commit description style error.
Shuah Khan <skhan@linuxfoundation.org>

Fixes: 01397e8 ("kunit: Fix TabError, remove defconfig code and handle when there is no kunitconfig")
Fixes: 45ba7a8 ("kunit: kunit_tool: Separate out config/build/exec/parse")
Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
  • Loading branch information
Brendan Higgins authored and Shuah Khan committed Jul 17, 2020
1 parent 6816fe6 commit d43c7fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
24 changes: 0 additions & 24 deletions tools/testing/kunit/kunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,6 @@ def main(argv, linux=None):
if cli_args.subcommand == 'run':
if not os.path.exists(cli_args.build_dir):
os.mkdir(cli_args.build_dir)
kunit_kernel.kunitconfig_path = os.path.join(
cli_args.build_dir,
kunit_kernel.kunitconfig_path)

if not os.path.exists(kunit_kernel.kunitconfig_path):
create_default_kunitconfig()

if not linux:
linux = kunit_kernel.LinuxSourceTree()
Expand All @@ -261,12 +255,6 @@ def main(argv, linux=None):
if cli_args.build_dir:
if not os.path.exists(cli_args.build_dir):
os.mkdir(cli_args.build_dir)
kunit_kernel.kunitconfig_path = os.path.join(
cli_args.build_dir,
kunit_kernel.kunitconfig_path)

if not os.path.exists(kunit_kernel.kunitconfig_path):
create_default_kunitconfig()

if not linux:
linux = kunit_kernel.LinuxSourceTree()
Expand All @@ -283,12 +271,6 @@ def main(argv, linux=None):
if cli_args.build_dir:
if not os.path.exists(cli_args.build_dir):
os.mkdir(cli_args.build_dir)
kunit_kernel.kunitconfig_path = os.path.join(
cli_args.build_dir,
kunit_kernel.kunitconfig_path)

if not os.path.exists(kunit_kernel.kunitconfig_path):
create_default_kunitconfig()

if not linux:
linux = kunit_kernel.LinuxSourceTree()
Expand All @@ -307,12 +289,6 @@ def main(argv, linux=None):
if cli_args.build_dir:
if not os.path.exists(cli_args.build_dir):
os.mkdir(cli_args.build_dir)
kunit_kernel.kunitconfig_path = os.path.join(
cli_args.build_dir,
kunit_kernel.kunitconfig_path)

if not os.path.exists(kunit_kernel.kunitconfig_path):
create_default_kunitconfig()

if not linux:
linux = kunit_kernel.LinuxSourceTree()
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/kunit/kunit_tool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def tearDown(self):
pass

def test_config_passes_args_pass(self):
kunit.main(['config'], self.linux_source_mock)
kunit.main(['config', '--build_dir=.kunit'], self.linux_source_mock)
assert self.linux_source_mock.build_reconfig.call_count == 1
assert self.linux_source_mock.run_kernel.call_count == 0

Expand Down Expand Up @@ -315,7 +315,7 @@ def test_run_timeout(self):

def test_run_builddir(self):
build_dir = '.kunit'
kunit.main(['run', '--build_dir', build_dir], self.linux_source_mock)
kunit.main(['run', '--build_dir=.kunit'], self.linux_source_mock)
assert self.linux_source_mock.build_reconfig.call_count == 1
self.linux_source_mock.run_kernel.assert_called_once_with(
build_dir=build_dir, timeout=300)
Expand Down

0 comments on commit d43c7fb

Please sign in to comment.