Merge "Remove temporary test filters" into rvc-dev
diff --git a/biometrics/face/1.0/vts/functional/VtsHalBiometricsFaceV1_0TargetTest.cpp b/biometrics/face/1.0/vts/functional/VtsHalBiometricsFaceV1_0TargetTest.cpp
index 7ac44a4..78f93af 100644
--- a/biometrics/face/1.0/vts/functional/VtsHalBiometricsFaceV1_0TargetTest.cpp
+++ b/biometrics/face/1.0/vts/functional/VtsHalBiometricsFaceV1_0TargetTest.cpp
@@ -28,6 +28,7 @@
#include <chrono>
#include <cstdint>
#include <random>
+#include <thread>
using android::sp;
using android::hardware::hidl_vec;
@@ -144,7 +145,10 @@
ASSERT_EQ(Status::OK, static_cast<Status>(ret2));
}
- void TearDown() override {}
+ void TearDown() override {
+ // Hack to allow the asynchronous operations to finish on time.
+ std::this_thread::sleep_for(std::chrono::milliseconds(250));
+ }
sp<IBiometricsFace> mService;
sp<FaceCallback> mCallback;
diff --git a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp
index 529fb18..6df7f8d 100644
--- a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp
+++ b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp
@@ -605,6 +605,9 @@
ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle)));
}
+/**
+ * Test multiple operations associated with different color formats
+ */
TEST_P(GraphicsMapperHidlTest, Lock_YCRCB_420_SP) {
auto info = mDummyDescriptorInfo;
info.format = PixelFormat::YCRCB_420_SP;
@@ -751,6 +754,90 @@
ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle)));
}
+TEST_P(GraphicsMapperHidlTest, Lock_RAW10) {
+ auto info = mDummyDescriptorInfo;
+ info.format = PixelFormat::RAW10;
+
+ const native_handle_t* bufferHandle;
+ uint32_t stride;
+ ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(
+ info, true, Tolerance::kToleranceUnSupported, &stride));
+ if (bufferHandle == nullptr) {
+ GTEST_SUCCEED() << "RAW10 format is unsupported";
+ return;
+ }
+
+ const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
+ static_cast<int32_t>(info.height)};
+ unique_fd fence;
+
+ ASSERT_NO_FATAL_FAILURE(mGralloc->lock(bufferHandle, info.usage, region, fence.get()));
+
+ hidl_vec<uint8_t> vec;
+ ASSERT_EQ(Error::NONE, mGralloc->get(bufferHandle, gralloc4::MetadataType_PlaneLayouts, &vec));
+ std::vector<PlaneLayout> planeLayouts;
+ ASSERT_EQ(NO_ERROR, gralloc4::decodePlaneLayouts(vec, &planeLayouts));
+
+ ASSERT_EQ(1, planeLayouts.size());
+ auto planeLayout = planeLayouts[0];
+
+ EXPECT_EQ(0, planeLayout.sampleIncrementInBits);
+ EXPECT_EQ(1, planeLayout.horizontalSubsampling);
+ EXPECT_EQ(1, planeLayout.verticalSubsampling);
+
+ ASSERT_EQ(1, planeLayout.components.size());
+ auto planeLayoutComponent = planeLayout.components[0];
+
+ EXPECT_EQ(PlaneLayoutComponentType::RAW,
+ static_cast<PlaneLayoutComponentType>(planeLayoutComponent.type.value));
+ EXPECT_EQ(0, planeLayoutComponent.offsetInBits % 8);
+ EXPECT_EQ(-1, planeLayoutComponent.sizeInBits);
+
+ ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle)));
+}
+
+TEST_P(GraphicsMapperHidlTest, Lock_RAW12) {
+ auto info = mDummyDescriptorInfo;
+ info.format = PixelFormat::RAW12;
+
+ const native_handle_t* bufferHandle;
+ uint32_t stride;
+ ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(
+ info, true, Tolerance::kToleranceUnSupported, &stride));
+ if (bufferHandle == nullptr) {
+ GTEST_SUCCEED() << "RAW12 format is unsupported";
+ return;
+ }
+
+ const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
+ static_cast<int32_t>(info.height)};
+ unique_fd fence;
+
+ ASSERT_NO_FATAL_FAILURE(mGralloc->lock(bufferHandle, info.usage, region, fence.get()));
+
+ hidl_vec<uint8_t> vec;
+ ASSERT_EQ(Error::NONE, mGralloc->get(bufferHandle, gralloc4::MetadataType_PlaneLayouts, &vec));
+ std::vector<PlaneLayout> planeLayouts;
+ ASSERT_EQ(NO_ERROR, gralloc4::decodePlaneLayouts(vec, &planeLayouts));
+
+ ASSERT_EQ(1, planeLayouts.size());
+ auto planeLayout = planeLayouts[0];
+
+ EXPECT_EQ(0, planeLayout.sampleIncrementInBits);
+ EXPECT_EQ(1, planeLayout.horizontalSubsampling);
+ EXPECT_EQ(1, planeLayout.verticalSubsampling);
+
+ ASSERT_EQ(1, planeLayout.components.size());
+ auto planeLayoutComponent = planeLayout.components[0];
+
+ EXPECT_EQ(PlaneLayoutComponentType::RAW,
+ static_cast<PlaneLayoutComponentType>(planeLayoutComponent.type.value));
+ EXPECT_EQ(0, planeLayoutComponent.offsetInBits % 8);
+ EXPECT_EQ(-1, planeLayoutComponent.sizeInBits);
+
+ ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle)));
+}
+
/**
* Test IMapper::unlock with bad access region
*/
@@ -1707,6 +1794,84 @@
}
/**
+ * Test get::metadata with cloned native_handle
+ */
+TEST_P(GraphicsMapperHidlTest, GetMetadataClonedHandle) {
+ const native_handle_t* bufferHandle = nullptr;
+ ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true));
+
+ const auto dataspace = Dataspace::SRGB_LINEAR;
+ {
+ hidl_vec<uint8_t> metadata;
+ ASSERT_EQ(NO_ERROR, gralloc4::encodeDataspace(dataspace, &metadata));
+
+ Error err = mGralloc->set(bufferHandle, gralloc4::MetadataType_Dataspace, metadata);
+ if (err == Error::UNSUPPORTED) {
+ GTEST_SUCCEED() << "setting this metadata is unsupported";
+ return;
+ }
+ ASSERT_EQ(Error::NONE, err);
+ }
+
+ const native_handle_t* importedHandle;
+ {
+ auto clonedHandle = native_handle_clone(bufferHandle);
+ ASSERT_NO_FATAL_FAILURE(importedHandle = mGralloc->importBuffer(clonedHandle));
+ native_handle_close(clonedHandle);
+ native_handle_delete(clonedHandle);
+ }
+
+ Dataspace realSpace = Dataspace::UNKNOWN;
+ {
+ hidl_vec<uint8_t> metadata;
+ ASSERT_EQ(Error::NONE,
+ mGralloc->get(importedHandle, gralloc4::MetadataType_Dataspace, &metadata));
+ ASSERT_NO_FATAL_FAILURE(gralloc4::decodeDataspace(metadata, &realSpace));
+ }
+
+ EXPECT_EQ(dataspace, realSpace);
+}
+
+/**
+ * Test set::metadata with cloned native_handle
+ */
+TEST_P(GraphicsMapperHidlTest, SetMetadataClonedHandle) {
+ const native_handle_t* bufferHandle = nullptr;
+ ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true));
+
+ const native_handle_t* importedHandle;
+ {
+ auto clonedHandle = native_handle_clone(bufferHandle);
+ ASSERT_NO_FATAL_FAILURE(importedHandle = mGralloc->importBuffer(clonedHandle));
+ native_handle_close(clonedHandle);
+ native_handle_delete(clonedHandle);
+ }
+
+ const auto dataspace = Dataspace::SRGB_LINEAR;
+ {
+ hidl_vec<uint8_t> metadata;
+ ASSERT_EQ(NO_ERROR, gralloc4::encodeDataspace(dataspace, &metadata));
+
+ Error err = mGralloc->set(importedHandle, gralloc4::MetadataType_Dataspace, metadata);
+ if (err == Error::UNSUPPORTED) {
+ GTEST_SUCCEED() << "setting this metadata is unsupported";
+ return;
+ }
+ ASSERT_EQ(Error::NONE, err);
+ }
+
+ Dataspace realSpace = Dataspace::UNKNOWN;
+ {
+ hidl_vec<uint8_t> metadata;
+ ASSERT_EQ(Error::NONE,
+ mGralloc->get(bufferHandle, gralloc4::MetadataType_Dataspace, &metadata));
+ ASSERT_NO_FATAL_FAILURE(gralloc4::decodeDataspace(metadata, &realSpace));
+ }
+
+ EXPECT_EQ(dataspace, realSpace);
+}
+
+/**
* Test IMapper::set(metadata) for constant metadata
*/
TEST_P(GraphicsMapperHidlTest, SetConstantMetadata) {
diff --git a/neuralnetworks/1.2/vts/functional/CompilationCachingTests.cpp b/neuralnetworks/1.2/vts/functional/CompilationCachingTests.cpp
index 449b8f3..16b313a 100644
--- a/neuralnetworks/1.2/vts/functional/CompilationCachingTests.cpp
+++ b/neuralnetworks/1.2/vts/functional/CompilationCachingTests.cpp
@@ -315,7 +315,8 @@
void saveModelToCache(const Model& model, const hidl_vec<hidl_handle>& modelCache,
const hidl_vec<hidl_handle>& dataCache,
- sp<IPreparedModel>* preparedModel = nullptr) {
+ sp<IPreparedModel>* preparedModel = nullptr,
+ bool allowGeneralFailure = false) {
if (preparedModel != nullptr) *preparedModel = nullptr;
// Launch prepare model.
@@ -329,7 +330,10 @@
// Retrieve prepared model.
preparedModelCallback->wait();
- ASSERT_EQ(preparedModelCallback->getStatus(), ErrorStatus::NONE);
+ const auto prepareCallbackStatus = preparedModelCallback->getStatus();
+ if (!allowGeneralFailure || prepareCallbackStatus != ErrorStatus::GENERAL_FAILURE) {
+ ASSERT_EQ(prepareCallbackStatus, ErrorStatus::NONE);
+ }
if (preparedModel != nullptr) {
*preparedModel = IPreparedModel::castFrom(preparedModelCallback->getPreparedModel())
.withDefault(nullptr);
@@ -1022,7 +1026,8 @@
// Number of operations in the large test model.
constexpr uint32_t kLargeModelSize = 100;
-constexpr uint32_t kNumIterationsTOCTOU = 100;
+constexpr uint32_t kNumSuccessfulIterationsTOCTOU = 100;
+constexpr uint32_t kMaxNumFailedIterationsTOCTOU = 100;
TEST_P(CompilationCachingTest, SaveToCache_TOCTOU) {
if (!mIsCachingSupported) return;
@@ -1050,18 +1055,30 @@
// Use a different token for modelAdd.
mToken[0]++;
- // This test is probabilistic, so we run it multiple times.
- for (uint32_t i = 0; i < kNumIterationsTOCTOU; i++) {
+ // This test is probabilistic, so we run it multiple times. We allow the compilation to fail
+ // because it is not related to the security aspect of the TOCTOU test. However, we need to have
+ // enough successful iterations to ensure the test coverage.
+ uint32_t numSuccessfulIterations = 0, numFailedIterations = 0;
+ while (numSuccessfulIterations < kNumSuccessfulIterationsTOCTOU) {
// Save the modelAdd compilation to cache.
{
hidl_vec<hidl_handle> modelCache, dataCache;
createCacheHandles(mModelCache, AccessMode::READ_WRITE, &modelCache);
createCacheHandles(mDataCache, AccessMode::READ_WRITE, &dataCache);
+ sp<IPreparedModel> preparedModel = nullptr;
// Spawn a thread to copy the cache content concurrently while saving to cache.
std::thread thread(copyCacheFiles, std::cref(modelCacheMul), std::cref(mModelCache));
- saveModelToCache(modelAdd, modelCache, dataCache);
+ saveModelToCache(modelAdd, modelCache, dataCache, &preparedModel,
+ /*allowGeneralFailure=*/true);
thread.join();
+
+ if (preparedModel == nullptr) {
+ numFailedIterations++;
+ ASSERT_LE(numFailedIterations, kMaxNumFailedIterationsTOCTOU);
+ } else {
+ numSuccessfulIterations++;
+ }
}
// Retrieve preparedModel from cache.
@@ -1112,14 +1129,26 @@
// Use a different token for modelAdd.
mToken[0]++;
- // This test is probabilistic, so we run it multiple times.
- for (uint32_t i = 0; i < kNumIterationsTOCTOU; i++) {
+ // This test is probabilistic, so we run it multiple times. We allow the compilation to fail
+ // because it is not related to the security aspect of the TOCTOU test. However, we need to have
+ // enough successful iterations to ensure the test coverage.
+ uint32_t numSuccessfulIterations = 0, numFailedIterations = 0;
+ while (numSuccessfulIterations < kNumSuccessfulIterationsTOCTOU) {
// Save the modelAdd compilation to cache.
{
hidl_vec<hidl_handle> modelCache, dataCache;
createCacheHandles(mModelCache, AccessMode::READ_WRITE, &modelCache);
createCacheHandles(mDataCache, AccessMode::READ_WRITE, &dataCache);
- saveModelToCache(modelAdd, modelCache, dataCache);
+ sp<IPreparedModel> preparedModel = nullptr;
+ saveModelToCache(modelAdd, modelCache, dataCache, &preparedModel,
+ /*allowGeneralFailure=*/true);
+
+ if (preparedModel == nullptr) {
+ numFailedIterations++;
+ ASSERT_LE(numFailedIterations, kMaxNumFailedIterationsTOCTOU);
+ } else {
+ numSuccessfulIterations++;
+ }
}
// Retrieve preparedModel from cache.
diff --git a/neuralnetworks/1.3/vts/functional/CompilationCachingTests.cpp b/neuralnetworks/1.3/vts/functional/CompilationCachingTests.cpp
index ac18c8f..382fc76 100644
--- a/neuralnetworks/1.3/vts/functional/CompilationCachingTests.cpp
+++ b/neuralnetworks/1.3/vts/functional/CompilationCachingTests.cpp
@@ -318,7 +318,8 @@
void saveModelToCache(const Model& model, const hidl_vec<hidl_handle>& modelCache,
const hidl_vec<hidl_handle>& dataCache,
- sp<IPreparedModel>* preparedModel = nullptr) {
+ sp<IPreparedModel>* preparedModel = nullptr,
+ bool allowGeneralFailure = false) {
if (preparedModel != nullptr) *preparedModel = nullptr;
// Launch prepare model.
@@ -332,7 +333,10 @@
// Retrieve prepared model.
preparedModelCallback->wait();
- ASSERT_EQ(preparedModelCallback->getStatus(), ErrorStatus::NONE);
+ const auto prepareCallbackStatus = preparedModelCallback->getStatus();
+ if (!allowGeneralFailure || prepareCallbackStatus != ErrorStatus::GENERAL_FAILURE) {
+ ASSERT_EQ(prepareCallbackStatus, ErrorStatus::NONE);
+ }
if (preparedModel != nullptr) {
*preparedModel = IPreparedModel::castFrom(preparedModelCallback->getPreparedModel())
.withDefault(nullptr);
@@ -1013,7 +1017,8 @@
// Number of operations in the large test model.
constexpr uint32_t kLargeModelSize = 100;
-constexpr uint32_t kNumIterationsTOCTOU = 100;
+constexpr uint32_t kNumSuccessfulIterationsTOCTOU = 100;
+constexpr uint32_t kMaxNumFailedIterationsTOCTOU = 100;
TEST_P(CompilationCachingTest, SaveToCache_TOCTOU) {
if (!mIsCachingSupported) return;
@@ -1041,18 +1046,30 @@
// Use a different token for modelAdd.
mToken[0]++;
- // This test is probabilistic, so we run it multiple times.
- for (uint32_t i = 0; i < kNumIterationsTOCTOU; i++) {
+ // This test is probabilistic, so we run it multiple times. We allow the compilation to fail
+ // because it is not related to the security aspect of the TOCTOU test. However, we need to have
+ // enough successful iterations to ensure the test coverage.
+ uint32_t numSuccessfulIterations = 0, numFailedIterations = 0;
+ while (numSuccessfulIterations < kNumSuccessfulIterationsTOCTOU) {
// Save the modelAdd compilation to cache.
{
hidl_vec<hidl_handle> modelCache, dataCache;
createCacheHandles(mModelCache, AccessMode::READ_WRITE, &modelCache);
createCacheHandles(mDataCache, AccessMode::READ_WRITE, &dataCache);
+ sp<IPreparedModel> preparedModel = nullptr;
// Spawn a thread to copy the cache content concurrently while saving to cache.
std::thread thread(copyCacheFiles, std::cref(modelCacheMul), std::cref(mModelCache));
- saveModelToCache(modelAdd, modelCache, dataCache);
+ saveModelToCache(modelAdd, modelCache, dataCache, &preparedModel,
+ /*allowGeneralFailure=*/true);
thread.join();
+
+ if (preparedModel == nullptr) {
+ numFailedIterations++;
+ ASSERT_LE(numFailedIterations, kMaxNumFailedIterationsTOCTOU);
+ } else {
+ numSuccessfulIterations++;
+ }
}
// Retrieve preparedModel from cache.
@@ -1103,14 +1120,26 @@
// Use a different token for modelAdd.
mToken[0]++;
- // This test is probabilistic, so we run it multiple times.
- for (uint32_t i = 0; i < kNumIterationsTOCTOU; i++) {
+ // This test is probabilistic, so we run it multiple times. We allow the compilation to fail
+ // because it is not related to the security aspect of the TOCTOU test. However, we need to have
+ // enough successful iterations to ensure the test coverage.
+ uint32_t numSuccessfulIterations = 0, numFailedIterations = 0;
+ while (numSuccessfulIterations < kNumSuccessfulIterationsTOCTOU) {
// Save the modelAdd compilation to cache.
{
hidl_vec<hidl_handle> modelCache, dataCache;
createCacheHandles(mModelCache, AccessMode::READ_WRITE, &modelCache);
createCacheHandles(mDataCache, AccessMode::READ_WRITE, &dataCache);
- saveModelToCache(modelAdd, modelCache, dataCache);
+ sp<IPreparedModel> preparedModel = nullptr;
+ saveModelToCache(modelAdd, modelCache, dataCache, &preparedModel,
+ /*allowGeneralFailure=*/true);
+
+ if (preparedModel == nullptr) {
+ numFailedIterations++;
+ ASSERT_LE(numFailedIterations, kMaxNumFailedIterationsTOCTOU);
+ } else {
+ numSuccessfulIterations++;
+ }
}
// Retrieve preparedModel from cache.