Slava Shklyaev | 73ee79d | 2019-05-14 14:15:14 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 ANDROID_HARDWARE_NEURALNETWORKS_V1_1_GENERATED_TEST_HARNESS_H |
| 18 | #define ANDROID_HARDWARE_NEURALNETWORKS_V1_1_GENERATED_TEST_HARNESS_H |
| 19 | |
| 20 | #include <android/hardware/neuralnetworks/1.1/IDevice.h> |
Slava Shklyaev | 73ee79d | 2019-05-14 14:15:14 +0100 | [diff] [blame] | 21 | #include "TestHarness.h" |
Xusong Wang | bcaa782 | 2019-08-23 16:10:54 -0700 | [diff] [blame^] | 22 | #include "VtsHalNeuralnetworks.h" |
Slava Shklyaev | 73ee79d | 2019-05-14 14:15:14 +0100 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace neuralnetworks { |
Slava Shklyaev | e8b2446 | 2019-07-17 15:50:57 +0100 | [diff] [blame] | 27 | namespace V1_1 { |
Xusong Wang | bcaa782 | 2019-08-23 16:10:54 -0700 | [diff] [blame^] | 28 | namespace vts { |
| 29 | namespace functional { |
| 30 | |
| 31 | class GeneratedTestBase |
| 32 | : public NeuralnetworksHidlTest, |
| 33 | public ::testing::WithParamInterface<test_helper::TestModelManager::TestParam> { |
| 34 | protected: |
| 35 | void SetUp() override { |
| 36 | NeuralnetworksHidlTest::SetUp(); |
| 37 | ASSERT_NE(mTestModel, nullptr); |
| 38 | } |
| 39 | |
| 40 | const test_helper::TestModel* mTestModel = GetParam().second; |
| 41 | }; |
| 42 | |
| 43 | #define INSTANTIATE_GENERATED_TEST(TestSuite, filter) \ |
| 44 | INSTANTIATE_TEST_SUITE_P( \ |
| 45 | TestGenerated, TestSuite, \ |
| 46 | ::testing::ValuesIn(::test_helper::TestModelManager::get().getTestModels(filter)), \ |
| 47 | [](const auto& info) { return info.param.first; }) |
| 48 | |
| 49 | // Tag for the validation tests, instantiated in VtsHalNeuralnetworks.cpp. |
| 50 | // TODO: Clean up the hierarchy for ValidationTest. |
| 51 | class ValidationTest : public GeneratedTestBase { |
| 52 | protected: |
| 53 | void validateEverything(const Model& model, const Request& request); |
| 54 | |
| 55 | private: |
| 56 | void validateModel(const Model& model); |
| 57 | void validateRequest(const sp<IPreparedModel>& preparedModel, const Request& request); |
| 58 | }; |
Slava Shklyaev | 73ee79d | 2019-05-14 14:15:14 +0100 | [diff] [blame] | 59 | |
Xusong Wang | 8161196 | 2019-08-09 16:41:16 -0700 | [diff] [blame] | 60 | Model createModel(const ::test_helper::TestModel& testModel); |
| 61 | |
Xusong Wang | bcaa782 | 2019-08-23 16:10:54 -0700 | [diff] [blame^] | 62 | } // namespace functional |
| 63 | } // namespace vts |
Slava Shklyaev | e8b2446 | 2019-07-17 15:50:57 +0100 | [diff] [blame] | 64 | } // namespace V1_1 |
Slava Shklyaev | 73ee79d | 2019-05-14 14:15:14 +0100 | [diff] [blame] | 65 | } // namespace neuralnetworks |
| 66 | } // namespace hardware |
| 67 | } // namespace android |
| 68 | |
| 69 | #endif // ANDROID_HARDWARE_NEURALNETWORKS_V1_1_GENERATED_TEST_HARNESS_H |