Slava Shklyaev | feb87a9 | 2018-09-12 14:52:02 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "neuralnetworks_hidl_hal_test" |
| 18 | |
| 19 | #include "VtsHalNeuralnetworks.h" |
| 20 | |
| 21 | namespace android { |
| 22 | namespace hardware { |
| 23 | namespace neuralnetworks { |
| 24 | namespace V1_2 { |
| 25 | namespace vts { |
| 26 | namespace functional { |
| 27 | |
| 28 | using V1_1::Capabilities; |
| 29 | |
| 30 | // create device test |
| 31 | TEST_F(NeuralnetworksHidlTest, CreateDevice) {} |
| 32 | |
| 33 | // status test |
| 34 | TEST_F(NeuralnetworksHidlTest, StatusTest) { |
| 35 | Return<DeviceStatus> status = device->getStatus(); |
| 36 | ASSERT_TRUE(status.isOk()); |
| 37 | EXPECT_EQ(DeviceStatus::AVAILABLE, static_cast<DeviceStatus>(status)); |
| 38 | } |
| 39 | |
Miao Wang | 618028b | 2018-09-20 11:35:42 -0700 | [diff] [blame] | 40 | // device version test |
| 41 | TEST_F(NeuralnetworksHidlTest, GetDeviceVersionStringTest) { |
| 42 | Return<void> ret = device->getVersionString([](ErrorStatus status, const hidl_string& version) { |
| 43 | EXPECT_EQ(ErrorStatus::NONE, status); |
| 44 | EXPECT_LT(0, version.size()); |
| 45 | }); |
| 46 | EXPECT_TRUE(ret.isOk()); |
| 47 | } |
Miao Wang | 7176fe7 | 2018-09-20 13:30:31 -0700 | [diff] [blame] | 48 | |
| 49 | // device type test |
| 50 | TEST_F(NeuralnetworksHidlTest, GetDeviceTypeTest) { |
| 51 | Return<void> ret = device->getType([](ErrorStatus status, DeviceType type) { |
| 52 | EXPECT_EQ(ErrorStatus::NONE, status); |
| 53 | EXPECT_TRUE(type == DeviceType::OTHER || type == DeviceType::CPU || |
| 54 | type == DeviceType::GPU || type == DeviceType::ACCELERATOR); |
| 55 | }); |
| 56 | EXPECT_TRUE(ret.isOk()); |
| 57 | } |
Slava Shklyaev | c9ff099 | 2018-11-20 15:29:01 +0000 | [diff] [blame] | 58 | |
| 59 | // device supported extensions test |
| 60 | TEST_F(NeuralnetworksHidlTest, GetDeviceSupportedExtensionsTest) { |
| 61 | Return<void> ret = device->getSupportedExtensions( |
| 62 | [](ErrorStatus status, const hidl_vec<Extension>& extensions) { |
| 63 | EXPECT_EQ(ErrorStatus::NONE, status); |
| 64 | for (auto& extension : extensions) { |
| 65 | std::string extensionName = extension.name; |
| 66 | EXPECT_FALSE(extensionName.empty()); |
| 67 | EXPECT_NE(extensionName.find("."), std::string::npos) |
| 68 | << "Extension name must start with the reverse domain name of the " |
| 69 | "vendor"; |
| 70 | } |
| 71 | }); |
| 72 | EXPECT_TRUE(ret.isOk()); |
| 73 | } |
| 74 | |
Xusong Wang | 96e68dc | 2019-01-18 17:28:26 -0800 | [diff] [blame^] | 75 | // isCachingSupported test |
| 76 | TEST_F(NeuralnetworksHidlTest, IsCachingSupported) { |
| 77 | Return<void> ret = device->isCachingSupported( |
| 78 | [](ErrorStatus status, bool) { EXPECT_EQ(ErrorStatus::NONE, status); }); |
| 79 | EXPECT_TRUE(ret.isOk()); |
| 80 | } |
Slava Shklyaev | feb87a9 | 2018-09-12 14:52:02 +0100 | [diff] [blame] | 81 | } // namespace functional |
| 82 | } // namespace vts |
| 83 | } // namespace V1_2 |
| 84 | } // namespace neuralnetworks |
| 85 | } // namespace hardware |
| 86 | } // namespace android |