diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2016-06-29 19:45:41 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-08-17 10:35:44 +0100 |
commit | d82a795683884eb6294895d7d2a9507e37e73ceb (patch) | |
tree | fb3846f6b59b4c0aa5a14e6fee4fe21d112b0a8b | |
parent | f4128f0e462e8c0ca2d3aabb99abd15e44e85c5b (diff) | |
download | poky-d82a795683884eb6294895d7d2a9507e37e73ceb.tar.gz |
oeqa.buildperf: introduce runCmd2()
Special runCmd() for build perf tests which doesn't raise an
AssertionError when the command fails. This causes command failures to
be detected as test errors instead of test failures. This way "failed"
state of tests is reserved for future making it possible to set e.g.
thresholds for certain measurement results.
(From OE-Core rev: 09590ac76a19ee1b1b4a9188f7fce5029f0de52a)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/buildperf/__init__.py | 3 | ||||
-rw-r--r-- | meta/lib/oeqa/buildperf/base.py | 15 |
2 files changed, 12 insertions, 6 deletions
diff --git a/meta/lib/oeqa/buildperf/__init__.py b/meta/lib/oeqa/buildperf/__init__.py index 85abf3a25e..605f429ecc 100644 --- a/meta/lib/oeqa/buildperf/__init__.py +++ b/meta/lib/oeqa/buildperf/__init__.py | |||
@@ -14,5 +14,6 @@ from .base import (BuildPerfTestCase, | |||
14 | BuildPerfTestLoader, | 14 | BuildPerfTestLoader, |
15 | BuildPerfTestResult, | 15 | BuildPerfTestResult, |
16 | BuildPerfTestRunner, | 16 | BuildPerfTestRunner, |
17 | KernelDropCaches) | 17 | KernelDropCaches, |
18 | runCmd2) | ||
18 | from .test_basic import * | 19 | from .test_basic import * |
diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py index d592bd26b9..52c2ab61bf 100644 --- a/meta/lib/oeqa/buildperf/base.py +++ b/meta/lib/oeqa/buildperf/base.py | |||
@@ -21,6 +21,7 @@ import time | |||
21 | import traceback | 21 | import traceback |
22 | import unittest | 22 | import unittest |
23 | from datetime import datetime, timedelta | 23 | from datetime import datetime, timedelta |
24 | from functools import partial | ||
24 | 25 | ||
25 | from oeqa.utils.commands import runCmd, get_bb_vars | 26 | from oeqa.utils.commands import runCmd, get_bb_vars |
26 | from oeqa.utils.git import GitError, GitRepo | 27 | from oeqa.utils.git import GitError, GitRepo |
@@ -28,6 +29,10 @@ from oeqa.utils.git import GitError, GitRepo | |||
28 | # Get logger for this module | 29 | # Get logger for this module |
29 | log = logging.getLogger('build-perf') | 30 | log = logging.getLogger('build-perf') |
30 | 31 | ||
32 | # Our own version of runCmd which does not raise AssertErrors which would cause | ||
33 | # errors to interpreted as failures | ||
34 | runCmd2 = partial(runCmd, assert_error=False) | ||
35 | |||
31 | 36 | ||
32 | class KernelDropCaches(object): | 37 | class KernelDropCaches(object): |
33 | """Container of the functions for dropping kernel caches""" | 38 | """Container of the functions for dropping kernel caches""" |
@@ -39,7 +44,7 @@ class KernelDropCaches(object): | |||
39 | from getpass import getpass | 44 | from getpass import getpass |
40 | from locale import getdefaultlocale | 45 | from locale import getdefaultlocale |
41 | cmd = ['sudo', '-k', '-n', 'tee', '/proc/sys/vm/drop_caches'] | 46 | cmd = ['sudo', '-k', '-n', 'tee', '/proc/sys/vm/drop_caches'] |
42 | ret = runCmd(cmd, ignore_status=True, data=b'0') | 47 | ret = runCmd2(cmd, ignore_status=True, data=b'0') |
43 | if ret.output.startswith('sudo:'): | 48 | if ret.output.startswith('sudo:'): |
44 | pass_str = getpass( | 49 | pass_str = getpass( |
45 | "\nThe script requires sudo access to drop caches between " | 50 | "\nThe script requires sudo access to drop caches between " |
@@ -59,7 +64,7 @@ class KernelDropCaches(object): | |||
59 | input_data = b'' | 64 | input_data = b'' |
60 | cmd += ['tee', '/proc/sys/vm/drop_caches'] | 65 | cmd += ['tee', '/proc/sys/vm/drop_caches'] |
61 | input_data += b'3' | 66 | input_data += b'3' |
62 | runCmd(cmd, data=input_data) | 67 | runCmd2(cmd, data=input_data) |
63 | 68 | ||
64 | 69 | ||
65 | def time_cmd(cmd, **kwargs): | 70 | def time_cmd(cmd, **kwargs): |
@@ -71,7 +76,7 @@ def time_cmd(cmd, **kwargs): | |||
71 | timecmd += cmd | 76 | timecmd += cmd |
72 | # TODO: 'ignore_status' could/should be removed when globalres.log is | 77 | # TODO: 'ignore_status' could/should be removed when globalres.log is |
73 | # deprecated. The function would just raise an exception, instead | 78 | # deprecated. The function would just raise an exception, instead |
74 | ret = runCmd(timecmd, ignore_status=True, **kwargs) | 79 | ret = runCmd2(timecmd, ignore_status=True, **kwargs) |
75 | timedata = tmpf.file.read() | 80 | timedata = tmpf.file.read() |
76 | return ret, timedata | 81 | return ret, timedata |
77 | 82 | ||
@@ -213,7 +218,7 @@ class BuildPerfTestCase(unittest.TestCase): | |||
213 | """Run a command and log it's output""" | 218 | """Run a command and log it's output""" |
214 | cmd_log = os.path.join(self.out_dir, 'commands.log') | 219 | cmd_log = os.path.join(self.out_dir, 'commands.log') |
215 | with open(cmd_log, 'a') as fobj: | 220 | with open(cmd_log, 'a') as fobj: |
216 | runCmd(cmd, stdout=fobj) | 221 | runCmd2(cmd, stdout=fobj) |
217 | 222 | ||
218 | def measure_cmd_resources(self, cmd, name, legend): | 223 | def measure_cmd_resources(self, cmd, name, legend): |
219 | """Measure system resource usage of a command""" | 224 | """Measure system resource usage of a command""" |
@@ -265,7 +270,7 @@ class BuildPerfTestCase(unittest.TestCase): | |||
265 | """Estimate disk usage of a file or directory""" | 270 | """Estimate disk usage of a file or directory""" |
266 | # TODO: 'ignore_status' could/should be removed when globalres.log is | 271 | # TODO: 'ignore_status' could/should be removed when globalres.log is |
267 | # deprecated. The function would just raise an exception, instead | 272 | # deprecated. The function would just raise an exception, instead |
268 | ret = runCmd(['du', '-s', path], ignore_status=True) | 273 | ret = runCmd2(['du', '-s', path], ignore_status=True) |
269 | if ret.status: | 274 | if ret.status: |
270 | log.error("du failed, disk usage will be reported as 0") | 275 | log.error("du failed, disk usage will be reported as 0") |
271 | size = 0 | 276 | size = 0 |