From 2d8834dc96bd6980fc0ab1917bf8485730e5a584 Mon Sep 17 00:00:00 2001 From: Changyeon Jo Date: Mon, 8 Nov 2021 08:12:33 -0800 Subject: [PATCH] Update CameraStreamBuffering test and correct instance name - CameraStreamBuffering test is modified to use the minimum number of frame buffers that is required to run a camera pipeline for a single client instead of using an arbitrarily chosen number, which may not work for certain device implementations. - Fix a name of v1.0 EvsManager implementation in VtsHalEvsV1_0TargetTest.cpp Bug: 305642713 Test: atest VtsHalEvsV1_0TargetTest and atest VtsHalEvsV1_1TargetTest Change-Id: Ieec986dbdf947311e0bc86871432da8a988d37ad --- .../functional/VtsHalEvsV1_0TargetTest.cpp | 29 ++++++++++++++----- .../functional/VtsHalEvsV1_1TargetTest.cpp | 24 +++++++++++---- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/automotive/evs/1.0/vts/functional/VtsHalEvsV1_0TargetTest.cpp b/automotive/evs/1.0/vts/functional/VtsHalEvsV1_0TargetTest.cpp index 9c72acdf8f..580b0ee721 100644 --- a/automotive/evs/1.0/vts/functional/VtsHalEvsV1_0TargetTest.cpp +++ b/automotive/evs/1.0/vts/functional/VtsHalEvsV1_0TargetTest.cpp @@ -66,8 +66,8 @@ public: ASSERT_NE(pEnumerator.get(), nullptr); - // "default" is reserved for EVS manager. - constexpr static char kEvsManagerName[] = "default"; + // "legacy_sw/0" is reserved for EVS manager v1.0 implementation. + constexpr static char kEvsManagerName[] = "legacy_sw/0"; mIsHwModule = service_name.compare(kEvsManagerName); } @@ -364,8 +364,14 @@ TEST_P(EvsHidlTest, CameraStreamPerformance) { TEST_P(EvsHidlTest, CameraStreamBuffering) { ALOGI("Starting CameraStreamBuffering test"); - // Arbitrary constant (should be > 1 and not too big) - static const unsigned int kBuffersToHold = 2; + // Maximum number of frames in flight this test case will attempt. This test + // case chooses an arbitrary number that is large enough to run a camera + // pipeline for a single client. + constexpr unsigned int kMaxBuffersToHold = 20; + + // Initial value for setMaxFramesInFlight() call. This number should be + // greater than 1. + unsigned int buffersToHold = 2; // Get the camera list loadCameraList(); @@ -381,9 +387,16 @@ TEST_P(EvsHidlTest, CameraStreamBuffering) { EXPECT_EQ(EvsResult::BUFFER_NOT_AVAILABLE, badResult); // Now ask for exactly two buffers in flight as we'll test behavior in that case - Return goodResult = pCam->setMaxFramesInFlight(kBuffersToHold); - EXPECT_EQ(EvsResult::OK, goodResult); + // Find the minimum number of buffers to run a target camera. + while (buffersToHold < kMaxBuffersToHold) { + Return goodResult = pCam->setMaxFramesInFlight(buffersToHold); + if (goodResult == EvsResult::OK) { + break; + } + ++buffersToHold; + } + EXPECT_LE(buffersToHold, kMaxBuffersToHold); // Set up a frame receiver object which will fire up its own thread. sp frameHandler = new FrameHandler(pCam, cam, @@ -399,7 +412,7 @@ TEST_P(EvsHidlTest, CameraStreamBuffering) { sleep(2); // 1 second should be enough for at least 5 frames to be delivered worst case unsigned framesReceived = 0; frameHandler->getFramesCounters(&framesReceived, nullptr); - ASSERT_EQ(kBuffersToHold, framesReceived) << "Stream didn't stall at expected buffer limit"; + ASSERT_EQ(buffersToHold, framesReceived) << "Stream didn't stall at expected buffer limit"; // Give back one buffer @@ -410,7 +423,7 @@ TEST_P(EvsHidlTest, CameraStreamBuffering) { // filled since we require 10fps minimum -- but give a 10% allowance just in case. usleep(110 * kMillisecondsToMicroseconds); frameHandler->getFramesCounters(&framesReceived, nullptr); - EXPECT_EQ(kBuffersToHold+1, framesReceived) << "Stream should've resumed"; + EXPECT_EQ(buffersToHold+1, framesReceived) << "Stream should've resumed"; // Even when the camera pointer goes out of scope, the FrameHandler object will // keep the stream alive unless we tell it to shutdown. diff --git a/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp b/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp index 9c8bfc4996..03f256ec81 100644 --- a/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp +++ b/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp @@ -534,8 +534,14 @@ TEST_P(EvsHidlTest, CameraStreamPerformance) { TEST_P(EvsHidlTest, CameraStreamBuffering) { LOG(INFO) << "Starting CameraStreamBuffering test"; - // Arbitrary constant (should be > 1 and not too big) - static const unsigned int kBuffersToHold = 2; + // Maximum number of frames in flight this test case will attempt. This test + // case chooses an arbitrary number that is large enough to run a camera + // pipeline for a single client. + constexpr unsigned int kMaxBuffersToHold = 20; + + // Initial value for setMaxFramesInFlight() call. This number should be + // greater than 1. + unsigned int buffersToHold = 2; // Get the camera list loadCameraList(); @@ -567,9 +573,15 @@ TEST_P(EvsHidlTest, CameraStreamBuffering) { EXPECT_EQ(EvsResult::BUFFER_NOT_AVAILABLE, badResult); // Now ask for exactly two buffers in flight as we'll test behavior in that case - Return goodResult = pCam->setMaxFramesInFlight(kBuffersToHold); - EXPECT_EQ(EvsResult::OK, goodResult); + while (buffersToHold < kMaxBuffersToHold) { + Return goodResult = pCam->setMaxFramesInFlight(buffersToHold); + if (goodResult == EvsResult::OK) { + break; + } + ++buffersToHold; + } + EXPECT_LE(buffersToHold, kMaxBuffersToHold); // Set up a frame receiver object which will fire up its own thread. sp frameHandler = new FrameHandler(pCam, cam, @@ -585,7 +597,7 @@ TEST_P(EvsHidlTest, CameraStreamBuffering) { sleep(1); // 1 second should be enough for at least 5 frames to be delivered worst case unsigned framesReceived = 0; frameHandler->getFramesCounters(&framesReceived, nullptr); - ASSERT_EQ(kBuffersToHold, framesReceived) << "Stream didn't stall at expected buffer limit"; + ASSERT_EQ(buffersToHold, framesReceived) << "Stream didn't stall at expected buffer limit"; // Give back one buffer @@ -596,7 +608,7 @@ TEST_P(EvsHidlTest, CameraStreamBuffering) { // filled since we require 10fps minimum -- but give a 10% allowance just in case. usleep(110 * kMillisecondsToMicroseconds); frameHandler->getFramesCounters(&framesReceived, nullptr); - EXPECT_EQ(kBuffersToHold+1, framesReceived) << "Stream should've resumed"; + EXPECT_EQ(buffersToHold+1, framesReceived) << "Stream should've resumed"; // Even when the camera pointer goes out of scope, the FrameHandler object will // keep the stream alive unless we tell it to shutdown.