Convert VtsHalRenderscriptV1_0TargetTest to be parameterized test

Bug: 142397658
Test: atest VtsHalRenderscriptV1_0TargetTest
Change-Id: I319f113d2c80afc75a28a480e3dd1c7739c5f2d7
This commit is contained in:
Dan Shi 2019-12-11 10:23:03 -08:00
parent 56cda83f8c
commit bc404e6c80
6 changed files with 39 additions and 59 deletions

View file

@ -28,5 +28,5 @@ cc_test {
"android.hardware.renderscript@1.0",
"libnativewindow",
],
test_suites: ["general-tests"],
test_suites: ["general-tests", "vts-core"],
}

View file

@ -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);

View file

@ -18,8 +18,7 @@
// The main test class for RENDERSCRIPT HIDL HAL.
void RenderscriptHidlTest::SetUp() {
device = ::testing::VtsHalHidlTargetTestBase::getService<IDevice>(
RenderscriptHidlEnvironment::Instance()->getServiceName<IDevice>());
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);

View file

@ -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 <android-base/logging.h>
@ -24,9 +23,9 @@
#include <android/hardware/renderscript/1.0/IDevice.h>
#include <android/hardware/renderscript/1.0/types.h>
#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
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<std::string> {
public:
virtual void SetUp() override;
virtual void TearDown() override;
@ -99,17 +98,3 @@ public:
private:
sp<IDevice> 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<IDevice>(); }
};
#endif // VTS_HAL_RENDERSCRIPT_V1_0_TARGET_TESTS_H

View file

@ -25,14 +25,14 @@
*
* Calls: getService<IDevice>, 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/");

View file

@ -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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> dataIn(256 * 256 * 4, 128), dataOut(256 * 256 * 4, 0),
zeros(256 * 256 * 4, 0);
hidl_vec<uint8_t> _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<uint8_t> 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<uint8_t> bitcode;
bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);