blob: cf449ea42d1c0b63e5fe3e508a9b0d3aa5c7e789 [file] [log] [blame]
Slava Shklyaev73ee79d2019-05-14 14:15:14 +01001/*
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>
Michael Butler07633282019-08-29 11:08:25 -070021#include "1.0/Utils.h"
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010022#include "TestHarness.h"
Xusong Wangbcaa7822019-08-23 16:10:54 -070023#include "VtsHalNeuralnetworks.h"
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010024
Michael Butler62749b92019-08-26 23:55:47 -070025namespace android::hardware::neuralnetworks::V1_1::vts::functional {
Xusong Wangbcaa7822019-08-23 16:10:54 -070026
Michael Butler07633282019-08-29 11:08:25 -070027using NamedModel = Named<const test_helper::TestModel*>;
28using GeneratedTestParam = std::tuple<NamedDevice, NamedModel>;
29
30class GeneratedTestBase : public testing::TestWithParam<GeneratedTestParam> {
Xusong Wangbcaa7822019-08-23 16:10:54 -070031 protected:
Michael Butler07633282019-08-29 11:08:25 -070032 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 Wangbcaa7822019-08-23 16:10:54 -070035};
36
Michael Butler07633282019-08-29 11:08:25 -070037using FilterFn = std::function<bool(const test_helper::TestModel&)>;
38std::vector<NamedModel> getNamedModels(const FilterFn& filter);
39
40std::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 Wangbcaa7822019-08-23 16:10:54 -070047
48// Tag for the validation tests, instantiated in VtsHalNeuralnetworks.cpp.
49// TODO: Clean up the hierarchy for ValidationTest.
Michael Butler13b05162019-08-29 22:17:24 -070050class ValidationTest : public GeneratedTestBase {};
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010051
Michael Butler07633282019-08-29 11:08:25 -070052Model createModel(const test_helper::TestModel& testModel);
Xusong Wang81611962019-08-09 16:41:16 -070053
Michael Butler62749b92019-08-26 23:55:47 -070054} // namespace android::hardware::neuralnetworks::V1_1::vts::functional
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010055
56#endif // ANDROID_HARDWARE_NEURALNETWORKS_V1_1_GENERATED_TEST_HARNESS_H