diff options
Diffstat (limited to 'tests/framework')
-rw-r--r-- | tests/framework/Framework.cpp | 18 | ||||
-rw-r--r-- | tests/framework/Framework.h | 20 | ||||
-rw-r--r-- | tests/framework/Macros.h | 55 |
3 files changed, 82 insertions, 11 deletions
diff --git a/tests/framework/Framework.cpp b/tests/framework/Framework.cpp index a1c684c08a..436aac0a34 100644 --- a/tests/framework/Framework.cpp +++ b/tests/framework/Framework.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -133,6 +133,7 @@ void Framework::init(const FrameworkConfig &config) _num_iterations = config.num_iterations; _log_level = config.log_level; _cooldown_sec = config.cooldown_sec; + _configure_only = config.configure_only; _instruments = std::set<framework::InstrumentsDescription>(std::begin(config.instruments), std::end(config.instruments)); } @@ -701,6 +702,21 @@ void Framework::set_instruments_info(InstrumentsInfo instr_info) ARM_COMPUTE_ERROR_ON(instruments_info == nullptr); *instruments_info = instr_info; } + +bool Framework::configure_only() const +{ + return _configure_only; +} + +bool Framework::new_fixture_call() const +{ + return _new_fixture_call; +} + +void Framework::set_new_fixture_call(bool val) +{ + _new_fixture_call = val; +} } // namespace framework } // namespace test } // namespace arm_compute diff --git a/tests/framework/Framework.h b/tests/framework/Framework.h index cf854f2351..4c2e86c6ea 100644 --- a/tests/framework/Framework.h +++ b/tests/framework/Framework.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -63,6 +63,7 @@ struct FrameworkConfig int num_iterations{ 1 }; /**< Number of iterations per test. */ float cooldown_sec{ -1.f }; /**< Delay between tests in seconds. */ LogLevel log_level{ LogLevel::NONE }; /**< Verbosity of the output. */ + bool configure_only{ false }; /**< Only configure kernels */ }; /** Information about a test case. @@ -306,6 +307,21 @@ public: * @param[in] instr_info Instruments info to set */ void set_instruments_info(InstrumentsInfo instr_info); + /** Get the configure only flag + * + * @return The current configure only flag. + */ + bool configure_only() const; + /** Return whether the new fixture has been called + * + * @return The current new fixture call flag. + */ + bool new_fixture_call() const; + /** Set the new fixture call flag + * + * @param[in] val Value to set for the flag + */ + void set_new_fixture_call(bool val); private: Framework(); @@ -340,6 +356,8 @@ private: bool _stop_on_error{ false }; bool _error_on_missing_assets{ false }; std::vector<Printer *> _printers{}; + bool _configure_only{ false }; + bool _new_fixture_call{ false }; using create_function = std::unique_ptr<Instrument>(); std::map<InstrumentsDescription, create_function *> _available_instruments{}; diff --git a/tests/framework/Macros.h b/tests/framework/Macros.h index a67a7596dc..23c826657d 100644 --- a/tests/framework/Macros.h +++ b/tests/framework/Macros.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -111,15 +111,29 @@ explicit TEST_NAME(D &&data) : DataTestCase{ std::forward<D>(data) } \ { \ } -#define FIXTURE_SETUP(FIXTURE) \ - void do_setup() override \ - { \ - FIXTURE::setup(); \ +#define FIXTURE_SETUP(FIXTURE) \ + void do_setup() override \ + { \ + framework::Framework::get().set_new_fixture_call(false); \ + FIXTURE::setup(); \ } -#define FIXTURE_DATA_SETUP(FIXTURE) \ - void do_setup() override \ - { \ - apply(this, &FIXTURE::setup<As...>, _data); \ +#define FIXTURE_DATA_SETUP(FIXTURE) \ + void do_setup() override \ + { \ + framework::Framework::get().set_new_fixture_call(false); \ + apply(this, &FIXTURE::setup<As...>, _data); \ + } +#define FIXTURE_DATA_SETUP_NEW(FIXTURE) \ + void do_setup() override \ + { \ + framework::Framework::get().set_new_fixture_call(true); \ + apply(this, &FIXTURE::setup<As...>, _data); \ + configure_target(); \ + if(!framework::Framework::get().configure_only()) \ + { \ + allocate_and_run_target(); \ + compute_reference(); \ + } \ } #define FIXTURE_RUN(FIXTURE) \ void do_run() override \ @@ -233,6 +247,29 @@ #define DISABLED_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED, DATASET) +#define FIXTURE_DATA_TEST_CASE_NEW_IMPL(TEST_NAME, FIXTURE, MODE, STATUS, DATASET) \ + template <typename T> \ + class TEST_NAME; \ + template <typename... As> \ + class TEST_NAME<std::tuple<As...>> : public arm_compute::test::framework::DataTestCase<decltype(DATASET)::type>, public FIXTURE \ + { \ + public: \ + DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \ + FIXTURE_DATA_SETUP_NEW(FIXTURE) \ + void do_run() override; \ + FIXTURE_TEARDOWN(FIXTURE) \ + }; \ + DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET); \ + template <typename... As> \ + void TEST_NAME<std::tuple<As...>>::do_run() + +#define FIXTURE_DATA_TEST_CASE_NEW(TEST_NAME, FIXTURE, MODE, DATASET) \ + FIXTURE_DATA_TEST_CASE_NEW_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE, DATASET) +#define EXPECTED_FAILURE_FIXTURE_DATA_TEST_CASE_NEW(TEST_NAME, FIXTURE, MODE, DATASET) \ + FIXTURE_DATA_TEST_CASE_NEW_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE, DATASET) +#define DISABLED_FIXTURE_DATA_TEST_CASE_NEW(TEST_NAME, FIXTURE, MODE, DATASET) \ + FIXTURE_DATA_TEST_CASE_NEW_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED, DATASET) + #define REGISTER_FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, STATUS) \ class TEST_NAME : public arm_compute::test::framework::TestCase, public FIXTURE \ { \ |