blob: 7b761d5936d15cf9b224eaed69a0db21f2a091a6 [file] [log] [blame]
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "Framework.h"
25
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010026#include "support/ToolchainSupport.h"
27
Moritz Pflanzer47752c92017-07-18 13:38:47 +010028#ifdef ARM_COMPUTE_CL
29#include "arm_compute/core/CL/OpenCL.h"
Anthony Barbierbf959222017-07-19 17:01:42 +010030#include "arm_compute/runtime/CL/CLScheduler.h"
Moritz Pflanzer47752c92017-07-18 13:38:47 +010031#endif /* ARM_COMPUTE_CL */
32
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010033#include <chrono>
34#include <iostream>
35#include <sstream>
36#include <type_traits>
37
38namespace arm_compute
39{
40namespace test
41{
42namespace framework
43{
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010044Framework::Framework()
45{
46 _available_instruments.emplace(InstrumentType::WALL_CLOCK_TIMER, Instrument::make_instrument<WallClockTimer>);
47#ifdef PMU_ENABLED
Moritz Pflanzer09e4f982017-08-30 12:47:06 +010048 _available_instruments.emplace(InstrumentType::PMU, Instrument::make_instrument<PMUCounter>);
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010049#endif /* PMU_ENABLED */
50}
51
52std::set<InstrumentType> Framework::available_instruments() const
53{
54 std::set<InstrumentType> types;
55
56 for(const auto &instrument : _available_instruments)
57 {
58 types.emplace(instrument.first);
59 }
60
61 return types;
62}
63
Moritz Pflanzerbf234e02017-07-24 15:04:14 +010064std::map<TestResult::Status, int> Framework::count_test_results() const
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010065{
Moritz Pflanzerbf234e02017-07-24 15:04:14 +010066 std::map<TestResult::Status, int> counts;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010067
68 for(const auto &test : _test_results)
69 {
Moritz Pflanzerbf234e02017-07-24 15:04:14 +010070 ++counts[test.second.status];
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010071 }
72
Moritz Pflanzerbf234e02017-07-24 15:04:14 +010073 return counts;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010074}
75
76Framework &Framework::get()
77{
78 static Framework instance;
79 return instance;
80}
81
Moritz Pflanzerec2de0f2017-07-27 14:43:46 +010082void Framework::init(const std::vector<InstrumentType> &instruments, int num_iterations, DatasetMode mode, const std::string &name_filter, const std::string &id_filter, LogLevel log_level)
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010083{
Moritz Pflanzerec2de0f2017-07-27 14:43:46 +010084 _test_filter = TestFilter(mode, name_filter, id_filter);
85 _num_iterations = num_iterations;
86 _log_level = log_level;
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010087
Moritz Pflanzer09e4f982017-08-30 12:47:06 +010088 _instruments = std::set<InstrumentType>(instruments.begin(), instruments.end());
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010089}
90
91std::string Framework::current_suite_name() const
92{
93 return join(_test_suite_name.cbegin(), _test_suite_name.cend(), "/");
94}
95
96void Framework::push_suite(std::string name)
97{
98 _test_suite_name.emplace_back(std::move(name));
99}
100
101void Framework::pop_suite()
102{
103 _test_suite_name.pop_back();
104}
105
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100106void Framework::add_test_info(std::string info)
107{
108 _test_info.emplace_back(std::move(info));
109}
110
111void Framework::clear_test_info()
112{
113 _test_info.clear();
114}
115
116bool Framework::has_test_info() const
117{
118 return !_test_info.empty();
119}
120
121void Framework::print_test_info(std::ostream &os) const
122{
Moritz Pflanzer8df3faf2017-07-28 13:57:53 +0100123 if(!_test_info.empty())
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100124 {
Moritz Pflanzer8df3faf2017-07-28 13:57:53 +0100125 os << "CONTEXT:\n";
126
127 for(const auto &str : _test_info)
128 {
129 os << " " << str << "\n";
130 }
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100131 }
132}
133
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100134void Framework::log_test_start(const TestInfo &info)
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100135{
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100136 if(_printer != nullptr && _log_level >= LogLevel::TESTS)
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100137 {
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100138 _printer->print_test_header(info);
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100139 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100140}
141
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100142void Framework::log_test_skipped(const TestInfo &info)
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100143{
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100144 static_cast<void>(info);
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100145}
146
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100147void Framework::log_test_end(const TestInfo &info)
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100148{
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100149 if(_printer != nullptr)
150 {
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100151 if(_log_level >= LogLevel::MEASUREMENTS)
152 {
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100153 _printer->print_measurements(_test_results.at(info).measurements);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100154 }
155
156 if(_log_level >= LogLevel::TESTS)
157 {
158 _printer->print_test_footer();
159 }
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100160 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100161}
162
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100163void Framework::log_failed_expectation(const TestError &error)
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100164{
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100165 if(_log_level >= error.level() && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100166 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100167 _printer->print_error(error);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100168 }
Moritz Pflanzere1103a82017-07-18 12:20:45 +0100169
170 if(_current_test_result != nullptr)
171 {
172 _current_test_result->status = TestResult::Status::FAILED;
173 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100174}
175
steniu01172c58d2017-08-31 13:49:08 +0100176void Framework::log_info(const std::string &info)
177{
178 if(_log_level >= LogLevel::DEBUG && _printer != nullptr)
179 {
180 _printer->print_info(info);
181 }
182}
183
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100184int Framework::num_iterations() const
185{
186 return _num_iterations;
187}
188
189void Framework::set_num_iterations(int num_iterations)
190{
191 _num_iterations = num_iterations;
192}
193
194void Framework::set_throw_errors(bool throw_errors)
195{
196 _throw_errors = throw_errors;
197}
198
199bool Framework::throw_errors() const
200{
201 return _throw_errors;
202}
203
Moritz Pflanzerfa811652017-07-26 17:00:37 +0100204void Framework::set_stop_on_error(bool stop_on_error)
205{
206 _stop_on_error = stop_on_error;
207}
208
209bool Framework::stop_on_error() const
210{
211 return _stop_on_error;
212}
213
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100214void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100215{
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100216 if(test_factory.status() == TestCaseFactory::Status::DISABLED)
217 {
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100218 log_test_skipped(info);
219 set_test_result(info, TestResult(TestResult::Status::DISABLED));
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100220 return;
221 }
222
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100223 log_test_start(info);
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100224
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100225 Profiler profiler = get_profiler();
Moritz Pflanzere33eb642017-07-31 14:48:45 +0100226 TestResult result(TestResult::Status::NOT_RUN);
Moritz Pflanzere1103a82017-07-18 12:20:45 +0100227
228 _current_test_result = &result;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100229
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100230 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
231 {
232 _printer->print_errors_header();
233 }
234
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100235 try
236 {
237 std::unique_ptr<TestCase> test_case = test_factory.make();
238
239 try
240 {
241 test_case->do_setup();
242
243 for(int i = 0; i < _num_iterations; ++i)
244 {
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100245 profiler.start();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100246 test_case->do_run();
Anthony Barbierbf959222017-07-19 17:01:42 +0100247#ifdef ARM_COMPUTE_CL
248 if(opencl_is_available())
249 {
250 CLScheduler::get().sync();
251 }
252#endif /* ARM_COMPUTE_CL */
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100253 profiler.stop();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100254 }
255
256 test_case->do_teardown();
Moritz Pflanzere33eb642017-07-31 14:48:45 +0100257
258 // Change status to success if no error has happend
259 if(result.status == TestResult::Status::NOT_RUN)
260 {
261 result.status = TestResult::Status::SUCCESS;
262 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100263 }
264 catch(const TestError &error)
265 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100266 if(_log_level >= error.level() && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100267 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100268 _printer->print_error(error);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100269 }
270
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100271 result.status = TestResult::Status::FAILED;
272
273 if(_throw_errors)
274 {
275 throw;
276 }
277 }
Moritz Pflanzer47752c92017-07-18 13:38:47 +0100278#ifdef ARM_COMPUTE_CL
279 catch(const ::cl::Error &error)
280 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100281 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100282 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100283 std::stringstream stream;
284 stream << "Error code: " << error.err();
285 _printer->print_error(TestError(error.what(), LogLevel::ERRORS, stream.str()));
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100286 }
287
Moritz Pflanzer47752c92017-07-18 13:38:47 +0100288 result.status = TestResult::Status::FAILED;
289
290 if(_throw_errors)
291 {
292 throw;
293 }
294 }
295#endif /* ARM_COMPUTE_CL */
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100296 catch(const std::exception &error)
297 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100298 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100299 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100300 _printer->print_error(error);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100301 }
302
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100303 result.status = TestResult::Status::CRASHED;
304
305 if(_throw_errors)
306 {
307 throw;
308 }
309 }
310 catch(...)
311 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100312 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100313 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100314 _printer->print_error(TestError("Received unknown exception"));
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100315 }
316
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100317 result.status = TestResult::Status::CRASHED;
318
319 if(_throw_errors)
320 {
321 throw;
322 }
323 }
324 }
325 catch(const std::exception &error)
326 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100327 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100328 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100329 _printer->print_error(error);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100330 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100331
Moritz Pflanzere33eb642017-07-31 14:48:45 +0100332 result.status = TestResult::Status::CRASHED;
333
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100334 if(_throw_errors)
335 {
336 throw;
337 }
338 }
339 catch(...)
340 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100341 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100342 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100343 _printer->print_error(TestError("Received unknown exception"));
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100344 }
345
Moritz Pflanzere1103a82017-07-18 12:20:45 +0100346 result.status = TestResult::Status::CRASHED;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100347
348 if(_throw_errors)
349 {
350 throw;
351 }
352 }
353
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100354 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
355 {
356 _printer->print_errors_footer();
357 }
358
Moritz Pflanzere1103a82017-07-18 12:20:45 +0100359 _current_test_result = nullptr;
360
Moritz Pflanzerfa811652017-07-26 17:00:37 +0100361 if(result.status == TestResult::Status::FAILED)
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100362 {
Moritz Pflanzerfa811652017-07-26 17:00:37 +0100363 if(info.status == TestCaseFactory::Status::EXPECTED_FAILURE)
364 {
365 result.status = TestResult::Status::EXPECTED_FAILURE;
366 }
Moritz Pflanzere33eb642017-07-31 14:48:45 +0100367 }
368
369 if(result.status == TestResult::Status::FAILED || result.status == TestResult::Status::CRASHED)
370 {
371 if(_stop_on_error)
Moritz Pflanzerfa811652017-07-26 17:00:37 +0100372 {
373 throw std::runtime_error("Abort on first error.");
374 }
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100375 }
376
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100377 result.measurements = profiler.measurements();
378
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100379 set_test_result(info, result);
380 log_test_end(info);
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100381}
382
383bool Framework::run()
384{
385 // Clear old test results
386 _test_results.clear();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100387
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100388 if(_printer != nullptr && _log_level >= LogLevel::TESTS)
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100389 {
390 _printer->print_run_header();
391 }
392
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100393 const std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100394
395 int id = 0;
396
397 for(auto &test_factory : _test_factories)
398 {
399 const std::string test_case_name = test_factory->name();
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100400 const TestInfo test_info{ id, test_case_name, test_factory->mode(), test_factory->status() };
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100401
Moritz Pflanzerec2de0f2017-07-27 14:43:46 +0100402 if(_test_filter.is_selected(test_info))
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100403 {
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100404 run_test(test_info, *test_factory);
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100405 }
406
407 ++id;
408 }
409
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100410 const std::chrono::time_point<std::chrono::high_resolution_clock> end = std::chrono::high_resolution_clock::now();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100411
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100412 if(_printer != nullptr && _log_level >= LogLevel::TESTS)
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100413 {
414 _printer->print_run_footer();
415 }
416
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100417 auto runtime = std::chrono::duration_cast<std::chrono::seconds>(end - start);
418 std::map<TestResult::Status, int> results = count_test_results();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100419
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100420 if(_log_level > LogLevel::NONE)
421 {
Moritz Pflanzer8df3faf2017-07-28 13:57:53 +0100422 std::cout << "Executed " << _test_results.size() << " test(s) ("
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100423 << results[TestResult::Status::SUCCESS] << " passed, "
424 << results[TestResult::Status::EXPECTED_FAILURE] << " expected failures, "
425 << results[TestResult::Status::FAILED] << " failed, "
426 << results[TestResult::Status::CRASHED] << " crashed, "
427 << results[TestResult::Status::DISABLED] << " disabled) in " << runtime.count() << " second(s)\n";
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100428 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100429
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100430 int num_successful_tests = results[TestResult::Status::SUCCESS] + results[TestResult::Status::EXPECTED_FAILURE];
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100431
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100432 return (static_cast<unsigned int>(num_successful_tests) == _test_results.size());
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100433}
434
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100435void Framework::set_test_result(TestInfo info, TestResult result)
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100436{
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100437 _test_results.emplace(std::move(info), std::move(result));
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100438}
439
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100440void Framework::print_test_results(Printer &printer) const
441{
442 printer.print_run_header();
443
444 for(const auto &test : _test_results)
445 {
446 printer.print_test_header(test.first);
447 printer.print_measurements(test.second.measurements);
448 printer.print_test_footer();
449 }
450
451 printer.print_run_footer();
452}
453
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100454Profiler Framework::get_profiler() const
455{
456 Profiler profiler;
457
Moritz Pflanzer09e4f982017-08-30 12:47:06 +0100458 const bool all_instruments = std::any_of(
459 _instruments.begin(),
460 _instruments.end(),
461 [](InstrumentType type) -> bool { return type == InstrumentType::ALL; });
462
463 auto is_selected = [&](InstrumentType instrument) -> bool
464 {
465 return std::find_if(_instruments.begin(), _instruments.end(), [&](InstrumentType type) -> bool {
466 const auto group = static_cast<InstrumentType>(static_cast<uint64_t>(type) & 0xFF00);
467 return group == instrument;
468 })
469 != _instruments.end();
470 };
471
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100472 for(const auto &instrument : _available_instruments)
473 {
Moritz Pflanzer09e4f982017-08-30 12:47:06 +0100474 if(all_instruments || is_selected(instrument.first))
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100475 {
476 profiler.add(instrument.second());
477 }
478 }
479
480 return profiler;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100481}
482
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100483void Framework::set_printer(Printer *printer)
484{
485 _printer = printer;
486}
487
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100488std::vector<TestInfo> Framework::test_infos() const
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100489{
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100490 std::vector<TestInfo> ids;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100491
492 int id = 0;
493
494 for(const auto &factory : _test_factories)
495 {
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100496 TestInfo test_info{ id, factory->name(), factory->mode(), factory->status() };
497
Moritz Pflanzerec2de0f2017-07-27 14:43:46 +0100498 if(_test_filter.is_selected(test_info))
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100499 {
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100500 ids.emplace_back(std::move(test_info));
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100501 }
502
503 ++id;
504 }
505
506 return ids;
507}
steniu01172c58d2017-08-31 13:49:08 +0100508
509LogLevel Framework::log_level() const
510{
511 return _log_level;
512}
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100513} // namespace framework
514} // namespace test
515} // namespace arm_compute