From bc404e6c809e619ef39606b0eabf8b4a14138bec Mon Sep 17 00:00:00 2001 From: Dan Shi Date: Wed, 11 Dec 2019 10:23:03 -0800 Subject: [PATCH] Convert VtsHalRenderscriptV1_0TargetTest to be parameterized test Bug: 142397658 Test: atest VtsHalRenderscriptV1_0TargetTest Change-Id: I319f113d2c80afc75a28a480e3dd1c7739c5f2d7 --- renderscript/1.0/vts/functional/Android.bp | 2 +- .../1.0/vts/functional/VtsCopyTests.cpp | 20 +++++++-------- .../VtsHalRenderscriptV1_0TargetTest.cpp | 15 ++++------- .../VtsHalRenderscriptV1_0TargetTest.h | 25 ++++--------------- .../vts/functional/VtsMiscellaneousTests.cpp | 18 ++++++------- .../1.0/vts/functional/VtsScriptTests.cpp | 18 ++++++------- 6 files changed, 39 insertions(+), 59 deletions(-) diff --git a/renderscript/1.0/vts/functional/Android.bp b/renderscript/1.0/vts/functional/Android.bp index 87e62f17c0..e3716e01b1 100644 --- a/renderscript/1.0/vts/functional/Android.bp +++ b/renderscript/1.0/vts/functional/Android.bp @@ -28,5 +28,5 @@ cc_test { "android.hardware.renderscript@1.0", "libnativewindow", ], - test_suites: ["general-tests"], + test_suites: ["general-tests", "vts-core"], } diff --git a/renderscript/1.0/vts/functional/VtsCopyTests.cpp b/renderscript/1.0/vts/functional/VtsCopyTests.cpp index f47253f99f..3040cbf944 100644 --- a/renderscript/1.0/vts/functional/VtsCopyTests.cpp +++ b/renderscript/1.0/vts/functional/VtsCopyTests.cpp @@ -27,7 +27,7 @@ * * Expect: dataIn & dataOut are the same. */ -TEST_F(RenderscriptHidlTest, Simple1DCopyTest) { +TEST_P(RenderscriptHidlTest, Simple1DCopyTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -63,7 +63,7 @@ TEST_F(RenderscriptHidlTest, Simple1DCopyTest) { * * Expect: dataIn & dataOut are the same. */ -TEST_F(RenderscriptHidlTest, Simple2DCopyTest) { +TEST_P(RenderscriptHidlTest, Simple2DCopyTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -100,7 +100,7 @@ TEST_F(RenderscriptHidlTest, Simple2DCopyTest) { * * Expect: dataIn & dataOut are the same. */ -TEST_F(RenderscriptHidlTest, Simple3DCopyTest) { +TEST_P(RenderscriptHidlTest, Simple3DCopyTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -137,7 +137,7 @@ TEST_F(RenderscriptHidlTest, Simple3DCopyTest) { * * Expect: dataIn & dataOut are the same. */ -TEST_F(RenderscriptHidlTest, SimpleBitmapTest) { +TEST_P(RenderscriptHidlTest, SimpleBitmapTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -177,7 +177,7 @@ TEST_F(RenderscriptHidlTest, SimpleBitmapTest) { * * Expect: dataIn & dataOut are the same. */ -TEST_F(RenderscriptHidlTest, AllocationCopy2DRangeTest) { +TEST_P(RenderscriptHidlTest, AllocationCopy2DRangeTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -229,7 +229,7 @@ TEST_F(RenderscriptHidlTest, AllocationCopy2DRangeTest) { * * Expect: dataIn & dataOut are the same. */ -TEST_F(RenderscriptHidlTest, AllocationCopy3DRangeTest) { +TEST_P(RenderscriptHidlTest, AllocationCopy3DRangeTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -282,7 +282,7 @@ TEST_F(RenderscriptHidlTest, AllocationCopy3DRangeTest) { * * Expect: dataIn & dataOut are the same. */ -TEST_F(RenderscriptHidlTest, SimpleAdapterTest) { +TEST_P(RenderscriptHidlTest, SimpleAdapterTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -339,7 +339,7 @@ TEST_F(RenderscriptHidlTest, SimpleAdapterTest) { * * Expect: dataIn & dataOut are the same. */ -TEST_F(RenderscriptHidlTest, SimpleMipmapTest) { +TEST_P(RenderscriptHidlTest, SimpleMipmapTest) { // uint8_t Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -386,7 +386,7 @@ TEST_F(RenderscriptHidlTest, SimpleMipmapTest) { * * Expect: dataIn & dataOut are the same. */ -TEST_F(RenderscriptHidlTest, SimpleCubemapTest) { +TEST_P(RenderscriptHidlTest, SimpleCubemapTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -425,7 +425,7 @@ TEST_F(RenderscriptHidlTest, SimpleCubemapTest) { * typeCreate, allocationCreateTyped, allocationElementWrite, * allocationElementRead */ -TEST_F(RenderscriptHidlTest, ComplexElementTest) { +TEST_P(RenderscriptHidlTest, ComplexElementTest) { Element element1 = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1); ASSERT_NE(Element(0), element1); diff --git a/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.cpp b/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.cpp index 0636cf9515..5e5776c06e 100644 --- a/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.cpp +++ b/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.cpp @@ -18,8 +18,7 @@ // The main test class for RENDERSCRIPT HIDL HAL. void RenderscriptHidlTest::SetUp() { - device = ::testing::VtsHalHidlTargetTestBase::getService( - RenderscriptHidlEnvironment::Instance()->getServiceName()); + device = IDevice::getService(GetParam()); ASSERT_NE(nullptr, device.get()); uint32_t version = 0; @@ -35,11 +34,7 @@ void RenderscriptHidlTest::TearDown() { } } -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(RenderscriptHidlEnvironment::Instance()); - ::testing::InitGoogleTest(&argc, argv); - RenderscriptHidlEnvironment::Instance()->init(&argc, argv); - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; - return status; -} +INSTANTIATE_TEST_SUITE_P( + PerInstance, RenderscriptHidlTest, + testing::ValuesIn(android::hardware::getAllHalInstanceNames(IDevice::descriptor)), + android::hardware::PrintInstanceNameToString); diff --git a/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.h b/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.h index e11ab92b66..b7dbed4c01 100644 --- a/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.h +++ b/renderscript/1.0/vts/functional/VtsHalRenderscriptV1_0TargetTest.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef VTS_HAL_RENDERSCRIPT_V1_0_TARGET_TESTS_H -#define VTS_HAL_RENDERSCRIPT_V1_0_TARGET_TESTS_H +#pragma once #define LOG_TAG "renderscript_hidl_hal_test" #include @@ -24,9 +23,9 @@ #include #include -#include -#include #include +#include +#include using ::android::hardware::renderscript::V1_0::Allocation; using ::android::hardware::renderscript::V1_0::AllocationAdapter; @@ -89,8 +88,8 @@ extern const int8_t bitCode[]; extern const int bitCodeLength; // The main test class for RENDERSCRIPT HIDL HAL. -class RenderscriptHidlTest : public ::testing::VtsHalHidlTargetTestBase { -public: +class RenderscriptHidlTest : public ::testing::TestWithParam { + public: virtual void SetUp() override; virtual void TearDown() override; @@ -99,17 +98,3 @@ public: private: sp device; }; - -// Test environment for RENDERSCRIPT HIDL HAL. -class RenderscriptHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { - public: - // get the test environment singleton - static RenderscriptHidlEnvironment* Instance() { - static RenderscriptHidlEnvironment* instance = new RenderscriptHidlEnvironment; - return instance; - } - - virtual void registerTestServices() override { registerTestService(); } -}; - -#endif // VTS_HAL_RENDERSCRIPT_V1_0_TARGET_TESTS_H diff --git a/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp b/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp index 278dbf301b..c66ddeadfe 100644 --- a/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp +++ b/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp @@ -25,14 +25,14 @@ * * Calls: getService, contextCreate, contextDestroy */ -TEST_F(RenderscriptHidlTest, ContextCreateAndDestroy) {} +TEST_P(RenderscriptHidlTest, ContextCreateAndDestroy) {} /* * Create an Element and verify the return value is valid. * * Calls: elementCreate */ -TEST_F(RenderscriptHidlTest, ElementCreate) { +TEST_P(RenderscriptHidlTest, ElementCreate) { Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); EXPECT_NE(Element(0), element); } @@ -43,7 +43,7 @@ TEST_F(RenderscriptHidlTest, ElementCreate) { * * Calls: elementCreate, typeCreate, allocationCreateTyped, allocationGetType */ -TEST_F(RenderscriptHidlTest, ElementTypeAllocationCreate) { +TEST_P(RenderscriptHidlTest, ElementTypeAllocationCreate) { // Element create test Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -71,7 +71,7 @@ TEST_F(RenderscriptHidlTest, ElementTypeAllocationCreate) { * Calls: elementCreate, typeCreate, elementGetNativeMetadata, * typeGetNativeMetadata */ -TEST_F(RenderscriptHidlTest, MetadataTest) { +TEST_P(RenderscriptHidlTest, MetadataTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -107,7 +107,7 @@ TEST_F(RenderscriptHidlTest, MetadataTest) { * Calls: elementCreate, typeCreate, allocationCreateTyped, * allocationGetPointer, allocationResize1D */ -TEST_F(RenderscriptHidlTest, ResizeTest) { +TEST_P(RenderscriptHidlTest, ResizeTest) { // float1 Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1); ASSERT_NE(Element(0), element); @@ -145,7 +145,7 @@ TEST_F(RenderscriptHidlTest, ResizeTest) { * allocationGetNativeWindow, allocationSetNativeWindow, allocationIoSend, * allocationIoReceive, allocation2DRead */ -TEST_F(RenderscriptHidlTest, NativeWindowIoTest) { +TEST_P(RenderscriptHidlTest, NativeWindowIoTest) { // uint8x4 Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 4); ASSERT_NE(Element(0), element); @@ -198,7 +198,7 @@ TEST_F(RenderscriptHidlTest, NativeWindowIoTest) { * allocation2DWrite, allocation2DRead, allocationIoSend, * allocationIoReceive */ -TEST_F(RenderscriptHidlTest, BufferQueueTest) { +TEST_P(RenderscriptHidlTest, BufferQueueTest) { // uint8x4 Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 4); ASSERT_NE(Element(0), element); @@ -269,7 +269,7 @@ TEST_F(RenderscriptHidlTest, BufferQueueTest) { * Calls: contextInitToClient, contextSendMessage, contextPeekMessage, * contextGetMessage, contextDeinitToClient, contextLog */ -TEST_F(RenderscriptHidlTest, ContextMessageTest) { +TEST_P(RenderscriptHidlTest, ContextMessageTest) { context->contextInitToClient(); const char * message = "correct"; @@ -299,7 +299,7 @@ TEST_F(RenderscriptHidlTest, ContextMessageTest) { * Calls: contextSetPriority, contextSetCacheDir, elementCreate, assignName, * contextFinish, getName, objDestroy, samplerCreate */ -TEST_F(RenderscriptHidlTest, MiscellaneousTests) { +TEST_P(RenderscriptHidlTest, MiscellaneousTests) { context->contextSetPriority(ThreadPriorities::NORMAL); context->contextSetCacheDir("/data/local/tmp/temp/"); diff --git a/renderscript/1.0/vts/functional/VtsScriptTests.cpp b/renderscript/1.0/vts/functional/VtsScriptTests.cpp index 8d24cfa7c5..96072671b5 100644 --- a/renderscript/1.0/vts/functional/VtsScriptTests.cpp +++ b/renderscript/1.0/vts/functional/VtsScriptTests.cpp @@ -22,7 +22,7 @@ * * Calls: elementCreate, scriptIntrinsicCreate, scriptSetTimeZone */ -TEST_F(RenderscriptHidlTest, IntrinsicTest) { +TEST_P(RenderscriptHidlTest, IntrinsicTest) { // uint8 Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1); EXPECT_NE(Element(0), element); @@ -41,7 +41,7 @@ TEST_F(RenderscriptHidlTest, IntrinsicTest) { * scriptSetVarF, scriptSetVarD, elementCreate, typeCreate, * allocationCreateTyped, scriptSetVarObj, scriptSetVarV, scriptSetVarVE */ -TEST_F(RenderscriptHidlTest, ScriptVarTest) { +TEST_P(RenderscriptHidlTest, ScriptVarTest) { hidl_vec bitcode; bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength); Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode); @@ -132,7 +132,7 @@ TEST_F(RenderscriptHidlTest, ScriptVarTest) { * * Calls: scriptCCreate, scriptInvoke, scriptGetVarV, scriptInvokeV */ -TEST_F(RenderscriptHidlTest, ScriptInvokeTest) { +TEST_P(RenderscriptHidlTest, ScriptInvokeTest) { hidl_vec bitcode; bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength); Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode); @@ -191,7 +191,7 @@ TEST_F(RenderscriptHidlTest, ScriptInvokeTest) { * Calls: scriptCCreate, elementCreate, typeCreate, allocationCreateTyped, * allocation1DWrite, scriptForEach, allocationRead */ -TEST_F(RenderscriptHidlTest, ScriptForEachTest) { +TEST_P(RenderscriptHidlTest, ScriptForEachTest) { hidl_vec bitcode; bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength); Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode); @@ -237,7 +237,7 @@ TEST_F(RenderscriptHidlTest, ScriptForEachTest) { * Calls: scriptCCreate, elementCreate, typeCreate, allocationCreateTyped, * allocation1DWrite, scriptReduce, contextFinish, allocationRead */ -TEST_F(RenderscriptHidlTest, ScriptReduceTest) { +TEST_P(RenderscriptHidlTest, ScriptReduceTest) { hidl_vec bitcode; bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength); Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode); @@ -288,7 +288,7 @@ TEST_F(RenderscriptHidlTest, ScriptReduceTest) { * allocation1DWrite, scriptBindAllocation, scriptSetVarV, scriptBindAllocation, * allocationRead, scriptInvokeV, allocationRead */ -TEST_F(RenderscriptHidlTest, ScriptBindTest) { +TEST_P(RenderscriptHidlTest, ScriptBindTest) { hidl_vec bitcode; bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength); Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode); @@ -333,7 +333,7 @@ TEST_F(RenderscriptHidlTest, ScriptBindTest) { * scriptGroupCreate, scriptGroupSetInput, scriptGroupSetOutput, * scriptGroupExecute, contextFinish, allocation2DRead */ -TEST_F(RenderscriptHidlTest, ScriptGroupTest) { +TEST_P(RenderscriptHidlTest, ScriptGroupTest) { std::vector dataIn(256 * 256 * 4, 128), dataOut(256 * 256 * 4, 0), zeros(256 * 256 * 4, 0); hidl_vec _dataIn, _dataOut; @@ -418,7 +418,7 @@ TEST_F(RenderscriptHidlTest, ScriptGroupTest) { * invokeClosureCreate, closureCreate, closureSetGlobal, scriptGroup2Create, * scriptGroupExecute, allocationRead */ -TEST_F(RenderscriptHidlTest, ScriptGroup2Test) { +TEST_P(RenderscriptHidlTest, ScriptGroup2Test) { hidl_vec bitcode; bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength); Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode); @@ -495,7 +495,7 @@ TEST_F(RenderscriptHidlTest, ScriptGroup2Test) { * allocation1DWrite, scriptKernelIDCreate, closureCreate, closureSetArg, * scriptGroup2Create, scriptGroupExecute, allocationRead */ -TEST_F(RenderscriptHidlTest, ScriptGroup2KernelTest) { +TEST_P(RenderscriptHidlTest, ScriptGroup2KernelTest) { hidl_vec bitcode; bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength); Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);