From 18339992dd5298f3f797edce5953bc8fca9cf753 Mon Sep 17 00:00:00 2001 From: Alec Mouri Date: Mon, 4 Apr 2022 21:53:57 +0000 Subject: [PATCH] Allow old gralloc implementations to skip P010 support. P010 is mandated for vendor versions that are at least api level 33. Gralloc versions below this may not support P010 due to lack of enforcement, but tests for already-shipping devices must still pass. Bug: 220360702 Test: VtsHalGraphicsMapperV3_0TargetTest Change-Id: I7ba268713bada133491813aa3c9bd87fdecd2fef --- graphics/mapper/3.0/utils/vts/MapperVts.cpp | 42 ++++++++++++------- .../VtsHalGraphicsMapperV3_0TargetTest.cpp | 4 ++ graphics/mapper/4.0/utils/vts/MapperVts.cpp | 16 ++++--- .../VtsHalGraphicsMapperV4_0TargetTest.cpp | 9 ++-- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/graphics/mapper/3.0/utils/vts/MapperVts.cpp b/graphics/mapper/3.0/utils/vts/MapperVts.cpp index de886a9c70..c470a4aca0 100644 --- a/graphics/mapper/3.0/utils/vts/MapperVts.cpp +++ b/graphics/mapper/3.0/utils/vts/MapperVts.cpp @@ -14,7 +14,9 @@ * limitations under the License. */ +#include #include +#include "gtest/gtest.h" namespace android { namespace hardware { @@ -94,23 +96,31 @@ std::vector Gralloc::allocate(const BufferDescriptor& de std::vector bufferHandles; bufferHandles.reserve(count); mAllocator->allocate( - descriptor, count, - [&](const auto& tmpError, const auto& tmpStride, const auto& tmpBuffers) { - ASSERT_EQ(Error::NONE, tmpError) << "failed to allocate buffers"; - ASSERT_EQ(count, tmpBuffers.size()) << "invalid buffer array"; - - for (uint32_t i = 0; i < count; i++) { - if (import) { - ASSERT_NO_FATAL_FAILURE(bufferHandles.push_back(importBuffer(tmpBuffers[i]))); - } else { - ASSERT_NO_FATAL_FAILURE(bufferHandles.push_back(cloneBuffer(tmpBuffers[i]))); + descriptor, count, + [&](const auto& tmpError, const auto& tmpStride, const auto& tmpBuffers) { + if (tmpError != Error::NONE) { + if (base::GetIntProperty("ro.vendor.build.version.sdk", 0, 0, INT_MAX) < 33) { + GTEST_SKIP() << "Old vendor grallocs may not support P010"; + } else { + GTEST_FAIL() << "failed to allocate buffers"; + } } - } + ASSERT_EQ(count, tmpBuffers.size()) << "invalid buffer array"; - if (outStride) { - *outStride = tmpStride; - } - }); + for (uint32_t i = 0; i < count; i++) { + if (import) { + ASSERT_NO_FATAL_FAILURE( + bufferHandles.push_back(importBuffer(tmpBuffers[i]))); + } else { + ASSERT_NO_FATAL_FAILURE( + bufferHandles.push_back(cloneBuffer(tmpBuffers[i]))); + } + } + + if (outStride) { + *outStride = tmpStride; + } + }); if (::testing::Test::HasFatalFailure()) { bufferHandles.clear(); @@ -127,7 +137,7 @@ const native_handle_t* Gralloc::allocate(const IMapper::BufferDescriptorInfo& de } auto buffers = allocate(descriptor, 1, import, outStride); - if (::testing::Test::HasFatalFailure()) { + if (::testing::Test::HasFatalFailure() || ::testing::Test::IsSkipped()) { return nullptr; } diff --git a/graphics/mapper/3.0/vts/functional/VtsHalGraphicsMapperV3_0TargetTest.cpp b/graphics/mapper/3.0/vts/functional/VtsHalGraphicsMapperV3_0TargetTest.cpp index 6c90af407a..3b1bfab867 100644 --- a/graphics/mapper/3.0/vts/functional/VtsHalGraphicsMapperV3_0TargetTest.cpp +++ b/graphics/mapper/3.0/vts/functional/VtsHalGraphicsMapperV3_0TargetTest.cpp @@ -337,6 +337,10 @@ TEST_P(GraphicsMapperHidlTest, LockYCbCrP010) { uint32_t stride; ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(info, true, &stride)); + if (::testing::Test::IsSkipped()) { + GTEST_SKIP(); + } + ASSERT_NE(nullptr, bufferHandle); const IMapper::Rect region{0, 0, static_cast(info.width), diff --git a/graphics/mapper/4.0/utils/vts/MapperVts.cpp b/graphics/mapper/4.0/utils/vts/MapperVts.cpp index 901f0e3ae7..4a6f68da26 100644 --- a/graphics/mapper/4.0/utils/vts/MapperVts.cpp +++ b/graphics/mapper/4.0/utils/vts/MapperVts.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include @@ -95,7 +96,14 @@ std::vector Gralloc::allocate(const BufferDescriptor& de return; } - ASSERT_EQ(Error::NONE, tmpError) << "failed to allocate buffers"; + if (tmpError != Error::NONE) { + if (base::GetIntProperty("ro.vendor.build.version.sdk", 0, 0, + INT_MAX) < 33) { + GTEST_SKIP() << "Old vendor grallocs may not support P010"; + } else { + GTEST_FAIL() << "failed to allocate buffers"; + } + } ASSERT_EQ(count, tmpBuffers.size()) << "invalid buffer array"; for (uint32_t i = 0; i < count; i++) { @@ -133,11 +141,7 @@ const native_handle_t* Gralloc::allocate(const IMapper::BufferDescriptorInfo& de } auto buffers = allocate(descriptor, 1, import, tolerance, outStride); - if (::testing::Test::HasFatalFailure()) { - return nullptr; - } - - if (buffers.size() != 1) { + if (::testing::Test::HasFatalFailure() || ::testing::Test::IsSkipped() || buffers.size() != 1) { return nullptr; } return buffers[0]; diff --git a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp index 463b565c2c..8f440e4d1e 100644 --- a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp +++ b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp @@ -999,10 +999,13 @@ TEST_P(GraphicsMapperHidlTest, Lock_YCBCR_P010) { auto info = mDummyDescriptorInfo; info.format = PixelFormat::YCBCR_P010; - const native_handle_t* bufferHandle; uint32_t stride; - ASSERT_NO_FATAL_FAILURE( - bufferHandle = mGralloc->allocate(info, true, Tolerance::kToleranceStrict, &stride)); + const native_handle_t* bufferHandle = + mGralloc->allocate(info, true, Tolerance::kToleranceStrict, &stride); + + if (::testing::Test::IsSkipped()) { + GTEST_SKIP(); + } const IMapper::Rect region{0, 0, static_cast(info.width), static_cast(info.height)};