diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-07-24 14:56:13 +0100 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-07-30 13:17:35 +0100 |
commit | bc2e210785a63e8360839e4ded5d2c15c2dffaf5 (patch) | |
tree | e9e4e75bab72ce7c7e599cfb86a6508a001d86bc /src/backends/backendsCommon/test/TestDynamicBackend.hpp | |
parent | 986c186468e6023b234c24bd10ed9687f9eea0da (diff) | |
download | armnn-bc2e210785a63e8360839e4ded5d2c15c2dffaf5.tar.gz |
IVGCVSW-3561 Test the DynamicBackend class
* Added unit test for valid dynamic backends
* Added unit tests for various cases of invalid dynamic backends
(invalid handle, malformed backends, incompatible version, etc.)
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Change-Id: I4c3b33702bb0faac2bbebe224f69908639b4fc54
Diffstat (limited to 'src/backends/backendsCommon/test/TestDynamicBackend.hpp')
-rw-r--r-- | src/backends/backendsCommon/test/TestDynamicBackend.hpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/backends/backendsCommon/test/TestDynamicBackend.hpp b/src/backends/backendsCommon/test/TestDynamicBackend.hpp new file mode 100644 index 0000000000..599ca16636 --- /dev/null +++ b/src/backends/backendsCommon/test/TestDynamicBackend.hpp @@ -0,0 +1,67 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include <cstdint> + +#if defined(VALID_TEST_DYNAMIC_BACKEND) + +// Correct dynamic backend interface +extern "C" +{ +const char* GetBackendId(); +void GetVersion(uint32_t* outMajor, uint32_t* outMinor); +void* BackendFactory(); +} + +#elif defined(INVALID_TEST_DYNAMIC_BACKEND_1) + +// Wrong external linkage: expected C-style name mangling +extern const char* GetBackendId(); +extern void GetVersion(uint32_t* outMajor, uint32_t* outMinor); +extern void* BackendFactory(); + +#else + +extern "C" +{ + +#if defined(INVALID_TEST_DYNAMIC_BACKEND_2) + +// Invalid interface: missing "GetBackendId()" +void GetVersion(uint32_t* outMajor, uint32_t* outMinor); +void* BackendFactory(); + +#elif defined(INVALID_TEST_DYNAMIC_BACKEND_3) + +// Invalid interface: missing "GetVersion()" +const char* GetBackendId(); +void* BackendFactory(); + +#elif defined(INVALID_TEST_DYNAMIC_BACKEND_4) + +// Invalid interface: missing "BackendFactory()" +const char* GetBackendId(); +void GetVersion(uint32_t* outMajor, uint32_t* outMinor); + +#elif defined(INVALID_TEST_DYNAMIC_BACKEND_5) || \ + defined(INVALID_TEST_DYNAMIC_BACKEND_6) || \ + defined(INVALID_TEST_DYNAMIC_BACKEND_7) + +// The interface is correct, the corresponding invalid changes are in the TestDynamicBackend.cpp file +const char* GetBackendId(); +void GetVersion(uint32_t* outMajor, uint32_t* outMinor); +void* BackendFactory(); + +#else + +#error "Invalid or missing configuration macro for the TestDynamicBackend object" + +#endif + +} + +#endif |