blob: 31e524338b0d0bc2b5fb609d20770ef5346ad0c5 [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 Pflanzer5b61fd32017-09-12 15:51:33 +0100167 constexpr bool expected_error = true;
168 _printer->print_error(error, expected_error);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100169 }
Moritz Pflanzere1103a82017-07-18 12:20:45 +0100170
171 if(_current_test_result != nullptr)
172 {
173 _current_test_result->status = TestResult::Status::FAILED;
174 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100175}
176
steniu01172c58d2017-08-31 13:49:08 +0100177void Framework::log_info(const std::string &info)
178{
179 if(_log_level >= LogLevel::DEBUG && _printer != nullptr)
180 {
181 _printer->print_info(info);
182 }
183}
184
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100185int Framework::num_iterations() const
186{
187 return _num_iterations;
188}
189
190void Framework::set_num_iterations(int num_iterations)
191{
192 _num_iterations = num_iterations;
193}
194
195void Framework::set_throw_errors(bool throw_errors)
196{
197 _throw_errors = throw_errors;
198}
199
200bool Framework::throw_errors() const
201{
202 return _throw_errors;
203}
204
Moritz Pflanzerfa811652017-07-26 17:00:37 +0100205void Framework::set_stop_on_error(bool stop_on_error)
206{
207 _stop_on_error = stop_on_error;
208}
209
210bool Framework::stop_on_error() const
211{
212 return _stop_on_error;
213}
214
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100215void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100216{
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100217 if(test_factory.status() == TestCaseFactory::Status::DISABLED)
218 {
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100219 log_test_skipped(info);
220 set_test_result(info, TestResult(TestResult::Status::DISABLED));
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100221 return;
222 }
223
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100224 log_test_start(info);
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100225
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100226 Profiler profiler = get_profiler();
Moritz Pflanzere33eb642017-07-31 14:48:45 +0100227 TestResult result(TestResult::Status::NOT_RUN);
Moritz Pflanzere1103a82017-07-18 12:20:45 +0100228
229 _current_test_result = &result;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100230
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100231 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
232 {
233 _printer->print_errors_header();
234 }
235
Moritz Pflanzer5b61fd32017-09-12 15:51:33 +0100236 const bool is_expected_failure = test_factory.status() == TestCaseFactory::Status::EXPECTED_FAILURE;
237
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100238 try
239 {
240 std::unique_ptr<TestCase> test_case = test_factory.make();
241
242 try
243 {
244 test_case->do_setup();
245
246 for(int i = 0; i < _num_iterations; ++i)
247 {
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100248 profiler.start();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100249 test_case->do_run();
Anthony Barbierbf959222017-07-19 17:01:42 +0100250#ifdef ARM_COMPUTE_CL
251 if(opencl_is_available())
252 {
253 CLScheduler::get().sync();
254 }
255#endif /* ARM_COMPUTE_CL */
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100256 profiler.stop();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100257 }
258
259 test_case->do_teardown();
Moritz Pflanzere33eb642017-07-31 14:48:45 +0100260
261 // Change status to success if no error has happend
262 if(result.status == TestResult::Status::NOT_RUN)
263 {
264 result.status = TestResult::Status::SUCCESS;
265 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100266 }
267 catch(const TestError &error)
268 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100269 if(_log_level >= error.level() && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100270 {
Moritz Pflanzer5b61fd32017-09-12 15:51:33 +0100271 _printer->print_error(error, is_expected_failure);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100272 }
273
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100274 result.status = TestResult::Status::FAILED;
275
276 if(_throw_errors)
277 {
278 throw;
279 }
280 }
Moritz Pflanzer47752c92017-07-18 13:38:47 +0100281#ifdef ARM_COMPUTE_CL
282 catch(const ::cl::Error &error)
283 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100284 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100285 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100286 std::stringstream stream;
287 stream << "Error code: " << error.err();
Moritz Pflanzer5b61fd32017-09-12 15:51:33 +0100288 TestError test_error(error.what(), LogLevel::ERRORS, stream.str());
289 _printer->print_error(test_error, is_expected_failure);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100290 }
291
Moritz Pflanzer47752c92017-07-18 13:38:47 +0100292 result.status = TestResult::Status::FAILED;
293
294 if(_throw_errors)
295 {
296 throw;
297 }
298 }
299#endif /* ARM_COMPUTE_CL */
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100300 catch(const std::exception &error)
301 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100302 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100303 {
Moritz Pflanzer5b61fd32017-09-12 15:51:33 +0100304 _printer->print_error(error, is_expected_failure);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100305 }
306
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100307 result.status = TestResult::Status::CRASHED;
308
309 if(_throw_errors)
310 {
311 throw;
312 }
313 }
314 catch(...)
315 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100316 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100317 {
Moritz Pflanzer5b61fd32017-09-12 15:51:33 +0100318 _printer->print_error(TestError("Received unknown exception"), is_expected_failure);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100319 }
320
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100321 result.status = TestResult::Status::CRASHED;
322
323 if(_throw_errors)
324 {
325 throw;
326 }
327 }
328 }
329 catch(const std::exception &error)
330 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100331 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100332 {
Moritz Pflanzer5b61fd32017-09-12 15:51:33 +0100333 _printer->print_error(error, is_expected_failure);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100334 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100335
Moritz Pflanzere33eb642017-07-31 14:48:45 +0100336 result.status = TestResult::Status::CRASHED;
337
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100338 if(_throw_errors)
339 {
340 throw;
341 }
342 }
343 catch(...)
344 {
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100345 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100346 {
Moritz Pflanzer5b61fd32017-09-12 15:51:33 +0100347 _printer->print_error(TestError("Received unknown exception"), is_expected_failure);
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100348 }
349
Moritz Pflanzere1103a82017-07-18 12:20:45 +0100350 result.status = TestResult::Status::CRASHED;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100351
352 if(_throw_errors)
353 {
354 throw;
355 }
356 }
357
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100358 if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
359 {
360 _printer->print_errors_footer();
361 }
362
Moritz Pflanzere1103a82017-07-18 12:20:45 +0100363 _current_test_result = nullptr;
364
Moritz Pflanzerfa811652017-07-26 17:00:37 +0100365 if(result.status == TestResult::Status::FAILED)
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100366 {
Moritz Pflanzerfa811652017-07-26 17:00:37 +0100367 if(info.status == TestCaseFactory::Status::EXPECTED_FAILURE)
368 {
369 result.status = TestResult::Status::EXPECTED_FAILURE;
370 }
Moritz Pflanzere33eb642017-07-31 14:48:45 +0100371 }
372
373 if(result.status == TestResult::Status::FAILED || result.status == TestResult::Status::CRASHED)
374 {
375 if(_stop_on_error)
Moritz Pflanzerfa811652017-07-26 17:00:37 +0100376 {
377 throw std::runtime_error("Abort on first error.");
378 }
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100379 }
380
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100381 result.measurements = profiler.measurements();
382
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100383 set_test_result(info, result);
384 log_test_end(info);
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100385}
386
387bool Framework::run()
388{
389 // Clear old test results
390 _test_results.clear();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100391
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100392 if(_printer != nullptr && _log_level >= LogLevel::TESTS)
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100393 {
394 _printer->print_run_header();
395 }
396
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100397 const std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100398
399 int id = 0;
400
401 for(auto &test_factory : _test_factories)
402 {
403 const std::string test_case_name = test_factory->name();
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100404 const TestInfo test_info{ id, test_case_name, test_factory->mode(), test_factory->status() };
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100405
Moritz Pflanzerec2de0f2017-07-27 14:43:46 +0100406 if(_test_filter.is_selected(test_info))
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100407 {
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100408 run_test(test_info, *test_factory);
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100409 }
410
411 ++id;
412 }
413
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100414 const std::chrono::time_point<std::chrono::high_resolution_clock> end = std::chrono::high_resolution_clock::now();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100415
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100416 if(_printer != nullptr && _log_level >= LogLevel::TESTS)
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100417 {
418 _printer->print_run_footer();
419 }
420
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100421 auto runtime = std::chrono::duration_cast<std::chrono::seconds>(end - start);
422 std::map<TestResult::Status, int> results = count_test_results();
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100423
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100424 if(_log_level > LogLevel::NONE)
425 {
Moritz Pflanzer8df3faf2017-07-28 13:57:53 +0100426 std::cout << "Executed " << _test_results.size() << " test(s) ("
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100427 << results[TestResult::Status::SUCCESS] << " passed, "
428 << results[TestResult::Status::EXPECTED_FAILURE] << " expected failures, "
429 << results[TestResult::Status::FAILED] << " failed, "
430 << results[TestResult::Status::CRASHED] << " crashed, "
431 << results[TestResult::Status::DISABLED] << " disabled) in " << runtime.count() << " second(s)\n";
Moritz Pflanzer2ac50402017-07-24 15:52:54 +0100432 }
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100433
steniu013e05e4e2017-08-25 17:18:01 +0100434 int num_successful_tests = results[TestResult::Status::SUCCESS] + results[TestResult::Status::EXPECTED_FAILURE] + results[TestResult::Status::DISABLED];
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100435
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100436 return (static_cast<unsigned int>(num_successful_tests) == _test_results.size());
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100437}
438
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100439void Framework::set_test_result(TestInfo info, TestResult result)
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100440{
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100441 _test_results.emplace(std::move(info), std::move(result));
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100442}
443
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100444void Framework::print_test_results(Printer &printer) const
445{
446 printer.print_run_header();
447
448 for(const auto &test : _test_results)
449 {
450 printer.print_test_header(test.first);
451 printer.print_measurements(test.second.measurements);
452 printer.print_test_footer();
453 }
454
455 printer.print_run_footer();
456}
457
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100458Profiler Framework::get_profiler() const
459{
460 Profiler profiler;
461
Moritz Pflanzer09e4f982017-08-30 12:47:06 +0100462 const bool all_instruments = std::any_of(
463 _instruments.begin(),
464 _instruments.end(),
465 [](InstrumentType type) -> bool { return type == InstrumentType::ALL; });
466
467 auto is_selected = [&](InstrumentType instrument) -> bool
468 {
469 return std::find_if(_instruments.begin(), _instruments.end(), [&](InstrumentType type) -> bool {
470 const auto group = static_cast<InstrumentType>(static_cast<uint64_t>(type) & 0xFF00);
471 return group == instrument;
472 })
473 != _instruments.end();
474 };
475
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100476 for(const auto &instrument : _available_instruments)
477 {
Moritz Pflanzer09e4f982017-08-30 12:47:06 +0100478 if(all_instruments || is_selected(instrument.first))
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100479 {
480 profiler.add(instrument.second());
481 }
482 }
483
484 return profiler;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100485}
486
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100487void Framework::set_printer(Printer *printer)
488{
489 _printer = printer;
490}
491
Moritz Pflanzer542002c2017-07-26 16:03:58 +0100492std::vector<TestInfo> Framework::test_infos() const
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100493{
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100494 std::vector<TestInfo> ids;
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100495
496 int id = 0;
497
498 for(const auto &factory : _test_factories)
499 {
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100500 TestInfo test_info{ id, factory->name(), factory->mode(), factory->status() };
501
Moritz Pflanzerec2de0f2017-07-27 14:43:46 +0100502 if(_test_filter.is_selected(test_info))
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100503 {
Moritz Pflanzerbf234e02017-07-24 15:04:14 +0100504 ids.emplace_back(std::move(test_info));
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100505 }
506
507 ++id;
508 }
509
510 return ids;
511}
steniu01172c58d2017-08-31 13:49:08 +0100512
513LogLevel Framework::log_level() const
514{
515 return _log_level;
516}
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +0100517} // namespace framework
518} // namespace test
519} // namespace arm_compute