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 #ifndef VTS_HAL_NEURALNETWORKS_V1_0_TARGET_TESTS_H 18 #define VTS_HAL_NEURALNETWORKS_V1_0_TARGET_TESTS_H 19 20 #include <android/hardware/neuralnetworks/1.0/IDevice.h> 21 #include <android/hardware/neuralnetworks/1.0/types.h> 22 23 #include <VtsHalHidlTargetTestBase.h> 24 #include <VtsHalHidlTargetTestEnvBase.h> 25 26 #include <android-base/macros.h> 27 #include <gtest/gtest.h> 28 #include <iostream> 29 #include <vector> 30 31 namespace android { 32 namespace hardware { 33 namespace neuralnetworks { 34 namespace V1_0 { 35 namespace vts { 36 namespace functional { 37 38 // A class for test environment setup 39 class NeuralnetworksHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { 40 DISALLOW_COPY_AND_ASSIGN(NeuralnetworksHidlEnvironment); 41 NeuralnetworksHidlEnvironment(); 42 ~NeuralnetworksHidlEnvironment() override; 43 44 public: 45 static NeuralnetworksHidlEnvironment* getInstance(); 46 void registerTestServices() override; 47 }; 48 49 // The main test class for NEURALNETWORKS HIDL HAL. 50 class NeuralnetworksHidlTest : public ::testing::VtsHalHidlTargetTestBase { 51 DISALLOW_COPY_AND_ASSIGN(NeuralnetworksHidlTest); 52 53 public: 54 NeuralnetworksHidlTest(); 55 ~NeuralnetworksHidlTest() override; 56 void SetUp() override; 57 void TearDown() override; 58 59 protected: 60 sp<IDevice> device; 61 }; 62 63 // Tag for the validation tests 64 class ValidationTest : public NeuralnetworksHidlTest { 65 protected: 66 void validateEverything(const Model& model, const std::vector<Request>& request); 67 68 private: 69 void validateModel(const Model& model); 70 void validateRequests(const sp<IPreparedModel>& preparedModel, 71 const std::vector<Request>& requests); 72 }; 73 74 // Tag for the generated tests 75 class GeneratedTest : public NeuralnetworksHidlTest {}; 76 77 } // namespace functional 78 } // namespace vts 79 } // namespace V1_0 80 } // namespace neuralnetworks 81 } // namespace hardware 82 } // namespace android 83 84 namespace android::hardware::neuralnetworks::V1_0 { 85 86 // pretty-print values for error messages 87 ::std::ostream& operator<<(::std::ostream& os, ErrorStatus errorStatus); 88 ::std::ostream& operator<<(::std::ostream& os, DeviceStatus deviceStatus); 89 90 } // namespace android::hardware::neuralnetworks::V1_0 91 92 #endif // VTS_HAL_NEURALNETWORKS_V1_0_TARGET_TESTS_H 93