OSDN Git Service

Add flush test
authorRam Mohan M <ram.mohan@ittiam.com>
Wed, 23 Aug 2017 12:38:27 +0000 (18:08 +0530)
committerPawin Vongmasa <pawin@google.com>
Sun, 17 Sep 2017 11:23:25 +0000 (04:23 -0700)
1. omx api allows flushing all ports at once by passing the
argument OMX_ALL. This fixture tests the flush call with the
arg OMX_ALL and expects behavior to be same as when the ports
are individually flushed.
2. Flush a port that is not listed and the api call shall
return with error code OMX_ErrorBadPortIndex
3. Test the behavior of flush API call when the component is
not in Execute State (expects OMX_ErrorIncorrectStateOperation)

Note: 2, 3 tests are disabled as of now

Test: make vts -j99 BUILD_GOOGLE_VTS=true TARGET_PRODUCT=aosp_arm64 \
&& vts-tradefed run commandAndExit vts \
--skip-all-system-status-check --primary-abi-only \
--skip-preconditions --module VtsHalMediaOmxV1_0Host \
-l INFO

Bug: 63796949

Change-Id: I6f0cccea0c923116f7e41ed0ef7d8d584631256b

media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp

index 2ec86b2..0dd3a61 100644 (file)
@@ -583,6 +583,109 @@ TEST_F(ComponentHidlTest, Flush) {
                             kPortIndexInput, kPortIndexOutput);
 }
 
+// Flush test - monkeying
+TEST_F(ComponentHidlTest, Flush_M) {
+    description("Test Flush monkeying");
+    if (disableTest) return;
+    android::hardware::media::omx::V1_0::Status status;
+    uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
+    Message msg;
+
+    status = setRole(omxNode, gEnv->getRole().c_str());
+    ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+    OMX_PORT_PARAM_TYPE params;
+    if (compClass == audio_decoder || compClass == audio_encoder) {
+        status = getParam(omxNode, OMX_IndexParamAudioInit, &params);
+    } else {
+        status = getParam(omxNode, OMX_IndexParamVideoInit, &params);
+    }
+    if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+        ASSERT_EQ(params.nPorts, 2U);
+        kPortIndexInput = params.nStartPortNumber;
+        kPortIndexOutput = kPortIndexInput + 1;
+    }
+
+    android::Vector<BufferInfo> iBuffer, oBuffer;
+
+    // set port mode
+    PortMode portMode[2];
+    initPortMode(portMode, isSecure, compClass);
+    status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+    status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+    //    // Flush all ports ; receive error OMX_ErrorIncorrectStateOperation
+    //    status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
+    //    OMX_ALL);
+    //    ASSERT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+    // set state to idle
+    changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
+                            kPortIndexInput, kPortIndexOutput, portMode);
+
+    //    // Flush all ports ; receive error OMX_ErrorIncorrectStateOperation
+    //    status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
+    //    OMX_ALL);
+    //    ASSERT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+    // set state to executing
+    changeStateIdletoExecute(omxNode, observer);
+    // dispatch buffers
+    for (size_t i = 0; i < oBuffer.size(); i++) {
+        dispatchOutputBuffer(omxNode, &oBuffer, i, portMode[1]);
+    }
+
+    //    // flush invalid port, expecting OMX_ErrorBadPortIndex
+    //    status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
+    //                                  RANDOM_INDEX);
+    //    ASSERT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+    // Flush all ports
+    status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush), OMX_ALL);
+    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+    for (int j = 0; j < 2; j++) {
+        status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_PE, &iBuffer,
+                                          &oBuffer);
+        ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+        ASSERT_EQ(msg.type, Message::Type::EVENT);
+        ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
+        ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
+        if (msg.data.eventData.data2 == kPortIndexInput) {
+            // test if client got all its buffers back
+            for (size_t i = 0; i < iBuffer.size(); ++i) {
+                EXPECT_EQ(iBuffer[i].owner, client);
+            }
+        } else if (msg.data.eventData.data2 == kPortIndexOutput) {
+            // test if client got all its buffers back
+            for (size_t i = 0; i < oBuffer.size(); ++i) {
+                EXPECT_EQ(oBuffer[i].owner, client);
+            }
+        } else {
+            EXPECT_TRUE(false) << "Bad port Index";
+        }
+    }
+
+    // SPECIAL CASE: When OMX_ALL is used as argument, Android OMX Core sends
+    // an additional flush event with argument OMX_ALL. This we believe is
+    // not recognized by OMX-IL Spec. So read this event and ignore it
+    status =
+        observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_PE, &iBuffer, &oBuffer);
+    if (status == android::hardware::media::omx::V1_0::Status::OK) {
+        ASSERT_EQ(msg.type, Message::Type::EVENT);
+        ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
+        ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
+        ASSERT_EQ(msg.data.eventData.data2, OMX_ALL);
+    }
+
+    // set state to idle
+    changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
+    // set state to loaded
+    changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
+                            kPortIndexInput, kPortIndexOutput);
+}
+
 // test port mode configuration when the component is in various states
 TEST_F(ComponentHidlTest, PortModeConfig) {
     description("Test Port Mode Configuration");