From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 07/18] patman: Provide a way to intercept commands for testing
Date: Fri, 5 Sep 2014 19:00:12 -0600 [thread overview]
Message-ID: <1409965223-29863-8-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1409965223-29863-1-git-send-email-sjg@chromium.org>
Add a test point for the command module. This allows tests to emulate
the execution of commands. This provides more control (since we can make
the fake 'commands' do whatever we like), makes it faster to write tests
since we don't need to set up as much environment, and speeds up test
execution.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3: None
Changes in v2: None
tools/patman/command.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/patman/command.py b/tools/patman/command.py
index 7212fdf..d586f11 100644
--- a/tools/patman/command.py
+++ b/tools/patman/command.py
@@ -20,9 +20,25 @@ class CommandResult:
def __init__(self):
self.stdout = None
self.stderr = None
+ self.combined = None
self.return_code = None
self.exception = None
+ def __init__(self, stdout='', stderr='', combined='', return_code=0,
+ exception=None):
+ self.stdout = stdout
+ self.stderr = stderr
+ self.combined = combined
+ self.return_code = return_code
+ self.exception = exception
+
+
+# This permits interception of RunPipe for test purposes. If it is set to
+# a function, then that function is called with the pipe list being
+# executed. Otherwise, it is assumed to be a CommandResult object, and is
+# returned as the result for every RunPipe() call.
+# When this value is None, commands are executed as normal.
+test_result = None
def RunPipe(pipe_list, infile=None, outfile=None,
capture=False, capture_stderr=False, oneline=False,
@@ -44,6 +60,10 @@ def RunPipe(pipe_list, infile=None, outfile=None,
Returns:
CommandResult object
"""
+ if test_result:
+ if hasattr(test_result, '__call__'):
+ return test_result(pipe_list=pipe_list)
+ return test_result
result = CommandResult()
last_pipe = None
pipeline = list(pipe_list)
--
2.1.0.rc2.206.gedb03e5
next prev parent reply other threads:[~2014-09-06 1:00 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-06 1:00 [U-Boot] [PATCH v3 0/18] buildman: Expand test coverage Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 01/18] patman: Add a way of recording terminal output for testing Simon Glass
2014-09-10 18:48 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 02/18] buildman: Send builder output through a function " Simon Glass
2014-09-10 18:49 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 03/18] buildman: Enhance basic test to check summary output Simon Glass
2014-09-10 18:49 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 04/18] patman: RunPipe() should not pipe stdout/stderr unless asked Simon Glass
2014-09-10 18:49 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 05/18] buildman: Move the command line code into its own file Simon Glass
2014-09-10 18:50 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 06/18] buildman: Move full help code into the control module Simon Glass
2014-09-10 18:50 ` Simon Glass
2014-09-06 1:00 ` Simon Glass [this message]
2014-09-10 18:50 ` [U-Boot] [PATCH v3 07/18] patman: Provide a way to intercept commands for testing Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 08/18] buildman: Add a functional test Simon Glass
2014-09-10 18:50 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 09/18] buildman: Set up bsettings outside the control module Simon Glass
2014-09-10 18:50 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 10/18] buildman: Avoid looking at config file or toolchains in tests Simon Glass
2014-09-10 18:53 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 11/18] buildman: Allow tests to have their own boards Simon Glass
2014-09-10 18:53 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 12/18] buildman: Correct counting of build failures on retry Simon Glass
2014-09-10 18:53 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 13/18] buildman: Provide an internal option to clean the outpur dir Simon Glass
2014-09-10 18:53 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 14/18] patman: Start with a clean series when needed Simon Glass
2014-09-10 18:54 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 15/18] buildman: Add additional functional tests Simon Glass
2014-09-10 18:54 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 16/18] buildman: Expand output test to cover directory prefixes Simon Glass
2014-09-10 18:54 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 17/18] buildman: Permit branch names with an embedded '/' Simon Glass
2014-09-10 18:54 ` Simon Glass
2014-09-06 1:00 ` [U-Boot] [PATCH v3 18/18] buildman: Ignore conflicting tags Simon Glass
2014-09-10 18:55 ` Simon Glass
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=1409965223-29863-8-git-send-email-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.