From 83e5ddfd1bedb2547e21ce36b9dcdd23b9296c5c Mon Sep 17 00:00:00 2001
From: Sascha Bischoff <sascha.bischoff@arm.com>
Date: Thu, 1 Mar 2018 15:26:43 +0000
Subject: [PATCH] target: add option to invoke to redirect stderr

The stderr of a command is not propagated as part of the command
output. However, some workloads/commands write vital output to
stderr. For this reason, we add an option to invoke which redirects
stderr to stdout (redirect_stderr). This is disabled by default.
---
 devlib/target.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/devlib/target.py b/devlib/target.py
index fe03e92..3304923 100644
--- a/devlib/target.py
+++ b/devlib/target.py
@@ -338,7 +338,7 @@ class Target(object):
         return self.conn.background(command, stdout, stderr, as_root)
 
     def invoke(self, binary, args=None, in_directory=None, on_cpus=None,
-               as_root=False, timeout=30):
+               redirect_stderr=False, as_root=False, timeout=30):
         """
         Executes the specified binary under the specified conditions.
 
@@ -369,6 +369,8 @@ class Target(object):
             command = '{} taskset 0x{:x} {}'.format(self.busybox, on_cpus, command)
         if in_directory:
             command = 'cd {} && {}'.format(in_directory, command)
+        if redirect_stderr:
+            command = '{} 2>&1'.format(command)
         return self.execute(command, as_root=as_root, timeout=timeout)
 
     def background_invoke(self, binary, args=None, in_directory=None,