Loading neuralnetworks/1.0/vts/functional/Android.bp +2 −2 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ cc_test { defaults: ["VtsHalNeuralNetworksV1_0TargetTestDefaults"], srcs: [ "BasicTests.cpp", ":VtsHalNeuralNetworksV1_0_all_generated_V1_0_tests", ":VtsHalNeuralNetworksV1_0_all_generated_tests", ], } Loading @@ -83,7 +83,7 @@ cc_test { defaults: ["VtsHalNeuralNetworksV1_0TargetTestDefaults"], srcs: [ "BasicTests.cpp", ":VtsHalNeuralNetworksV1_0_all_generated_V1_0_tests", ":VtsHalNeuralNetworksV1_0_all_generated_tests", ], cflags: [ "-DPRESUBMIT_NOT_VTS", Loading neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp +54 −39 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "1.0/Utils.h" #include "MemoryUtils.h" #include "TestHarness.h" #include "VtsHalNeuralnetworks.h" #include <android-base/logging.h> #include <android/hardware/neuralnetworks/1.0/IDevice.h> Loading @@ -36,7 +37,8 @@ namespace android { namespace hardware { namespace neuralnetworks { namespace V1_0 { namespace generated_tests { namespace vts { namespace functional { using namespace test_helper; using ::android::hardware::neuralnetworks::V1_0::ErrorStatus; Loading Loading @@ -151,7 +153,10 @@ void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestMo checkResults(testModel, outputs); } void Execute(const sp<IDevice>& device, const TestModel& testModel) { // Tag for the generated tests class GeneratedTest : public GeneratedTestBase { protected: void Execute(const TestModel& testModel) { Model model = createModel(testModel); // see if service can handle model Loading @@ -167,7 +172,8 @@ void Execute(const sp<IDevice>& device, const TestModel& testModel) { // launch prepare model sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback(); Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback); Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback); ASSERT_TRUE(prepareLaunchStatus.isOk()); ASSERT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(prepareLaunchStatus)); Loading @@ -191,8 +197,17 @@ void Execute(const sp<IDevice>& device, const TestModel& testModel) { EvaluatePreparedModel(preparedModel, testModel); } }; } // namespace generated_tests TEST_P(GeneratedTest, Test) { Execute(*mTestModel); } INSTANTIATE_GENERATED_TEST(GeneratedTest, [](const TestModel& testModel) { return !testModel.expectFailure; }); } // namespace functional } // namespace vts } // namespace V1_0 } // namespace neuralnetworks } // namespace hardware Loading neuralnetworks/1.0/vts/functional/GeneratedTestHarness.h +34 −4 Original line number Diff line number Diff line Loading @@ -19,18 +19,48 @@ #include <android/hardware/neuralnetworks/1.0/IDevice.h> #include "TestHarness.h" #include "VtsHalNeuralnetworks.h" namespace android { namespace hardware { namespace neuralnetworks { namespace V1_0 { namespace generated_tests { namespace vts { namespace functional { Model createModel(const ::test_helper::TestModel& testModel); class GeneratedTestBase : public NeuralnetworksHidlTest, public ::testing::WithParamInterface<test_helper::TestModelManager::TestParam> { protected: void SetUp() override { NeuralnetworksHidlTest::SetUp(); ASSERT_NE(mTestModel, nullptr); } const test_helper::TestModel* mTestModel = GetParam().second; }; #define INSTANTIATE_GENERATED_TEST(TestSuite, filter) \ INSTANTIATE_TEST_SUITE_P( \ TestGenerated, TestSuite, \ ::testing::ValuesIn(::test_helper::TestModelManager::get().getTestModels(filter)), \ [](const auto& info) { return info.param.first; }) void Execute(const sp<V1_0::IDevice>& device, const ::test_helper::TestModel& testModel); // Tag for the validation tests, instantiated in VtsHalNeuralnetworks.cpp. // TODO: Clean up the hierarchy for ValidationTest. class ValidationTest : public GeneratedTestBase { protected: void validateEverything(const Model& model, const Request& request); private: void validateModel(const Model& model); void validateRequest(const sp<IPreparedModel>& preparedModel, const Request& request); }; Model createModel(const ::test_helper::TestModel& testModel); } // namespace generated_tests } // namespace functional } // namespace vts } // namespace V1_0 } // namespace neuralnetworks } // namespace hardware Loading neuralnetworks/1.0/vts/functional/GeneratedTests.hdeleted 100644 → 0 +0 −26 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "1.0/Utils.h" #include "GeneratedTestHarness.h" #include "TestHarness.h" #include "VtsHalNeuralnetworks.h" namespace android::hardware::neuralnetworks::V1_0::generated_tests { using namespace android::hardware::neuralnetworks::V1_0::vts::functional; } // namespace android::hardware::neuralnetworks::V1_0::generated_tests neuralnetworks/1.0/vts/functional/ValidateModel.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ #define LOG_TAG "neuralnetworks_hidl_hal_test" #include "VtsHalNeuralnetworks.h" #include "1.0/Callbacks.h" #include "GeneratedTestHarness.h" #include "VtsHalNeuralnetworks.h" namespace android { namespace hardware { Loading Loading
neuralnetworks/1.0/vts/functional/Android.bp +2 −2 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ cc_test { defaults: ["VtsHalNeuralNetworksV1_0TargetTestDefaults"], srcs: [ "BasicTests.cpp", ":VtsHalNeuralNetworksV1_0_all_generated_V1_0_tests", ":VtsHalNeuralNetworksV1_0_all_generated_tests", ], } Loading @@ -83,7 +83,7 @@ cc_test { defaults: ["VtsHalNeuralNetworksV1_0TargetTestDefaults"], srcs: [ "BasicTests.cpp", ":VtsHalNeuralNetworksV1_0_all_generated_V1_0_tests", ":VtsHalNeuralNetworksV1_0_all_generated_tests", ], cflags: [ "-DPRESUBMIT_NOT_VTS", Loading
neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp +54 −39 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "1.0/Utils.h" #include "MemoryUtils.h" #include "TestHarness.h" #include "VtsHalNeuralnetworks.h" #include <android-base/logging.h> #include <android/hardware/neuralnetworks/1.0/IDevice.h> Loading @@ -36,7 +37,8 @@ namespace android { namespace hardware { namespace neuralnetworks { namespace V1_0 { namespace generated_tests { namespace vts { namespace functional { using namespace test_helper; using ::android::hardware::neuralnetworks::V1_0::ErrorStatus; Loading Loading @@ -151,7 +153,10 @@ void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestMo checkResults(testModel, outputs); } void Execute(const sp<IDevice>& device, const TestModel& testModel) { // Tag for the generated tests class GeneratedTest : public GeneratedTestBase { protected: void Execute(const TestModel& testModel) { Model model = createModel(testModel); // see if service can handle model Loading @@ -167,7 +172,8 @@ void Execute(const sp<IDevice>& device, const TestModel& testModel) { // launch prepare model sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback(); Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback); Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback); ASSERT_TRUE(prepareLaunchStatus.isOk()); ASSERT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(prepareLaunchStatus)); Loading @@ -191,8 +197,17 @@ void Execute(const sp<IDevice>& device, const TestModel& testModel) { EvaluatePreparedModel(preparedModel, testModel); } }; } // namespace generated_tests TEST_P(GeneratedTest, Test) { Execute(*mTestModel); } INSTANTIATE_GENERATED_TEST(GeneratedTest, [](const TestModel& testModel) { return !testModel.expectFailure; }); } // namespace functional } // namespace vts } // namespace V1_0 } // namespace neuralnetworks } // namespace hardware Loading
neuralnetworks/1.0/vts/functional/GeneratedTestHarness.h +34 −4 Original line number Diff line number Diff line Loading @@ -19,18 +19,48 @@ #include <android/hardware/neuralnetworks/1.0/IDevice.h> #include "TestHarness.h" #include "VtsHalNeuralnetworks.h" namespace android { namespace hardware { namespace neuralnetworks { namespace V1_0 { namespace generated_tests { namespace vts { namespace functional { Model createModel(const ::test_helper::TestModel& testModel); class GeneratedTestBase : public NeuralnetworksHidlTest, public ::testing::WithParamInterface<test_helper::TestModelManager::TestParam> { protected: void SetUp() override { NeuralnetworksHidlTest::SetUp(); ASSERT_NE(mTestModel, nullptr); } const test_helper::TestModel* mTestModel = GetParam().second; }; #define INSTANTIATE_GENERATED_TEST(TestSuite, filter) \ INSTANTIATE_TEST_SUITE_P( \ TestGenerated, TestSuite, \ ::testing::ValuesIn(::test_helper::TestModelManager::get().getTestModels(filter)), \ [](const auto& info) { return info.param.first; }) void Execute(const sp<V1_0::IDevice>& device, const ::test_helper::TestModel& testModel); // Tag for the validation tests, instantiated in VtsHalNeuralnetworks.cpp. // TODO: Clean up the hierarchy for ValidationTest. class ValidationTest : public GeneratedTestBase { protected: void validateEverything(const Model& model, const Request& request); private: void validateModel(const Model& model); void validateRequest(const sp<IPreparedModel>& preparedModel, const Request& request); }; Model createModel(const ::test_helper::TestModel& testModel); } // namespace generated_tests } // namespace functional } // namespace vts } // namespace V1_0 } // namespace neuralnetworks } // namespace hardware Loading
neuralnetworks/1.0/vts/functional/GeneratedTests.hdeleted 100644 → 0 +0 −26 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "1.0/Utils.h" #include "GeneratedTestHarness.h" #include "TestHarness.h" #include "VtsHalNeuralnetworks.h" namespace android::hardware::neuralnetworks::V1_0::generated_tests { using namespace android::hardware::neuralnetworks::V1_0::vts::functional; } // namespace android::hardware::neuralnetworks::V1_0::generated_tests
neuralnetworks/1.0/vts/functional/ValidateModel.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ #define LOG_TAG "neuralnetworks_hidl_hal_test" #include "VtsHalNeuralnetworks.h" #include "1.0/Callbacks.h" #include "GeneratedTestHarness.h" #include "VtsHalNeuralnetworks.h" namespace android { namespace hardware { Loading