telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | 93e4898 | 2018-09-05 13:05:09 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 4 | // |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 5 | #define LOG_TAG "ArmnnDriverTests" |
| 6 | #define BOOST_TEST_MODULE armnn_driver_tests |
| 7 | #include <boost/test/unit_test.hpp> |
| 8 | #include <log/log.h> |
| 9 | |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 10 | #include "DriverTestHelpers.hpp" |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 11 | |
| 12 | BOOST_AUTO_TEST_SUITE(DriverTests) |
| 13 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 14 | using namespace android::hardware; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 15 | using namespace driverTestHelpers; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 16 | using namespace armnn_driver; |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 17 | |
| 18 | BOOST_AUTO_TEST_CASE(Init) |
| 19 | { |
| 20 | // Making the driver object on the stack causes a weird libc error, so make it on the heap instead |
| 21 | auto driver = std::make_unique<ArmnnDriver>(DriverOptions(armnn::Compute::CpuRef)); |
| 22 | |
| 23 | DeviceStatus status = driver->getStatus(); |
| 24 | // Note double-parentheses to avoid compile error from Boost trying to printf the DeviceStatus |
| 25 | BOOST_TEST((status == DeviceStatus::AVAILABLE)); |
| 26 | } |
| 27 | |
| 28 | BOOST_AUTO_TEST_CASE(TestCapabilities) |
| 29 | { |
| 30 | // Making the driver object on the stack causes a weird libc error, so make it on the heap instead |
| 31 | auto driver = std::make_unique<ArmnnDriver>(DriverOptions(armnn::Compute::CpuRef)); |
| 32 | |
| 33 | ErrorStatus error; |
Matteo Martincigh | 8b287c2 | 2018-09-07 09:25:10 +0100 | [diff] [blame^] | 34 | V1_0::Capabilities cap; |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 35 | |
Matteo Martincigh | 8b287c2 | 2018-09-07 09:25:10 +0100 | [diff] [blame^] | 36 | auto cb = [&](ErrorStatus status, const V1_0::Capabilities& capabilities) |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 37 | { |
| 38 | error = status; |
| 39 | cap = capabilities; |
| 40 | }; |
| 41 | |
| 42 | driver->getCapabilities(cb); |
| 43 | |
| 44 | BOOST_TEST((int)error == (int)ErrorStatus::NONE); |
| 45 | BOOST_TEST(cap.float32Performance.execTime > 0.f); |
| 46 | BOOST_TEST(cap.float32Performance.powerUsage > 0.f); |
| 47 | BOOST_TEST(cap.quantized8Performance.execTime > 0.f); |
| 48 | BOOST_TEST(cap.quantized8Performance.powerUsage > 0.f); |
| 49 | } |
| 50 | |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 51 | BOOST_AUTO_TEST_SUITE_END() |