blob: a42f271cadb5842e0b666e614e1fb844a1e06582 [file] [log] [blame]
Xusong Wang96e68dc2019-01-18 17:28:26 -08001/*
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 Shklyaev73ee79d2019-05-14 14:15:14 +010017#ifndef ANDROID_HARDWARE_NEURALNETWORKS_V1_0_GENERATED_TEST_HARNESS_H
18#define ANDROID_HARDWARE_NEURALNETWORKS_V1_0_GENERATED_TEST_HARNESS_H
Xusong Wang96e68dc2019-01-18 17:28:26 -080019
20#include <android/hardware/neuralnetworks/1.0/IDevice.h>
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010021#include "TestHarness.h"
Xusong Wangbcaa7822019-08-23 16:10:54 -070022#include "VtsHalNeuralnetworks.h"
Xusong Wang96e68dc2019-01-18 17:28:26 -080023
Michael Butler62749b92019-08-26 23:55:47 -070024namespace android::hardware::neuralnetworks::V1_0::vts::functional {
Xusong Wangbcaa7822019-08-23 16:10:54 -070025
26class GeneratedTestBase
27 : public NeuralnetworksHidlTest,
28 public ::testing::WithParamInterface<test_helper::TestModelManager::TestParam> {
29 protected:
30 void SetUp() override {
31 NeuralnetworksHidlTest::SetUp();
32 ASSERT_NE(mTestModel, nullptr);
33 }
34
35 const test_helper::TestModel* mTestModel = GetParam().second;
36};
37
38#define INSTANTIATE_GENERATED_TEST(TestSuite, filter) \
39 INSTANTIATE_TEST_SUITE_P( \
40 TestGenerated, TestSuite, \
41 ::testing::ValuesIn(::test_helper::TestModelManager::get().getTestModels(filter)), \
42 [](const auto& info) { return info.param.first; })
43
44// Tag for the validation tests, instantiated in VtsHalNeuralnetworks.cpp.
45// TODO: Clean up the hierarchy for ValidationTest.
46class ValidationTest : public GeneratedTestBase {
47 protected:
48 void validateEverything(const Model& model, const Request& request);
49
50 private:
51 void validateModel(const Model& model);
52 void validateRequest(const sp<IPreparedModel>& preparedModel, const Request& request);
53};
Slava Shklyaeve8b24462019-07-17 15:50:57 +010054
Xusong Wang7df43062019-08-09 16:38:14 -070055Model createModel(const ::test_helper::TestModel& testModel);
Xusong Wang96e68dc2019-01-18 17:28:26 -080056
Michael Butler62749b92019-08-26 23:55:47 -070057} // namespace android::hardware::neuralnetworks::V1_0::vts::functional
Xusong Wang96e68dc2019-01-18 17:28:26 -080058
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010059#endif // ANDROID_HARDWARE_NEURALNETWORKS_V1_0_GENERATED_TEST_HARNESS_H