From a369b890c018d0885c3b7cefed7b914bb4bc9f17 Mon Sep 17 00:00:00 2001 From: Matthew Bentham Date: Mon, 5 Jul 2021 09:20:23 +0100 Subject: Improve ThrowBackendUnavailableException test Fail test if exception is not thrown. Remove unnecessary references to CpuAcc backend. Remove excess trace message. Signed-off-by: Matthew Bentham Change-Id: I22d30b47a092ac2e66f5987c656804cd31b04b21 --- src/backends/backendsCommon/test/BackendRegistryTests.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/backends/backendsCommon/test/BackendRegistryTests.cpp b/src/backends/backendsCommon/test/BackendRegistryTests.cpp index d9c19d659c..ba407d2908 100644 --- a/src/backends/backendsCommon/test/BackendRegistryTests.cpp +++ b/src/backends/backendsCommon/test/BackendRegistryTests.cpp @@ -117,18 +117,14 @@ TEST_CASE("ThrowBackendUnavailableException") const BackendId mockBackendId("MockDynamicBackend"); - const std::string exceptionMessage("Neon support not found on device, could not register CpuAcc Backend.\n"); + const std::string exceptionMessage("Mock error message to test unavailable backend"); - // Register the mock backend with a factory function lambda equivalent to NeonRegisterInitializer + // Register the mock backend with a factory function lambda that always throws BackendRegistryInstance().Register(mockBackendId, [exceptionMessage]() { - if (false) - { - return IBackendInternalUniquePtr(new RefBackend); - } - ARMNN_LOG(info) << "Neon support not found on device, could not register CpuAcc Backend."; throw armnn::BackendUnavailableException(exceptionMessage); + return IBackendInternalUniquePtr(); // Satisfy return type }); // Get the factory function of the mock backend @@ -138,12 +134,12 @@ TEST_CASE("ThrowBackendUnavailableException") { // Call the factory function as done during runtime backend registering auto backend = factoryFunc(); + FAIL("Expected exception to have been thrown"); } catch (const BackendUnavailableException& e) { // Caught CHECK_EQ(e.what(), exceptionMessage); - MESSAGE("ThrowBackendUnavailableExceptionImpl: BackendUnavailableException caught."); } } -- cgit v1.2.1