diff options
Diffstat (limited to 'meta/lib/oeqa/buildperf/base.py')
-rw-r--r-- | meta/lib/oeqa/buildperf/base.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py index c54b70cb11..1bfcb71610 100644 --- a/meta/lib/oeqa/buildperf/base.py +++ b/meta/lib/oeqa/buildperf/base.py | |||
@@ -15,8 +15,10 @@ import logging | |||
15 | import os | 15 | import os |
16 | import re | 16 | import re |
17 | import shutil | 17 | import shutil |
18 | import socket | ||
18 | import tempfile | 19 | import tempfile |
19 | import time | 20 | import time |
21 | import traceback | ||
20 | from datetime import datetime, timedelta | 22 | from datetime import datetime, timedelta |
21 | 23 | ||
22 | from oeqa.utils.commands import runCmd, get_bb_vars | 24 | from oeqa.utils.commands import runCmd, get_bb_vars |
@@ -72,6 +74,51 @@ def time_cmd(cmd, **kwargs): | |||
72 | return ret, timedata | 74 | return ret, timedata |
73 | 75 | ||
74 | 76 | ||
77 | class BuildPerfTestRunner(object): | ||
78 | """Runner class for executing the individual tests""" | ||
79 | # List of test cases to run | ||
80 | test_run_queue = [] | ||
81 | |||
82 | def __init__(self, out_dir): | ||
83 | self.results = {} | ||
84 | self.out_dir = os.path.abspath(out_dir) | ||
85 | if not os.path.exists(self.out_dir): | ||
86 | os.makedirs(self.out_dir) | ||
87 | |||
88 | |||
89 | def run_tests(self): | ||
90 | """Method that actually runs the tests""" | ||
91 | self.results['schema_version'] = 1 | ||
92 | self.results['tester_host'] = socket.gethostname() | ||
93 | start_time = datetime.utcnow() | ||
94 | self.results['start_time'] = start_time | ||
95 | self.results['tests'] = {} | ||
96 | |||
97 | for test_class in self.test_run_queue: | ||
98 | log.info("Executing test %s: %s", test_class.name, | ||
99 | test_class.description) | ||
100 | |||
101 | test = test_class(self.out_dir) | ||
102 | try: | ||
103 | test.run() | ||
104 | except Exception: | ||
105 | # Catch all exceptions. This way e.g buggy tests won't scrap | ||
106 | # the whole test run | ||
107 | sep = '-' * 5 + ' TRACEBACK ' + '-' * 60 + '\n' | ||
108 | tb_msg = sep + traceback.format_exc() + sep | ||
109 | log.error("Test execution failed with:\n" + tb_msg) | ||
110 | self.results['tests'][test.name] = test.results | ||
111 | |||
112 | self.results['elapsed_time'] = datetime.utcnow() - start_time | ||
113 | return 0 | ||
114 | |||
115 | |||
116 | def perf_test_case(obj): | ||
117 | """Decorator for adding test classes""" | ||
118 | BuildPerfTestRunner.test_run_queue.append(obj) | ||
119 | return obj | ||
120 | |||
121 | |||
75 | class BuildPerfTest(object): | 122 | class BuildPerfTest(object): |
76 | """Base class for build performance tests""" | 123 | """Base class for build performance tests""" |
77 | SYSRES = 'sysres' | 124 | SYSRES = 'sysres' |