diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2016-05-11 14:42:32 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-07-01 16:08:50 +0100 |
commit | bf90aecb7e150d6bfac7240286c797b79d26528b (patch) | |
tree | 99bb0103c43bd0690b0a2924d44b3c1501f6c7f6 /meta/lib/oeqa/buildperf | |
parent | 15b44a484ce408b0a1acfb907e2b12ebc6cce296 (diff) | |
download | openembedded-core-bf90aecb7e150d6bfac7240286c797b79d26528b.tar.gz openembedded-core-bf90aecb7e150d6bfac7240286c797b79d26528b.tar.bz2 openembedded-core-bf90aecb7e150d6bfac7240286c797b79d26528b.zip |
oeqa.buildperf: implement BuildPerfTestRunner class
The new class is responsible for actually running the tests and
processing their results. This commit also adds a decorator function for
adding new tests. No automatic test discovery, at least yet.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/lib/oeqa/buildperf')
-rw-r--r-- | meta/lib/oeqa/buildperf/__init__.py | 3 | ||||
-rw-r--r-- | meta/lib/oeqa/buildperf/base.py | 47 |
2 files changed, 49 insertions, 1 deletions
diff --git a/meta/lib/oeqa/buildperf/__init__.py b/meta/lib/oeqa/buildperf/__init__.py index 3bee5b9028..d6065e806d 100644 --- a/meta/lib/oeqa/buildperf/__init__.py +++ b/meta/lib/oeqa/buildperf/__init__.py @@ -10,4 +10,5 @@ # more details. # """Build performance tests""" -from .base import BuildPerfTest, KernelDropCaches +from .base import (build_perf_test, BuildPerfTest, BuildPerfTestRunner, + KernelDropCaches) 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 import os import re import shutil +import socket import tempfile import time +import traceback from datetime import datetime, timedelta from oeqa.utils.commands import runCmd, get_bb_vars @@ -72,6 +74,51 @@ def time_cmd(cmd, **kwargs): return ret, timedata +class BuildPerfTestRunner(object): + """Runner class for executing the individual tests""" + # List of test cases to run + test_run_queue = [] + + def __init__(self, out_dir): + self.results = {} + self.out_dir = os.path.abspath(out_dir) + if not os.path.exists(self.out_dir): + os.makedirs(self.out_dir) + + + def run_tests(self): + """Method that actually runs the tests""" + self.results['schema_version'] = 1 + self.results['tester_host'] = socket.gethostname() + start_time = datetime.utcnow() + self.results['start_time'] = start_time + self.results['tests'] = {} + + for test_class in self.test_run_queue: + log.info("Executing test %s: %s", test_class.name, + test_class.description) + + test = test_class(self.out_dir) + try: + test.run() + except Exception: + # Catch all exceptions. This way e.g buggy tests won't scrap + # the whole test run + sep = '-' * 5 + ' TRACEBACK ' + '-' * 60 + '\n' + tb_msg = sep + traceback.format_exc() + sep + log.error("Test execution failed with:\n" + tb_msg) + self.results['tests'][test.name] = test.results + + self.results['elapsed_time'] = datetime.utcnow() - start_time + return 0 + + +def perf_test_case(obj): + """Decorator for adding test classes""" + BuildPerfTestRunner.test_run_queue.append(obj) + return obj + + class BuildPerfTest(object): """Base class for build performance tests""" SYSRES = 'sysres' |