From b46adc9493b90aa7ec306715b11a1be7944c32ff Mon Sep 17 00:00:00 2001 From: Changyeon Jo Date: Thu, 27 Feb 2020 10:51:04 -0800 Subject: [PATCH] Parameterize VtsHalEvsV1_0TargetTest Bug: 142397658 Test: VtsHalEvsV1_0Target Signed-off-by: Changyeon Jo Merged-In: Ica8f5e6228d7d4b1426d8cc9cd2c570d6b584897 Change-Id: Ide6f4f58b60936ca766feb3090645afedde37a4d --- automotive/evs/1.0/vts/functional/Android.bp | 6 +- .../functional/VtsHalEvsV1_0TargetTest.cpp | 70 ++++++------------- 2 files changed, 27 insertions(+), 49 deletions(-) diff --git a/automotive/evs/1.0/vts/functional/Android.bp b/automotive/evs/1.0/vts/functional/Android.bp index 2ef33fdd11..47702fd85e 100644 --- a/automotive/evs/1.0/vts/functional/Android.bp +++ b/automotive/evs/1.0/vts/functional/Android.bp @@ -25,8 +25,10 @@ cc_test { shared_libs: [ "libui", ], - static_libs: ["android.hardware.automotive.evs@1.0"], - test_suites: ["general-tests"], + static_libs: [ + "android.hardware.automotive.evs@1.0", + ], + test_suites: ["vts-core"], cflags: [ "-O0", "-g", diff --git a/automotive/evs/1.0/vts/functional/VtsHalEvsV1_0TargetTest.cpp b/automotive/evs/1.0/vts/functional/VtsHalEvsV1_0TargetTest.cpp index f7580f02a8..54862a2ccb 100644 --- a/automotive/evs/1.0/vts/functional/VtsHalEvsV1_0TargetTest.cpp +++ b/automotive/evs/1.0/vts/functional/VtsHalEvsV1_0TargetTest.cpp @@ -17,15 +17,6 @@ #define LOG_TAG "VtsHalEvsTest" -// Note: We have't got a great way to indicate which target -// should be tested, so we'll leave the interface served by the -// default (mock) EVS driver here for easy reference. All -// actual EVS drivers should serve on the EvsEnumeratorHw name, -// however, so the code is checked in that way. -//const static char kEnumeratorName[] = "EvsEnumeratorHw-Mock"; -const static char kEnumeratorName[] = "EvsEnumeratorHw"; - - // These values are called out in the EVS design doc (as of Mar 8, 2017) static const int kMaxStreamStartMilliseconds = 500; static const int kMinimumFramesPerSecond = 10; @@ -53,8 +44,9 @@ static const float kNanoToSeconds = 0.000000001f; #include #include -#include -#include +#include +#include +#include using namespace ::android::hardware::automotive::evs::V1_0; using ::android::hardware::Return; @@ -64,32 +56,19 @@ using ::android::hardware::hidl_handle; using ::android::hardware::hidl_string; using ::android::sp; -// Test environment for Evs HIDL HAL. -class EvsHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { - public: - // get the test environment singleton - static EvsHidlEnvironment* Instance() { - static EvsHidlEnvironment* instance = new EvsHidlEnvironment; - return instance; - } - - virtual void registerTestServices() override { registerTestService(); } - - private: - EvsHidlEnvironment() {} -}; - // The main test class for EVS -class EvsHidlTest : public ::testing::VtsHalHidlTargetTestBase { +class EvsHidlTest : public ::testing::TestWithParam { public: virtual void SetUp() override { // Make sure we can connect to the enumerator - string service_name = - EvsHidlEnvironment::Instance()->getServiceName(kEnumeratorName); - pEnumerator = getService(service_name); + std::string service_name = GetParam(); + pEnumerator = IEvsEnumerator::getService(service_name); + ASSERT_NE(pEnumerator.get(), nullptr); - mIsHwModule = !service_name.compare(kEnumeratorName); + // "default" is reserved for EVS manager. + constexpr static char kEvsManagerName[] = "default"; + mIsHwModule = service_name.compare(kEvsManagerName); } virtual void TearDown() override {} @@ -130,7 +109,7 @@ protected: * Opens each camera reported by the enumerator and then explicitly closes it via a * call to closeCamera. Then repeats the test to ensure all cameras can be reopened. */ -TEST_F(EvsHidlTest, CameraOpenClean) { +TEST_P(EvsHidlTest, CameraOpenClean) { ALOGI("Starting CameraOpenClean test"); // Get the camera list @@ -162,7 +141,7 @@ TEST_F(EvsHidlTest, CameraOpenClean) { * call. This ensures that the intended "aggressive open" behavior works. This is necessary for * the system to be tolerant of shutdown/restart race conditions. */ -TEST_F(EvsHidlTest, CameraOpenAggressive) { +TEST_P(EvsHidlTest, CameraOpenAggressive) { ALOGI("Starting CameraOpenAggressive test"); // Get the camera list @@ -216,7 +195,7 @@ TEST_F(EvsHidlTest, CameraOpenAggressive) { * DisplayOpen: * Test both clean shut down and "aggressive open" device stealing behavior. */ -TEST_F(EvsHidlTest, DisplayOpen) { +TEST_P(EvsHidlTest, DisplayOpen) { ALOGI("Starting DisplayOpen test"); // Request exclusive access to the EVS display, then let it go @@ -264,7 +243,7 @@ TEST_F(EvsHidlTest, DisplayOpen) { * Validate that display states transition as expected and can be queried from either the display * object itself or the owning enumerator. */ -TEST_F(EvsHidlTest, DisplayStates) { +TEST_P(EvsHidlTest, DisplayStates) { ALOGI("Starting DisplayStates test"); // Ensure the display starts in the expected state @@ -324,7 +303,7 @@ TEST_F(EvsHidlTest, DisplayStates) { * CameraStreamPerformance: * Measure and qualify the stream start up time and streaming frame rate of each reported camera */ -TEST_F(EvsHidlTest, CameraStreamPerformance) { +TEST_P(EvsHidlTest, CameraStreamPerformance) { ALOGI("Starting CameraStreamPerformance test"); // Get the camera list @@ -387,7 +366,7 @@ TEST_F(EvsHidlTest, CameraStreamPerformance) { * Ensure the camera implementation behaves properly when the client holds onto buffers for more * than one frame time. The camera must cleanly skip frames until the client is ready again. */ -TEST_F(EvsHidlTest, CameraStreamBuffering) { +TEST_P(EvsHidlTest, CameraStreamBuffering) { ALOGI("Starting CameraStreamBuffering test"); // Arbitrary constant (should be > 1 and less than crazy) @@ -456,7 +435,7 @@ TEST_F(EvsHidlTest, CameraStreamBuffering) { * imagery is simply copied to the display buffer and presented on screen. This is the one test * which a human could observe to see the operation of the system on the physical display. */ -TEST_F(EvsHidlTest, CameraToDisplayRoundTrip) { +TEST_P(EvsHidlTest, CameraToDisplayRoundTrip) { ALOGI("Starting CameraToDisplayRoundTrip test"); // Get the camera list @@ -517,7 +496,7 @@ TEST_F(EvsHidlTest, CameraToDisplayRoundTrip) { * Verify that each client can start and stop video streams on the same * underlying camera. */ -TEST_F(EvsHidlTest, MultiCameraStream) { +TEST_P(EvsHidlTest, MultiCameraStream) { ALOGI("Starting MultiCameraStream test"); if (mIsHwModule) { @@ -601,11 +580,8 @@ TEST_F(EvsHidlTest, MultiCameraStream) { } -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(EvsHidlEnvironment::Instance()); - ::testing::InitGoogleTest(&argc, argv); - EvsHidlEnvironment::Instance()->init(&argc, argv); - int status = RUN_ALL_TESTS(); - ALOGI("Test result = %d", status); - return status; -} +INSTANTIATE_TEST_SUITE_P( + PerInstance, + EvsHidlTest, + testing::ValuesIn(android::hardware::getAllHalInstanceNames(IEvsEnumerator::descriptor)), + android::hardware::PrintInstanceNameToString);