summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/buildperf/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/buildperf/base.py')
-rw-r--r--meta/lib/oeqa/buildperf/base.py47
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
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'