kunit: Introduce get_file_path() helper
Helper allows to derive file names depending on --build_dir argument. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Tested-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
committed by
Shuah Khan
parent
b650545978
commit
f3ed003e64
@@ -23,6 +23,11 @@ DEFAULT_KUNITCONFIG_PATH = 'arch/um/configs/kunit_defconfig'
|
|||||||
BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config'
|
BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config'
|
||||||
OUTFILE_PATH = 'test.log'
|
OUTFILE_PATH = 'test.log'
|
||||||
|
|
||||||
|
def get_file_path(build_dir, default):
|
||||||
|
if build_dir:
|
||||||
|
default = os.path.join(build_dir, default)
|
||||||
|
return default
|
||||||
|
|
||||||
class ConfigError(Exception):
|
class ConfigError(Exception):
|
||||||
"""Represents an error trying to configure the Linux kernel."""
|
"""Represents an error trying to configure the Linux kernel."""
|
||||||
|
|
||||||
@@ -97,9 +102,7 @@ class LinuxSourceTreeOperations(object):
|
|||||||
|
|
||||||
def linux_bin(self, params, timeout, build_dir):
|
def linux_bin(self, params, timeout, build_dir):
|
||||||
"""Runs the Linux UML binary. Must be named 'linux'."""
|
"""Runs the Linux UML binary. Must be named 'linux'."""
|
||||||
linux_bin = './linux'
|
linux_bin = get_file_path(build_dir, 'linux')
|
||||||
if build_dir:
|
|
||||||
linux_bin = os.path.join(build_dir, 'linux')
|
|
||||||
outfile = get_outfile_path(build_dir)
|
outfile = get_outfile_path(build_dir)
|
||||||
with open(outfile, 'w') as output:
|
with open(outfile, 'w') as output:
|
||||||
process = subprocess.Popen([linux_bin] + params,
|
process = subprocess.Popen([linux_bin] + params,
|
||||||
@@ -108,22 +111,13 @@ class LinuxSourceTreeOperations(object):
|
|||||||
process.wait(timeout)
|
process.wait(timeout)
|
||||||
|
|
||||||
def get_kconfig_path(build_dir):
|
def get_kconfig_path(build_dir):
|
||||||
kconfig_path = KCONFIG_PATH
|
return get_file_path(build_dir, KCONFIG_PATH)
|
||||||
if build_dir:
|
|
||||||
kconfig_path = os.path.join(build_dir, KCONFIG_PATH)
|
|
||||||
return kconfig_path
|
|
||||||
|
|
||||||
def get_kunitconfig_path(build_dir):
|
def get_kunitconfig_path(build_dir):
|
||||||
kunitconfig_path = KUNITCONFIG_PATH
|
return get_file_path(build_dir, KUNITCONFIG_PATH)
|
||||||
if build_dir:
|
|
||||||
kunitconfig_path = os.path.join(build_dir, KUNITCONFIG_PATH)
|
|
||||||
return kunitconfig_path
|
|
||||||
|
|
||||||
def get_outfile_path(build_dir):
|
def get_outfile_path(build_dir):
|
||||||
outfile_path = OUTFILE_PATH
|
return get_file_path(build_dir, OUTFILE_PATH)
|
||||||
if build_dir:
|
|
||||||
outfile_path = os.path.join(build_dir, OUTFILE_PATH)
|
|
||||||
return outfile_path
|
|
||||||
|
|
||||||
class LinuxSourceTree(object):
|
class LinuxSourceTree(object):
|
||||||
"""Represents a Linux kernel source tree with KUnit tests."""
|
"""Represents a Linux kernel source tree with KUnit tests."""
|
||||||
|
|||||||
Reference in New Issue
Block a user