From 9c3c8642fba1a85f7cdcd1a30a6f82fdc0025b40 Mon Sep 17 00:00:00 2001 From: Michael Butler Date: Mon, 23 Aug 2021 18:14:50 -0700 Subject: [PATCH] Quick-fail NNAPI VTS test case if driver is dead This CL adds a check during SetUp that an NNAPI driver service is still alive by pinging the driver service. If it is not alive, the test will fail during SetUp. Without this quick-fail, the test case would continue as if the driver were still active, which would result in multiple EXPECT_* and ASSERT_* statements failing instead of a single, clear failure message. Bug: 197035200 Test: mma Test: presubmit: VtsHalNeuralnetworks*TargetTest Change-Id: Ib1b75ed20f764055699590581d5ad4e5aff4baae --- neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp | 2 ++ neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.cpp | 2 ++ neuralnetworks/1.1/vts/functional/GeneratedTestHarness.cpp | 2 ++ neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.cpp | 2 ++ neuralnetworks/1.2/vts/functional/CompilationCachingTests.cpp | 2 ++ neuralnetworks/1.2/vts/functional/GeneratedTestHarness.cpp | 2 ++ neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.cpp | 2 ++ neuralnetworks/1.3/vts/functional/CompilationCachingTests.cpp | 2 ++ neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp | 2 ++ neuralnetworks/1.3/vts/functional/MemoryDomainTests.cpp | 2 ++ neuralnetworks/1.3/vts/functional/VtsHalNeuralnetworks.cpp | 2 ++ neuralnetworks/aidl/vts/functional/CompilationCachingTests.cpp | 3 +++ neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp | 3 +++ neuralnetworks/aidl/vts/functional/MemoryDomainTests.cpp | 3 +++ neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp | 3 +++ 15 files changed, 34 insertions(+) diff --git a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp index ae1e3a220d..2ef66c20e6 100644 --- a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp +++ b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp @@ -154,6 +154,8 @@ void Execute(const sp& device, const TestModel& testModel) { void GeneratedTestBase::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); } std::vector getNamedModels(const FilterFn& filter) { diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.cpp index 2c17796f2e..e2c0511441 100644 --- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.cpp +++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.cpp @@ -81,6 +81,8 @@ void createPreparedModel(const sp& device, const Model& model, void NeuralnetworksHidlTest::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); } static NamedDevice makeNamedDevice(const std::string& name) { diff --git a/neuralnetworks/1.1/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.1/vts/functional/GeneratedTestHarness.cpp index a2338350aa..faf7bb47ce 100644 --- a/neuralnetworks/1.1/vts/functional/GeneratedTestHarness.cpp +++ b/neuralnetworks/1.1/vts/functional/GeneratedTestHarness.cpp @@ -162,6 +162,8 @@ void Execute(const sp& device, const TestModel& testModel) { void GeneratedTestBase::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); } std::vector getNamedModels(const FilterFn& filter) { diff --git a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.cpp index 54e8802a54..613b828ef1 100644 --- a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.cpp +++ b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.cpp @@ -84,6 +84,8 @@ void createPreparedModel(const sp& device, const Model& model, void NeuralnetworksHidlTest::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); } static NamedDevice makeNamedDevice(const std::string& name) { diff --git a/neuralnetworks/1.2/vts/functional/CompilationCachingTests.cpp b/neuralnetworks/1.2/vts/functional/CompilationCachingTests.cpp index ede1600090..3d783d9aa1 100644 --- a/neuralnetworks/1.2/vts/functional/CompilationCachingTests.cpp +++ b/neuralnetworks/1.2/vts/functional/CompilationCachingTests.cpp @@ -225,6 +225,8 @@ class CompilationCachingTestBase : public testing::Test { void SetUp() override { testing::Test::SetUp(); ASSERT_NE(kDevice.get(), nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); // Create cache directory. The cache directory and a temporary cache file is always created // to test the behavior of prepareModelFromCache, even when caching is not supported. diff --git a/neuralnetworks/1.2/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.2/vts/functional/GeneratedTestHarness.cpp index 56f3c0b7e2..9fa139a2a8 100644 --- a/neuralnetworks/1.2/vts/functional/GeneratedTestHarness.cpp +++ b/neuralnetworks/1.2/vts/functional/GeneratedTestHarness.cpp @@ -384,6 +384,8 @@ void Execute(const sp& device, const TestModel& testModel, bool testDyn void GeneratedTestBase::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); } std::vector getNamedModels(const FilterFn& filter) { diff --git a/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.cpp index a60ec4d1d2..729d584863 100644 --- a/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.cpp +++ b/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.cpp @@ -87,6 +87,8 @@ void createPreparedModel(const sp& device, const Model& model, void NeuralnetworksHidlTest::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); } static NamedDevice makeNamedDevice(const std::string& name) { diff --git a/neuralnetworks/1.3/vts/functional/CompilationCachingTests.cpp b/neuralnetworks/1.3/vts/functional/CompilationCachingTests.cpp index edffa22cca..a2013ecd3a 100644 --- a/neuralnetworks/1.3/vts/functional/CompilationCachingTests.cpp +++ b/neuralnetworks/1.3/vts/functional/CompilationCachingTests.cpp @@ -228,6 +228,8 @@ class CompilationCachingTestBase : public testing::Test { void SetUp() override { testing::Test::SetUp(); ASSERT_NE(kDevice.get(), nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); // Create cache directory. The cache directory and a temporary cache file is always created // to test the behavior of prepareModelFromCache_1_3, even when caching is not supported. diff --git a/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp index 0a956958f9..6d30d85f1b 100644 --- a/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp +++ b/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp @@ -926,6 +926,8 @@ void Execute(const sp& device, const TestModel& testModel, TestKind tes void GeneratedTestBase::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); } std::vector getNamedModels(const FilterFn& filter) { diff --git a/neuralnetworks/1.3/vts/functional/MemoryDomainTests.cpp b/neuralnetworks/1.3/vts/functional/MemoryDomainTests.cpp index 5facc5ee96..e2fa6e4d42 100644 --- a/neuralnetworks/1.3/vts/functional/MemoryDomainTests.cpp +++ b/neuralnetworks/1.3/vts/functional/MemoryDomainTests.cpp @@ -243,6 +243,8 @@ class MemoryDomainTestBase : public testing::Test { void SetUp() override { testing::Test::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); } sp createConvPreparedModel(const TestOperand& testOperand, diff --git a/neuralnetworks/1.3/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/1.3/vts/functional/VtsHalNeuralnetworks.cpp index df1e4535be..eb8cb4bc6d 100644 --- a/neuralnetworks/1.3/vts/functional/VtsHalNeuralnetworks.cpp +++ b/neuralnetworks/1.3/vts/functional/VtsHalNeuralnetworks.cpp @@ -92,6 +92,8 @@ void createPreparedModel(const sp& device, const Model& model, void NeuralnetworksHidlTest::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = kDevice->ping().isOk(); + ASSERT_TRUE(deviceIsResponsive); } static NamedDevice makeNamedDevice(const std::string& name) { diff --git a/neuralnetworks/aidl/vts/functional/CompilationCachingTests.cpp b/neuralnetworks/aidl/vts/functional/CompilationCachingTests.cpp index 94ce5c1130..77208aaf87 100644 --- a/neuralnetworks/aidl/vts/functional/CompilationCachingTests.cpp +++ b/neuralnetworks/aidl/vts/functional/CompilationCachingTests.cpp @@ -223,6 +223,9 @@ class CompilationCachingTestBase : public testing::Test { void SetUp() override { testing::Test::SetUp(); ASSERT_NE(kDevice.get(), nullptr); + const bool deviceIsResponsive = + ndk::ScopedAStatus::fromStatus(AIBinder_ping(kDevice->asBinder().get())).isOk(); + ASSERT_TRUE(deviceIsResponsive); // Create cache directory. The cache directory and a temporary cache file is always created // to test the behavior of prepareModelFromCache, even when caching is not supported. diff --git a/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp index 2356ff0520..ac5b96a8a4 100644 --- a/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp +++ b/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp @@ -904,6 +904,9 @@ void Execute(const std::shared_ptr& device, const TestModel& testModel, void GeneratedTestBase::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = + ndk::ScopedAStatus::fromStatus(AIBinder_ping(kDevice->asBinder().get())).isOk(); + ASSERT_TRUE(deviceIsResponsive); } std::vector getNamedModels(const FilterFn& filter) { diff --git a/neuralnetworks/aidl/vts/functional/MemoryDomainTests.cpp b/neuralnetworks/aidl/vts/functional/MemoryDomainTests.cpp index e8313f19eb..1819699ab2 100644 --- a/neuralnetworks/aidl/vts/functional/MemoryDomainTests.cpp +++ b/neuralnetworks/aidl/vts/functional/MemoryDomainTests.cpp @@ -233,6 +233,9 @@ class MemoryDomainTestBase : public testing::Test { void SetUp() override { testing::Test::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = + ndk::ScopedAStatus::fromStatus(AIBinder_ping(kDevice->asBinder().get())).isOk(); + ASSERT_TRUE(deviceIsResponsive); } std::shared_ptr createConvPreparedModel(const TestOperand& testOperand, diff --git a/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp index ee7cf89d4f..c417356005 100644 --- a/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp +++ b/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp @@ -91,6 +91,9 @@ void createPreparedModel(const std::shared_ptr& device, const Model& mo void NeuralNetworksAidlTest::SetUp() { testing::TestWithParam::SetUp(); ASSERT_NE(kDevice, nullptr); + const bool deviceIsResponsive = + ndk::ScopedAStatus::fromStatus(AIBinder_ping(kDevice->asBinder().get())).isOk(); + ASSERT_TRUE(deviceIsResponsive); } static NamedDevice makeNamedDevice(const std::string& name) {