[Buildroot] [next v2 3/7] testing/infra/builder: allow to override logfile

Ricardo Martincoski ricardo.martincoski at gmail.com
Sat Aug 26 22:20:52 UTC 2017


From: Ricardo Martincoski <ricardo.martincoski at datacom.ind.br>

Some test cases can use only the configure step as setup, while the
build is part of the test itself.
Allow the caller to build() to override the logfile used. This way all
the log for the actual test can be directed to *-run.log.

This change will be needed to make nice logs for git downloader test
cases.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski at datacom.ind.br>
---
Changes v1 -> v2:
  - new patch to adapt the test infra to test git download
---
 support/testing/infra/builder.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/support/testing/infra/builder.py b/support/testing/infra/builder.py
index de7c141a76..d634c211ac 100644
--- a/support/testing/infra/builder.py
+++ b/support/testing/infra/builder.py
@@ -46,7 +46,13 @@ class Builder(object):
     # that calls make.
     # e.g. env={"BR2_DL_DIR": "/path"}
     #
-    def build(self, makecmdline=None, env=None):
+    # ovrdlogfile: when the build is part of the actual test case instead of
+    # the setup, this parameter can be used to override the logfile used.
+    # e.g. ovrdlogfile=handler_for_the_run_log
+    #
+    def build(self, makecmdline=None, env=None, ovrdlogfile=None):
+        logfile = ovrdlogfile or self.logfile
+
         buildenv = os.environ.copy()
         if env:
             buildenv.update(env)
@@ -55,7 +61,7 @@ class Builder(object):
         if makecmdline:
             cmd += makecmdline
 
-        ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile,
+        ret = subprocess.call(cmd, stdout=logfile, stderr=logfile,
                               env=buildenv)
         if ret != 0:
             raise SystemError("Build failed")
-- 
2.13.0




More information about the buildroot mailing list