Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 1 | /* |
Ramy Elgammal | 1355ec4 | 2023-05-15 13:50:46 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2021, 2023 Arm Limited. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 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 | #ifndef ARM_COMPUTE_TEST_FRAMEWORK |
| 25 | #define ARM_COMPUTE_TEST_FRAMEWORK |
| 26 | |
Moritz Pflanzer | d03b00a | 2017-07-17 13:50:12 +0100 | [diff] [blame] | 27 | #include "DatasetModes.h" |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 28 | #include "Exceptions.h" |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 29 | #include "Profiler.h" |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 30 | #include "TestCase.h" |
| 31 | #include "TestCaseFactory.h" |
| 32 | #include "TestResult.h" |
| 33 | #include "Utils.h" |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 34 | #include "instruments/Instruments.h" |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 35 | #include "printers/Printer.h" |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 36 | |
| 37 | #include <algorithm> |
| 38 | #include <chrono> |
| 39 | #include <map> |
| 40 | #include <memory> |
| 41 | #include <numeric> |
| 42 | #include <ostream> |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 43 | #include <set> |
| 44 | #include <sstream> |
| 45 | #include <string> |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 46 | #include <vector> |
| 47 | |
| 48 | namespace arm_compute |
| 49 | { |
| 50 | namespace test |
| 51 | { |
| 52 | namespace framework |
| 53 | { |
Matthew Bentham | 470bc1e | 2020-03-09 10:55:40 +0000 | [diff] [blame] | 54 | class TestFilter; |
| 55 | |
Georgios Pinitas | 7f15251 | 2019-12-16 19:59:52 +0000 | [diff] [blame] | 56 | /** Framework configuration structure */ |
| 57 | struct FrameworkConfig |
| 58 | { |
| 59 | std::vector<framework::InstrumentsDescription> instruments{}; /**< Instrument types that will be used for benchmarking. */ |
| 60 | std::string name_filter{}; /**< Regular expression to filter tests by name. Only matching tests will be executed. */ |
| 61 | std::string id_filter{}; /**< String to match selected test ids. Only matching tests will be executed. */ |
| 62 | DatasetMode mode{ DatasetMode::ALL }; /**< Dataset mode. */ |
| 63 | int num_iterations{ 1 }; /**< Number of iterations per test. */ |
| 64 | float cooldown_sec{ -1.f }; /**< Delay between tests in seconds. */ |
| 65 | LogLevel log_level{ LogLevel::NONE }; /**< Verbosity of the output. */ |
Giorgio Arena | 68e29da | 2021-02-08 16:31:10 +0000 | [diff] [blame] | 66 | bool configure_only{ false }; /**< Only configure kernels */ |
Ramy Elgammal | 1355ec4 | 2023-05-15 13:50:46 +0100 | [diff] [blame] | 67 | bool print_rerun_cmd{ false }; /**< Print the command to rerun the failed testcase */ |
| 68 | unsigned int seed{0}; /**< The seed that is used to fill tensors with random values.*/ |
Georgios Pinitas | 7f15251 | 2019-12-16 19:59:52 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 71 | /** Information about a test case. |
| 72 | * |
| 73 | * A test can be identified either via its id or via its name. Additionally |
| 74 | * each test is tagged with the data set mode in which it will be used and |
| 75 | * its status. |
| 76 | * |
| 77 | * @note The mapping between test id and test name is not guaranteed to be |
| 78 | * stable. It is subject to change as new test are added. |
| 79 | */ |
| 80 | struct TestInfo |
| 81 | { |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 82 | int id; /**< Test ID */ |
| 83 | std::string name; /**< Test name */ |
| 84 | DatasetMode mode; /**< Test data set mode */ |
| 85 | TestCaseFactory::Status status; /**< Test status */ |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | inline bool operator<(const TestInfo &lhs, const TestInfo &rhs) |
| 89 | { |
| 90 | return lhs.id < rhs.id; |
| 91 | } |
| 92 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 93 | /** Main framework class. |
| 94 | * |
| 95 | * Keeps track of the global state, owns all test cases and collects results. |
| 96 | */ |
| 97 | class Framework final |
| 98 | { |
| 99 | public: |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 100 | /** Access to the singleton. |
| 101 | * |
| 102 | * @return Unique instance of the framework class. |
| 103 | */ |
| 104 | static Framework &get(); |
| 105 | |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 106 | /** Supported instrument types for benchmarking. |
| 107 | * |
| 108 | * @return Set of all available instrument types. |
| 109 | */ |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 110 | std::set<InstrumentsDescription> available_instruments() const; |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 111 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 112 | /** Init the framework. |
| 113 | * |
Moritz Pflanzer | ec2de0f | 2017-07-27 14:43:46 +0100 | [diff] [blame] | 114 | * @see TestFilter::TestFilter for the format of the string to filter ids. |
| 115 | * |
Georgios Pinitas | 7f15251 | 2019-12-16 19:59:52 +0000 | [diff] [blame] | 116 | * @param[in] config Framework configuration meta-data. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 117 | */ |
Georgios Pinitas | 7f15251 | 2019-12-16 19:59:52 +0000 | [diff] [blame] | 118 | void init(const FrameworkConfig &config); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 119 | |
| 120 | /** Add a new test suite. |
| 121 | * |
| 122 | * @warning Cannot be used at execution time. It can only be used for |
| 123 | * registering test cases. |
| 124 | * |
| 125 | * @param[in] name Name of the added test suite. |
| 126 | * |
| 127 | * @return Name of the current test suite. |
| 128 | */ |
| 129 | void push_suite(std::string name); |
| 130 | |
| 131 | /** Remove innermost test suite. |
| 132 | * |
| 133 | * @warning Cannot be used at execution time. It can only be used for |
| 134 | * registering test cases. |
| 135 | */ |
| 136 | void pop_suite(); |
| 137 | |
| 138 | /** Add a test case to the framework. |
| 139 | * |
| 140 | * @param[in] test_name Name of the new test case. |
Moritz Pflanzer | d03b00a | 2017-07-17 13:50:12 +0100 | [diff] [blame] | 141 | * @param[in] mode Mode in which to include the test. |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 142 | * @param[in] status Status of the test case. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 143 | */ |
| 144 | template <typename T> |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 145 | void add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 146 | |
| 147 | /** Add a data test case to the framework. |
| 148 | * |
| 149 | * @param[in] test_name Name of the new test case. |
Moritz Pflanzer | d03b00a | 2017-07-17 13:50:12 +0100 | [diff] [blame] | 150 | * @param[in] mode Mode in which to include the test. |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 151 | * @param[in] status Status of the test case. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 152 | * @param[in] description Description of @p data. |
| 153 | * @param[in] data Data that will be used as input to the test. |
| 154 | */ |
| 155 | template <typename T, typename D> |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 156 | void add_data_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, std::string description, D &&data); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 157 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 158 | /** Add info string for the next expectation/assertion. |
| 159 | * |
| 160 | * @param[in] info Info string. |
| 161 | */ |
| 162 | void add_test_info(std::string info); |
| 163 | |
| 164 | /** Clear the collected test info. */ |
| 165 | void clear_test_info(); |
| 166 | |
| 167 | /** Check if any info has been registered. |
| 168 | * |
| 169 | * @return True if there is test info. |
| 170 | */ |
| 171 | bool has_test_info() const; |
| 172 | |
| 173 | /** Print test info. |
| 174 | * |
| 175 | * @param[out] os Output stream. |
| 176 | */ |
| 177 | void print_test_info(std::ostream &os) const; |
| 178 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 179 | /** Tell the framework that execution of a test starts. |
| 180 | * |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 181 | * @param[in] info Test info. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 182 | */ |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 183 | void log_test_start(const TestInfo &info); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 184 | |
| 185 | /** Tell the framework that a test case is skipped. |
| 186 | * |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 187 | * @param[in] info Test info. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 188 | */ |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 189 | void log_test_skipped(const TestInfo &info); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 190 | |
| 191 | /** Tell the framework that a test case finished. |
| 192 | * |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 193 | * @param[in] info Test info. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 194 | */ |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 195 | void log_test_end(const TestInfo &info); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 196 | |
| 197 | /** Tell the framework that the currently running test case failed a non-fatal expectation. |
| 198 | * |
Moritz Pflanzer | 24a8246 | 2017-08-04 11:34:44 +0100 | [diff] [blame] | 199 | * @param[in] error Description of the error. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 200 | */ |
Moritz Pflanzer | 24a8246 | 2017-08-04 11:34:44 +0100 | [diff] [blame] | 201 | void log_failed_expectation(const TestError &error); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 202 | |
steniu01 | 172c58d | 2017-08-31 13:49:08 +0100 | [diff] [blame] | 203 | /** Print the debug information that has already been logged |
| 204 | * |
| 205 | * @param[in] info Description of the log info. |
| 206 | */ |
| 207 | void log_info(const std::string &info); |
| 208 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 209 | /** Number of iterations per test case. |
| 210 | * |
| 211 | * @return Number of iterations per test case. |
| 212 | */ |
| 213 | int num_iterations() const; |
| 214 | |
| 215 | /** Set number of iterations per test case. |
| 216 | * |
| 217 | * @param[in] num_iterations Number of iterations per test case. |
| 218 | */ |
| 219 | void set_num_iterations(int num_iterations); |
| 220 | |
| 221 | /** Should errors be caught or thrown by the framework. |
| 222 | * |
| 223 | * @return True if errors are thrown. |
| 224 | */ |
| 225 | bool throw_errors() const; |
| 226 | |
| 227 | /** Set whether errors are caught or thrown by the framework. |
| 228 | * |
| 229 | * @param[in] throw_errors True if errors should be thrown. |
| 230 | */ |
| 231 | void set_throw_errors(bool throw_errors); |
| 232 | |
Moritz Pflanzer | fa81165 | 2017-07-26 17:00:37 +0100 | [diff] [blame] | 233 | /** Indicates if test execution is stopped after the first failed test. |
| 234 | * |
ramelg01 | b2eba7f | 2021-12-23 08:32:08 +0000 | [diff] [blame] | 235 | * @return True if the execution is going to be stopped after the first failed test. |
Moritz Pflanzer | fa81165 | 2017-07-26 17:00:37 +0100 | [diff] [blame] | 236 | */ |
| 237 | bool stop_on_error() const; |
| 238 | |
ramelg01 | b2eba7f | 2021-12-23 08:32:08 +0000 | [diff] [blame] | 239 | /** Set whether to stop execution after the first failed test. |
Moritz Pflanzer | fa81165 | 2017-07-26 17:00:37 +0100 | [diff] [blame] | 240 | * |
ramelg01 | b2eba7f | 2021-12-23 08:32:08 +0000 | [diff] [blame] | 241 | * @param[in] stop_on_error True if execution is going to be stopped after first failed test. |
Moritz Pflanzer | fa81165 | 2017-07-26 17:00:37 +0100 | [diff] [blame] | 242 | */ |
| 243 | void set_stop_on_error(bool stop_on_error); |
| 244 | |
Anthony Barbier | f6705ec | 2017-09-28 12:01:10 +0100 | [diff] [blame] | 245 | /** Indicates if a test should be marked as failed when its assets are missing. |
| 246 | * |
| 247 | * @return True if a test should be marked as failed when its assets are missing. |
| 248 | */ |
| 249 | bool error_on_missing_assets() const; |
| 250 | |
| 251 | /** Set whether a test should be considered as failed if its assets cannot be found. |
| 252 | * |
| 253 | * @param[in] error_on_missing_assets True if a test should be marked as failed when its assets are missing. |
| 254 | */ |
| 255 | void set_error_on_missing_assets(bool error_on_missing_assets); |
| 256 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 257 | /** Run all enabled test cases. |
| 258 | * |
| 259 | * @return True if all test cases executed successful. |
| 260 | */ |
| 261 | bool run(); |
| 262 | |
| 263 | /** Set the result for an executed test case. |
| 264 | * |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 265 | * @param[in] info Test info. |
| 266 | * @param[in] result Execution result. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 267 | */ |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 268 | void set_test_result(TestInfo info, TestResult result); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 269 | |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 270 | /** Use the specified printer to output test results from the last run. |
| 271 | * |
| 272 | * This method can be used if the test results need to be obtained using a |
| 273 | * different printer than the one managed by the framework. |
| 274 | * |
| 275 | * @param[in] printer Printer used to output results. |
| 276 | */ |
| 277 | void print_test_results(Printer &printer) const; |
| 278 | |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 279 | /** Factory method to obtain a configured profiler. |
| 280 | * |
| 281 | * The profiler enables all instruments that have been passed to the @ref |
| 282 | * init method. |
| 283 | * |
| 284 | * @return Configured profiler to collect benchmark results. |
| 285 | */ |
| 286 | Profiler get_profiler() const; |
| 287 | |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 288 | /** Set the printer used for the output of test results. |
| 289 | * |
| 290 | * @param[in] printer Pointer to a printer. |
| 291 | */ |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 292 | void add_printer(Printer *printer); |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 293 | |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 294 | /** List of @ref TestInfo's. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 295 | * |
| 296 | * @return Vector with all test ids. |
| 297 | */ |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 298 | std::vector<TestInfo> test_infos() const; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 299 | |
steniu01 | 172c58d | 2017-08-31 13:49:08 +0100 | [diff] [blame] | 300 | /** Get the current logging level |
| 301 | * |
| 302 | * @return The current logging level. |
| 303 | */ |
| 304 | LogLevel log_level() const; |
Georgios Pinitas | 12833d0 | 2019-07-25 13:31:10 +0100 | [diff] [blame] | 305 | /** Sets instruments info |
| 306 | * |
| 307 | * @note TODO(COMPMID-2638) : Remove once instruments are transferred outside the framework. |
| 308 | * |
| 309 | * @param[in] instr_info Instruments info to set |
| 310 | */ |
| 311 | void set_instruments_info(InstrumentsInfo instr_info); |
Giorgio Arena | 68e29da | 2021-02-08 16:31:10 +0000 | [diff] [blame] | 312 | /** Get the configure only flag |
| 313 | * |
| 314 | * @return The current configure only flag. |
| 315 | */ |
| 316 | bool configure_only() const; |
| 317 | /** Return whether the new fixture has been called |
| 318 | * |
| 319 | * @return The current new fixture call flag. |
| 320 | */ |
| 321 | bool new_fixture_call() const; |
| 322 | /** Set the new fixture call flag |
| 323 | * |
| 324 | * @param[in] val Value to set for the flag |
| 325 | */ |
| 326 | void set_new_fixture_call(bool val); |
steniu01 | 172c58d | 2017-08-31 13:49:08 +0100 | [diff] [blame] | 327 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 328 | private: |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 329 | Framework(); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 330 | ~Framework() = default; |
| 331 | |
| 332 | Framework(const Framework &) = delete; |
| 333 | Framework &operator=(const Framework &) = delete; |
| 334 | |
Ramy Elgammal | 1355ec4 | 2023-05-15 13:50:46 +0100 | [diff] [blame] | 335 | TestResult::Status run_test(const TestInfo &info, TestCaseFactory &test_factory); |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 336 | std::map<TestResult::Status, int> count_test_results() const; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 337 | |
| 338 | /** Returns the current test suite name. |
| 339 | * |
| 340 | * @warning Cannot be used at execution time to get the test suite of the |
| 341 | * currently executed test case. It can only be used for registering test |
| 342 | * cases. |
| 343 | * |
| 344 | * @return Name of the current test suite. |
| 345 | */ |
| 346 | std::string current_suite_name() const; |
| 347 | |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 348 | /* Perform func on all printers */ |
| 349 | template <typename F> |
| 350 | void func_on_all_printers(F &&func); |
| 351 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 352 | std::vector<std::string> _test_suite_name{}; |
| 353 | std::vector<std::unique_ptr<TestCaseFactory>> _test_factories{}; |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 354 | std::map<TestInfo, TestResult> _test_results{}; |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 355 | int _num_iterations{ 1 }; |
Georgios Pinitas | 7f15251 | 2019-12-16 19:59:52 +0000 | [diff] [blame] | 356 | float _cooldown_sec{ -1.f }; |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 357 | bool _throw_errors{ false }; |
| 358 | bool _stop_on_error{ false }; |
| 359 | bool _error_on_missing_assets{ false }; |
| 360 | std::vector<Printer *> _printers{}; |
Giorgio Arena | 68e29da | 2021-02-08 16:31:10 +0000 | [diff] [blame] | 361 | bool _configure_only{ false }; |
| 362 | bool _new_fixture_call{ false }; |
Ramy Elgammal | 1355ec4 | 2023-05-15 13:50:46 +0100 | [diff] [blame] | 363 | bool _print_rerun_cmd{ false }; |
| 364 | unsigned int _seed {0}; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 365 | |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 366 | using create_function = std::unique_ptr<Instrument>(); |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 367 | std::map<InstrumentsDescription, create_function *> _available_instruments{}; |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 368 | |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 369 | std::set<framework::InstrumentsDescription> _instruments{ std::pair<InstrumentType, ScaleFactor>(InstrumentType::NONE, ScaleFactor::NONE) }; |
Matthew Bentham | 470bc1e | 2020-03-09 10:55:40 +0000 | [diff] [blame] | 370 | std::unique_ptr<TestFilter> _test_filter; |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 371 | LogLevel _log_level{ LogLevel::ALL }; |
| 372 | const TestInfo *_current_test_info{ nullptr }; |
| 373 | TestResult *_current_test_result{ nullptr }; |
| 374 | std::vector<std::string> _test_info{}; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 375 | }; |
| 376 | |
| 377 | template <typename T> |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 378 | inline void Framework::add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 379 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 380 | _test_factories.emplace_back(std::make_unique<SimpleTestCaseFactory<T>>(current_suite_name(), std::move(test_name), mode, status)); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | template <typename T, typename D> |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 384 | inline void Framework::add_data_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, std::string description, D &&data) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 385 | { |
| 386 | // WORKAROUND for GCC 4.9 |
| 387 | // The function should get *it which is tuple but that seems to trigger a |
| 388 | // bug in the compiler. |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 389 | auto tmp = std::unique_ptr<DataTestCaseFactory<T, decltype(*std::declval<D>())>>(new DataTestCaseFactory<T, decltype(*std::declval<D>())>(current_suite_name(), std::move(test_name), mode, status, |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 390 | std::move(description), *data)); |
| 391 | _test_factories.emplace_back(std::move(tmp)); |
| 392 | } |
| 393 | } // namespace framework |
| 394 | } // namespace test |
| 395 | } // namespace arm_compute |
| 396 | #endif /* ARM_COMPUTE_TEST_FRAMEWORK */ |