blob: 0eec3656e7f57aaed7d7d874aa78886075df1f8f [file] [log] [blame]
Slava Shklyaevfeb87a92018-09-12 14:52:02 +01001/*
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
21namespace android {
22namespace hardware {
23namespace neuralnetworks {
24namespace V1_2 {
25namespace vts {
26namespace functional {
27
28using V1_1::Capabilities;
29
30// create device test
31TEST_F(NeuralnetworksHidlTest, CreateDevice) {}
32
33// status test
34TEST_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 Wang618028b2018-09-20 11:35:42 -070040// device version test
41TEST_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 Wang7176fe72018-09-20 13:30:31 -070048
49// device type test
50TEST_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 Shklyaevc9ff0992018-11-20 15:29:01 +000058
59// device supported extensions test
60TEST_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
Slava Shklyaevfeb87a92018-09-12 14:52:02 +010075} // namespace functional
76} // namespace vts
77} // namespace V1_2
78} // namespace neuralnetworks
79} // namespace hardware
80} // namespace android