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