blob: 3b629a7acfbd6ab7eb57701e48717643a23d2fcd [file] [log] [blame]
telsoa015307bc12018-03-09 13:51:08 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beck93e48982018-09-05 13:05:09 +01003// SPDX-License-Identifier: MIT
telsoa015307bc12018-03-09 13:51:08 +00004//
telsoa015307bc12018-03-09 13:51:08 +00005#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
surmeh0149b9e102018-05-17 14:11:25 +010010#include "DriverTestHelpers.hpp"
telsoa015307bc12018-03-09 13:51:08 +000011
12BOOST_AUTO_TEST_SUITE(DriverTests)
13
telsoa01ce3e84a2018-08-31 09:31:35 +010014using namespace android::hardware;
surmeh0149b9e102018-05-17 14:11:25 +010015using namespace driverTestHelpers;
telsoa01ce3e84a2018-08-31 09:31:35 +010016using namespace armnn_driver;
telsoa015307bc12018-03-09 13:51:08 +000017
18BOOST_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
28BOOST_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
Kevin Mayec1e5b82020-02-26 17:00:39 +000033 V1_0::ErrorStatus error;
Matteo Martincigh8b287c22018-09-07 09:25:10 +010034 V1_0::Capabilities cap;
telsoa015307bc12018-03-09 13:51:08 +000035
Kevin Mayec1e5b82020-02-26 17:00:39 +000036 auto cb = [&](V1_0::ErrorStatus status, const V1_0::Capabilities& capabilities)
telsoa015307bc12018-03-09 13:51:08 +000037 {
38 error = status;
39 cap = capabilities;
40 };
41
42 driver->getCapabilities(cb);
43
Kevin Mayec1e5b82020-02-26 17:00:39 +000044 BOOST_TEST((int)error == (int)V1_0::ErrorStatus::NONE);
telsoa015307bc12018-03-09 13:51:08 +000045 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
telsoa015307bc12018-03-09 13:51:08 +000051BOOST_AUTO_TEST_SUITE_END()