Xusong Wang | 96e68dc | 2019-01-18 17:28:26 -0800 | [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 | |
Slava Shklyaev | 73ee79d | 2019-05-14 14:15:14 +0100 | [diff] [blame] | 17 | #ifndef ANDROID_HARDWARE_NEURALNETWORKS_V1_0_GENERATED_TEST_HARNESS_H |
| 18 | #define ANDROID_HARDWARE_NEURALNETWORKS_V1_0_GENERATED_TEST_HARNESS_H |
Xusong Wang | 96e68dc | 2019-01-18 17:28:26 -0800 | [diff] [blame] | 19 | |
| 20 | #include <android/hardware/neuralnetworks/1.0/IDevice.h> |
Michael Butler | 0763328 | 2019-08-29 11:08:25 -0700 | [diff] [blame^] | 21 | #include <functional> |
Slava Shklyaev | 73ee79d | 2019-05-14 14:15:14 +0100 | [diff] [blame] | 22 | #include "TestHarness.h" |
Xusong Wang | bcaa782 | 2019-08-23 16:10:54 -0700 | [diff] [blame] | 23 | #include "VtsHalNeuralnetworks.h" |
Xusong Wang | 96e68dc | 2019-01-18 17:28:26 -0800 | [diff] [blame] | 24 | |
Michael Butler | 62749b9 | 2019-08-26 23:55:47 -0700 | [diff] [blame] | 25 | namespace android::hardware::neuralnetworks::V1_0::vts::functional { |
Xusong Wang | bcaa782 | 2019-08-23 16:10:54 -0700 | [diff] [blame] | 26 | |
Michael Butler | 0763328 | 2019-08-29 11:08:25 -0700 | [diff] [blame^] | 27 | using NamedModel = Named<const test_helper::TestModel*>; |
| 28 | using GeneratedTestParam = std::tuple<NamedDevice, NamedModel>; |
| 29 | |
| 30 | class GeneratedTestBase : public testing::TestWithParam<GeneratedTestParam> { |
Xusong Wang | bcaa782 | 2019-08-23 16:10:54 -0700 | [diff] [blame] | 31 | protected: |
Michael Butler | 0763328 | 2019-08-29 11:08:25 -0700 | [diff] [blame^] | 32 | void SetUp() override; |
| 33 | const sp<IDevice> kDevice = getData(std::get<NamedDevice>(GetParam())); |
| 34 | const test_helper::TestModel& kTestModel = *getData(std::get<NamedModel>(GetParam())); |
Xusong Wang | bcaa782 | 2019-08-23 16:10:54 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
Michael Butler | 0763328 | 2019-08-29 11:08:25 -0700 | [diff] [blame^] | 37 | using FilterFn = std::function<bool(const test_helper::TestModel&)>; |
| 38 | std::vector<NamedModel> getNamedModels(const FilterFn& filter); |
| 39 | |
| 40 | std::string printGeneratedTest(const testing::TestParamInfo<GeneratedTestParam>& info); |
| 41 | |
| 42 | #define INSTANTIATE_GENERATED_TEST(TestSuite, filter) \ |
| 43 | INSTANTIATE_TEST_SUITE_P(TestGenerated, TestSuite, \ |
| 44 | testing::Combine(testing::ValuesIn(getNamedDevices()), \ |
| 45 | testing::ValuesIn(getNamedModels(filter))), \ |
| 46 | printGeneratedTest) |
Xusong Wang | bcaa782 | 2019-08-23 16:10:54 -0700 | [diff] [blame] | 47 | |
| 48 | // Tag for the validation tests, instantiated in VtsHalNeuralnetworks.cpp. |
| 49 | // TODO: Clean up the hierarchy for ValidationTest. |
Michael Butler | 13b0516 | 2019-08-29 22:17:24 -0700 | [diff] [blame] | 50 | class ValidationTest : public GeneratedTestBase {}; |
Slava Shklyaev | e8b2446 | 2019-07-17 15:50:57 +0100 | [diff] [blame] | 51 | |
Michael Butler | 0763328 | 2019-08-29 11:08:25 -0700 | [diff] [blame^] | 52 | Model createModel(const test_helper::TestModel& testModel); |
Xusong Wang | 96e68dc | 2019-01-18 17:28:26 -0800 | [diff] [blame] | 53 | |
Michael Butler | 62749b9 | 2019-08-26 23:55:47 -0700 | [diff] [blame] | 54 | } // namespace android::hardware::neuralnetworks::V1_0::vts::functional |
Xusong Wang | 96e68dc | 2019-01-18 17:28:26 -0800 | [diff] [blame] | 55 | |
Slava Shklyaev | 73ee79d | 2019-05-14 14:15:14 +0100 | [diff] [blame] | 56 | #endif // ANDROID_HARDWARE_NEURALNETWORKS_V1_0_GENERATED_TEST_HARNESS_H |