summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2016-05-11 14:42:32 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-01 16:22:46 +0100
commit1d88659ef6b96408243144d41bd99dd3ff5015e2 (patch)
treefc2736ca9ce5b2bb2fd6ff27f8960a244c506c24
parent6512d6956b23d7b596c3ae37e01c5b842da95690 (diff)
downloadpoky-1d88659ef6b96408243144d41bd99dd3ff5015e2.tar.gz
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. (From OE-Core rev: bf90aecb7e150d6bfac7240286c797b79d26528b) 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__.py3
-rw-r--r--meta/lib/oeqa/buildperf/base.py47
-rwxr-xr-xscripts/oe-build-perf-test10
3 files changed, 57 insertions, 3 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 @@
10# more details. 10# more details.
11# 11#
12"""Build performance tests""" 12"""Build performance tests"""
13from .base import BuildPerfTest, KernelDropCaches 13from .base import (build_perf_test, BuildPerfTest, BuildPerfTestRunner,
14 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
15import os 15import os
16import re 16import re
17import shutil 17import shutil
18import socket
18import tempfile 19import tempfile
19import time 20import time
21import traceback
20from datetime import datetime, timedelta 22from datetime import datetime, timedelta
21 23
22from oeqa.utils.commands import runCmd, get_bb_vars 24from 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
77class 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
116def perf_test_case(obj):
117 """Decorator for adding test classes"""
118 BuildPerfTestRunner.test_run_queue.append(obj)
119 return obj
120
121
75class BuildPerfTest(object): 122class BuildPerfTest(object):
76 """Base class for build performance tests""" 123 """Base class for build performance tests"""
77 SYSRES = 'sysres' 124 SYSRES = 'sysres'
diff --git a/scripts/oe-build-perf-test b/scripts/oe-build-perf-test
index 9589dee3ac..0a9fc9e7d4 100755
--- a/scripts/oe-build-perf-test
+++ b/scripts/oe-build-perf-test
@@ -18,11 +18,12 @@ import argparse
18import logging 18import logging
19import os 19import os
20import sys 20import sys
21from datetime import datetime
21 22
22sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') 23sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib')
23import scriptpath 24import scriptpath
24scriptpath.add_oe_lib_path() 25scriptpath.add_oe_lib_path()
25from oeqa.buildperf import KernelDropCaches 26from oeqa.buildperf import BuildPerfTestRunner, KernelDropCaches
26from oeqa.utils.commands import runCmd 27from oeqa.utils.commands import runCmd
27 28
28 29
@@ -75,7 +76,12 @@ def main(argv=None):
75 # Check our capability to drop caches and ask pass if needed 76 # Check our capability to drop caches and ask pass if needed
76 KernelDropCaches.check() 77 KernelDropCaches.check()
77 78
78 return 0 79 # Run actual tests
80 out_dir = 'results-{}'.format(datetime.now().strftime('%Y%m%d%H%M%S'))
81 runner = BuildPerfTestRunner(out_dir)
82 ret = runner.run_tests()
83
84 return ret
79 85
80 86
81if __name__ == '__main__': 87if __name__ == '__main__':