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
(cherry picked from commit 2d8834dc96)
This commit is contained in:
Changyeon Jo 2021-11-08 08:12:33 -08:00
parent ab78601274
commit 912b16f8c5
2 changed files with 39 additions and 14 deletions

View file

@ -65,8 +65,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);
}
@ -363,8 +363,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();
@ -380,9 +386,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<EvsResult> goodResult = pCam->setMaxFramesInFlight(kBuffersToHold);
EXPECT_EQ(EvsResult::OK, goodResult);
// Find the minimum number of buffers to run a target camera.
while (buffersToHold < kMaxBuffersToHold) {
Return<EvsResult> 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> frameHandler = new FrameHandler(pCam, cam,
@ -398,7 +411,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
@ -409,7 +422,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.

View file

@ -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();
@ -566,9 +572,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<EvsResult> goodResult = pCam->setMaxFramesInFlight(kBuffersToHold);
EXPECT_EQ(EvsResult::OK, goodResult);
while (buffersToHold < kMaxBuffersToHold) {
Return<EvsResult> 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> frameHandler = new FrameHandler(pCam, cam,
@ -584,7 +596,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
@ -595,7 +607,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.