summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/utils/commands.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 6528a98427..cd7a5e3b12 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -97,7 +97,8 @@ class Result(object):
97 pass 97 pass
98 98
99 99
100def runCmd(command, ignore_status=False, timeout=None, assert_error=True, native_sysroot=None, **options): 100def runCmd(command, ignore_status=False, timeout=None, assert_error=True,
101 native_sysroot=None, limit_exc_output=0, **options):
101 result = Result() 102 result = Result()
102 103
103 if native_sysroot: 104 if native_sysroot:
@@ -117,10 +118,16 @@ def runCmd(command, ignore_status=False, timeout=None, assert_error=True, native
117 result.pid = cmd.process.pid 118 result.pid = cmd.process.pid
118 119
119 if result.status and not ignore_status: 120 if result.status and not ignore_status:
121 exc_output = result.output
122 if limit_exc_output > 0:
123 split = result.output.splitlines()
124 if len(split) > limit_exc_output:
125 exc_output = "\n... (last %d lines of output)\n" % limit_exc_output + \
126 '\n'.join(split[-limit_exc_output:])
120 if assert_error: 127 if assert_error:
121 raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, result.output)) 128 raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))
122 else: 129 else:
123 raise CommandError(result.status, command, result.output) 130 raise CommandError(result.status, command, exc_output)
124 131
125 return result 132 return result
126 133