aboutsummaryrefslogtreecommitdiff
path: root/src/backends/test/BackendRegistryTests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/test/BackendRegistryTests.cpp')
-rw-r--r--src/backends/test/BackendRegistryTests.cpp48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/backends/test/BackendRegistryTests.cpp b/src/backends/test/BackendRegistryTests.cpp
index e895df63a6..f6f749936f 100644
--- a/src/backends/test/BackendRegistryTests.cpp
+++ b/src/backends/test/BackendRegistryTests.cpp
@@ -15,16 +15,16 @@ class SwapRegistryStorage : public armnn::BackendRegistry
public:
SwapRegistryStorage() : armnn::BackendRegistry()
{
- Swap(m_TempStorage);
+ Swap(armnn::BackendRegistryInstance(), m_TempStorage);
}
~SwapRegistryStorage()
{
- Swap(m_TempStorage);
+ Swap(armnn::BackendRegistryInstance(),m_TempStorage);
}
private:
- BackendRegistry::FactoryStorage m_TempStorage;
+ FactoryStorage m_TempStorage;
};
}
@@ -33,30 +33,36 @@ BOOST_AUTO_TEST_SUITE(BackendRegistryTests)
BOOST_AUTO_TEST_CASE(SwapRegistry)
{
- using armnn::BackendRegistry;
- auto nFactories = BackendRegistry::Instance().Size();
+ using namespace armnn;
+ auto nFactories = BackendRegistryInstance().Size();
{
SwapRegistryStorage helper;
- BOOST_TEST(BackendRegistry::Instance().Size() == 0);
+ BOOST_TEST(BackendRegistryInstance().Size() == 0);
}
- BOOST_TEST(BackendRegistry::Instance().Size() == nFactories);
+ BOOST_TEST(BackendRegistryInstance().Size() == nFactories);
}
BOOST_AUTO_TEST_CASE(TestRegistryHelper)
{
- using armnn::BackendRegistry;
+ using namespace armnn;
SwapRegistryStorage helper;
bool called = false;
- BackendRegistry::Helper factoryHelper("HelloWorld", [&called]() {
- called = true;
- return armnn::IBackendUniquePtr(nullptr, nullptr);
- } );
+
+ StaticRegistryInitializer<BackendRegistry> factoryHelper(
+ BackendRegistryInstance(),
+ "HelloWorld",
+ [&called]()
+ {
+ called = true;
+ return armnn::IBackendUniquePtr(nullptr, nullptr);
+ }
+ );
// sanity check: the factory has not been called yet
BOOST_TEST(called == false);
- auto factoryFunction = BackendRegistry::Instance().GetFactory("HelloWorld");
+ auto factoryFunction = BackendRegistryInstance().GetFactory("HelloWorld");
// sanity check: the factory still not called
BOOST_TEST(called == false);
@@ -67,19 +73,23 @@ BOOST_AUTO_TEST_CASE(TestRegistryHelper)
BOOST_AUTO_TEST_CASE(TestDirectCallToRegistry)
{
- using armnn::BackendRegistry;
+ using namespace armnn;
SwapRegistryStorage helper;
bool called = false;
- BackendRegistry::Instance().Register("HelloWorld", [&called]() {
- called = true;
- return armnn::IBackendUniquePtr(nullptr, nullptr);
- } );
+ BackendRegistryInstance().Register(
+ "HelloWorld",
+ [&called]()
+ {
+ called = true;
+ return armnn::IBackendUniquePtr(nullptr, nullptr);
+ }
+ );
// sanity check: the factory has not been called yet
BOOST_TEST(called == false);
- auto factoryFunction = BackendRegistry::Instance().GetFactory("HelloWorld");
+ auto factoryFunction = BackendRegistryInstance().GetFactory("HelloWorld");
// sanity check: the factory still not called
BOOST_TEST(called == false);