From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Brendan Higgins <brendanhiggins@google.com>,
linux-kselftest@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>,
kunit-dev@googlegroups.com
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 3/3] kunit: Introduce get_file_path() helper
Date: Thu, 15 Oct 2020 18:23:48 +0300 [thread overview]
Message-ID: <20201015152348.65147-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20201015152348.65147-1-andriy.shevchenko@linux.intel.com>
Helper allows to derive file names depending on --build_dir argument.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
tools/testing/kunit/kunit_kernel.py | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
index 3a68dc51d33d..1f317bd1ec4f 100644
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@ -23,6 +23,11 @@ DEFAULT_KUNITCONFIG_PATH = 'arch/um/configs/kunit_defconfig'
BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config'
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):
"""Represents an error trying to configure the Linux kernel."""
@@ -92,9 +97,7 @@ class LinuxSourceTreeOperations(object):
def linux_bin(self, params, timeout, build_dir):
"""Runs the Linux UML binary. Must be named 'linux'."""
- linux_bin = './linux'
- if build_dir:
- linux_bin = os.path.join(build_dir, 'linux')
+ linux_bin = get_file_path(build_dir, 'linux')
outfile = get_outfile_path(build_dir)
with open(outfile, 'w') as output:
process = subprocess.Popen([linux_bin] + params,
@@ -103,22 +106,13 @@ class LinuxSourceTreeOperations(object):
process.wait(timeout)
def get_kconfig_path(build_dir):
- kconfig_path = KCONFIG_PATH
- if build_dir:
- kconfig_path = os.path.join(build_dir, KCONFIG_PATH)
- return kconfig_path
+ return get_file_path(build_dir, KCONFIG_PATH)
def get_kunitconfig_path(build_dir):
- kunitconfig_path = KUNITCONFIG_PATH
- if build_dir:
- kunitconfig_path = os.path.join(build_dir, KUNITCONFIG_PATH)
- return kunitconfig_path
+ return get_file_path(build_dir, KUNITCONFIG_PATH)
def get_outfile_path(build_dir):
- outfile_path = OUTFILE_PATH
- if build_dir:
- outfile_path = os.path.join(build_dir, OUTFILE_PATH)
- return outfile_path
+ return get_file_path(build_dir, OUTFILE_PATH)
class LinuxSourceTree(object):
"""Represents a Linux kernel source tree with KUnit tests."""
--
2.28.0
next prev parent reply other threads:[~2020-10-15 15:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 15:23 [PATCH v1 1/3] kunit: Do not pollute source directory with generated files (.kunitconfig) Andy Shevchenko
2020-10-15 15:23 ` [PATCH v1 2/3] kunit: Do not pollute source directory with generated files (test.log) Andy Shevchenko
2020-10-23 20:39 ` Brendan Higgins
2020-10-15 15:23 ` Andy Shevchenko [this message]
2020-10-23 20:41 ` [PATCH v1 3/3] kunit: Introduce get_file_path() helper Brendan Higgins
2020-10-23 20:37 ` [PATCH v1 1/3] kunit: Do not pollute source directory with generated files (.kunitconfig) Brendan Higgins
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=20201015152348.65147-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=brendanhiggins@google.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=skhan@linuxfoundation.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;
as well as URLs for NNTP newsgroup(s).