OMX_ERRORTYPE OMX_CONF_WaitForResourcesTest(OMX_IN OMX_STRING cComponentName)
    {
        /* Interop test 4.7: Wait For Resources */
        /* ---------------------------------------
         * 1. Load component
         * 2. Transition to idle
         * 3. Repeat from steps 1-3 until transition to idle returns
         *    OMX_ErrorInsufficientResources and transitions to Wait state
         * 4. Switch one of the previous components to the loaded state to free resources
         * 5. Verify the component in the WaitForResources state transitions to idle
         */

        OMX_HANDLETYPE hComp[1000];
        OMX_U32 i, nComp = 0;
        OMX_ERRORTYPE  eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE  oCallbacks;
        OMXWFRTESTDATA    oAppData[1000];
        OMX_STATETYPE     eState = OMX_StateLoaded;
        OMX_BOOL          bTimeout  = OMX_FALSE;
        OMX_PRIORITYMGMTTYPE oPriority;
        OMX_HANDLETYPE hTraceComp[1000];
        OMX_HANDLETYPE hEventStateChange;
        OMX_ERRORTYPE eErrorCleanup;
        OMX_PTR pWrappedAppData[1000];
        OMX_CALLBACKTYPE *pWrappedCallbacks[1000];
        char szInstantiationName[256];

        /* Initialize data */
        oCallbacks.EventHandler         = WaitResEventHandler;
        oCallbacks.EmptyBufferDone      = StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone       = StubbedFillBufferDone;

        /* Begin test */
        eError = OMX_Init();
        if (OMX_ErrorNone != eError) return OMX_ErrorUndefined;

        hEventStateChange       = 0;
        hEventStateChangeIdle   = 0;
        hEventStateChangeLoaded = 0;
        eError = OMX_OSAL_EventCreate(&hEventStateChange);
        OMX_CONF_FAIL_IF_ERROR(eError);
        eError = OMX_OSAL_EventCreate(&hEventStateChangeIdle);
        OMX_CONF_FAIL_IF_ERROR(eError);
        eError = OMX_OSAL_EventCreate(&hEventStateChangeLoaded);
        OMX_CONF_FAIL_IF_ERROR(eError);

        INIT_PARAM(oPriority);
        oPriority.nGroupPriority = OMX_RESOURCETEST_PRIORITY_LOW;
        oPriority.nGroupID       = 1;


        nComp = 0;
        do
        {
            hComp[nComp] = hTraceComp[nComp] = NULL;
            GetInstantiationName(cComponentName, nComp, szInstantiationName);
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Trying to create and idle instantiation %i (priority = %i)\n",
                           nComp, OMX_RESOURCETEST_PRIORITY_LOW);
            if (nComp >= 1000)
            {
                OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Test unable to complete. Too many components requested (%d)\n", nComp);
                eError = OMX_ErrorUndefined;
                goto OMX_CONF_TEST_FAIL;
            }

            oAppData[nComp].bErrorInsufficientResources = OMX_FALSE;
            oAppData[nComp].hEventStateChange      = hEventStateChange;
            oAppData[nComp].nInstantiation = nComp;

            eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR) & oAppData[nComp], szInstantiationName,
                                                   &pWrappedCallbacks[nComp], &pWrappedAppData[nComp]);
            OMX_CONF_FAIL_IF_ERROR(eError);

            hComp[nComp] = NULL;
            eError = OMX_GetHandle(&hComp[nComp], cComponentName, pWrappedAppData[nComp], pWrappedCallbacks[nComp]);
            OMX_CONF_FAIL_IF_ERROR(eError); /* Problem acquiring handle. bail. */

            eError = OMX_CONF_ComponentTracerCreate(hComp[nComp], szInstantiationName, &hTraceComp[nComp]);
            OMX_CONF_FAIL_IF_ERROR(eError);

            /* Set priority and transition to idle */
            eError = OMX_SetParameter(hTraceComp[nComp], OMX_IndexParamPriorityMgmt, &oPriority);
            OMX_CONF_FAIL_IF_ERROR(eError);

            /* Disable all ports so we can go idle without buffers */
            eError = DisableAllPorts(hTraceComp[nComp]);
            OMX_CONF_FAIL_IF_ERROR(eError);

            eError = OMX_SendCommand(hTraceComp[nComp], OMX_CommandStateSet, OMX_StateIdle, 0);
            OMX_CONF_FAIL_IF_ERROR(eError);
            OMX_OSAL_EventWait(hEventStateChange, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
            if (bTimeout == OMX_TRUE)
            {
                eError = OMX_ErrorTimeout;
                goto OMX_CONF_TEST_FAIL;
            }
            OMX_OSAL_EventReset(hEventStateChange);

            eError = OMX_GetState(hTraceComp[nComp], &eState);
            OMX_CONF_FAIL_IF_ERROR(eError);
            nComp++;

        }
        while (!oAppData[nComp-1].bErrorInsufficientResources);

        nComp--;

        /* check that the last try stayed in loaded because of insufficient resources */
        if ((eState != OMX_StateLoaded) || !oAppData[nComp].bErrorInsufficientResources)
        {
            eError = OMX_ErrorUndefined;
            goto OMX_CONF_TEST_FAIL;
        }

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Instantiation %i failed to idle (insuffient resources)\n", nComp);

        /* tell last try it to wait for resources */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Telling instantiation %i to wait for resources\n", nComp);
        OMX_OSAL_EventReset(hEventStateChange);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hTraceComp[nComp], OMX_CommandStateSet, OMX_StateWaitForResources, 0));
        OMX_OSAL_EventWait(hEventStateChange, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (bTimeout == OMX_TRUE)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: Timed out waiting for state change from instantiation %i\n", nComp);
            eError = OMX_ErrorTimeout;
            goto OMX_CONF_TEST_FAIL;
        }
        OMX_CONF_FAIL_IF_ERROR(OMX_GetState(hTraceComp[nComp], &eState));
        if (eState != OMX_StateWaitForResources)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: State of instantiation %i is not OMX_StateWaitForResources\n", nComp);
            eError = OMX_ErrorUndefined;
            goto OMX_CONF_TEST_FAIL;
        }

        /* transition first try to loaded */
        OMX_OSAL_EventReset(hEventStateChange);
        OMX_OSAL_EventReset(hEventStateChangeIdle);
        OMX_OSAL_EventReset(hEventStateChangeLoaded);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Telling instantiation 0 to go to loaded\n", nComp);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hTraceComp[0], OMX_CommandStateSet, OMX_StateLoaded, 0));
        OMX_OSAL_EventWait(hEventStateChangeLoaded, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (bTimeout == OMX_TRUE)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: Timed out waiting for state change from instantiation 0\n");
            eError = OMX_ErrorTimeout;
            goto OMX_CONF_TEST_FAIL;
        }
        OMX_CONF_FAIL_IF_ERROR(OMX_GetState(hTraceComp[0], &eState));
        if (eState != OMX_StateLoaded)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: State of instantiation 0 is not OMX_StateLoaded\n");
            eError = OMX_ErrorUndefined;
            goto OMX_CONF_TEST_FAIL;
        }

        /* wait for last try to get resources */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Waiting for instantiation %i to go to idle\n", nComp);
        OMX_OSAL_EventWait(hEventStateChangeIdle, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (bTimeout == OMX_TRUE)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: Timed out waiting for state change from instantiation %i\n", nComp);
            eError = OMX_ErrorTimeout;
            goto OMX_CONF_TEST_FAIL;
        }
        OMX_CONF_FAIL_IF_ERROR(OMX_GetState(hTraceComp[nComp], &eState));
        if (eState != OMX_StateIdle)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: State of instantiation %i is not OMX_StateIdle\n", nComp);
            eError = OMX_ErrorUndefined;
            goto OMX_CONF_TEST_FAIL;
        }

OMX_CONF_TEST_FAIL:
        /* Cleanup */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Cleaning up\n");
        for (i = 1;i <= nComp;i++)
        {
            OMX_ERRORTYPE eErrorCleanup;

            if (hTraceComp[i] != NULL)
            {
                OMX_OSAL_EventReset(hEventStateChange);
                eErrorCleanup = OMX_SendCommand(hTraceComp[i], OMX_CommandStateSet, OMX_StateLoaded, 0);
                if (OMX_ErrorNone == eErrorCleanup)
                {
                    OMX_OSAL_EventWait(hEventStateChange, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
                }
            }
        }

        for (i = 0;i <= nComp;i++)
        {
            OMX_OSAL_EventReset(hEventStateChange);
            OMX_OSAL_EventWait(hEventStateChange, 20, &bTimeout);
            if (hComp[i] != NULL)
                eErrorCleanup = OMX_FreeHandle(hComp[i]);
        }

        for (i = 0;i <= nComp;i++)
        {
            /* unset trace component */
            if (hTraceComp[i] != NULL)
                OMX_CONF_ComponentTracerDestroy(hTraceComp[i]);
        }

        for (i = 0;i <= nComp;i++)
        {
            OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks[i], pWrappedAppData[i]);
        }

        if (hEventStateChange)
        {
            OMX_OSAL_EventDestroy(hEventStateChange);
        }

        if (hEventStateChangeIdle)
        {
            OMX_OSAL_EventDestroy(hEventStateChangeIdle);
        }

        if (hEventStateChangeLoaded)
        {
            OMX_OSAL_EventDestroy(hEventStateChangeLoaded);
        }

        OMX_Deinit();

        return eError;
    }
    OMX_ERRORTYPE OMX_CONF_BufferTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_ERRORTYPE eError = OMX_ErrorNone;
        OMX_ERRORTYPE eCleanupError = OMX_ErrorNone;
        TEST_CTXTYPE ctx;
        TEST_CTXTYPE *pCtx;
        OMX_HANDLETYPE hComp  = 0x0;
        OMX_CALLBACKTYPE oCallbacks;
        OMX_HANDLETYPE hWrappedComp = 0x0;
        OMX_CALLBACKTYPE *pWrappedCallbacks;
        OMX_PTR pWrappedAppData;
        OMX_BOOL bTimeout;
        TEST_PORTTYPE *pPort;
        OMX_U32 i;
        OMX_U32 nPortIndex;
        OMX_PARAM_PORTDEFINITIONTYPE sPortDefinition;

        oCallbacks.EventHandler    =  BufferTest_EventHandler;
        oCallbacks.EmptyBufferDone =  StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone  =  StubbedFillBufferDone;

        pCtx = &ctx;
        pCtx->hStateChangeEvent = 0x0;
        pCtx->hPortDisableEvent = 0x0;
        pCtx->hPortEnableEvent = 0x0;
        pCtx->hPortErrorEvent = 0x0;
        pCtx->aPorts = 0x0;
        pCtx->bRestartAllPorts = OMX_FALSE;
        pCtx->bStopAllPorts = OMX_FALSE;

        /* initialize events to track callbacks */
        OMX_OSAL_EventCreate(&pCtx->hStateChangeEvent);
        OMX_OSAL_EventReset(pCtx->hStateChangeEvent);
        OMX_OSAL_EventCreate(&pCtx->hPortDisableEvent);
        OMX_OSAL_EventReset(pCtx->hPortDisableEvent);
        OMX_OSAL_EventCreate(&pCtx->hPortEnableEvent);
        OMX_OSAL_EventReset(pCtx->hPortEnableEvent);
        OMX_OSAL_EventCreate(&pCtx->hPortErrorEvent);
        OMX_OSAL_EventReset(pCtx->hPortErrorEvent);

        eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR)pCtx, cComponentName,
                                               &pWrappedCallbacks, &pWrappedAppData);
        OMX_CONF_BAIL_ON_ERROR(eError);

        /* Initialize OpenMax */
        eError = OMX_Init();
        OMX_CONF_BAIL_ON_ERROR(eError);

        eError = OMX_GetHandle(&hComp, cComponentName, pWrappedAppData, pWrappedCallbacks);
        OMX_CONF_BAIL_ON_ERROR(eError);
        eError = OMX_CONF_ComponentTracerCreate(hComp, cComponentName, &hWrappedComp);
        OMX_CONF_BAIL_ON_ERROR(eError);

        pCtx->hWrappedComp = hWrappedComp;

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected all port on component %s\n", cComponentName);
        /* inspect component's ports */
        OMX_CONF_INIT_STRUCT(pCtx->sPortParam[0], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(hWrappedComp, OMX_IndexParamAudioInit, (OMX_PTR) & pCtx->sPortParam[0]);
        if (OMX_ErrorUnsupportedIndex == eError)  eError = OMX_ErrorNone;
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i audio ports starting at %i \n",
                       pCtx->sPortParam[0].nPorts, pCtx->sPortParam[0].nStartPortNumber);

        /* detect all video ports on the component */
        OMX_CONF_INIT_STRUCT(pCtx->sPortParam[1], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(hWrappedComp, OMX_IndexParamVideoInit, (OMX_PTR) & pCtx->sPortParam[1]);
        if (OMX_ErrorUnsupportedIndex == eError)  eError = OMX_ErrorNone;
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i video ports starting at %i \n",
                       pCtx->sPortParam[1].nPorts, pCtx->sPortParam[1].nStartPortNumber);

        /* detect all image ports on the component */
        OMX_CONF_INIT_STRUCT(pCtx->sPortParam[2], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(hWrappedComp, OMX_IndexParamImageInit, (OMX_PTR) & pCtx->sPortParam[2]);
        if (OMX_ErrorUnsupportedIndex == eError)  eError = OMX_ErrorNone;
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i image ports starting at %i \n",
                       pCtx->sPortParam[2].nPorts, pCtx->sPortParam[2].nStartPortNumber);

        /* detect all other ports on the component */
        OMX_CONF_INIT_STRUCT(pCtx->sPortParam[3], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(hWrappedComp, OMX_IndexParamOtherInit, (OMX_PTR) & pCtx->sPortParam[3]);
        if (OMX_ErrorUnsupportedIndex == eError)  eError = OMX_ErrorNone;
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i other ports starting at %i \n",
                       pCtx->sPortParam[3].nPorts, pCtx->sPortParam[3].nStartPortNumber);

        /* record total number of ports and allocate port structures */
        pCtx->nNumPorts = pCtx->sPortParam[0].nPorts +
                          pCtx->sPortParam[1].nPorts +
                          pCtx->sPortParam[2].nPorts +
                          pCtx->sPortParam[3].nPorts;

        if (0x0 == pCtx->nNumPorts)
        {
            OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Component has no ports\n");
        }

        /* allocate port structures */
        eError = BufferTest_AllocatePortStructures(pCtx);
        OMX_CONF_BAIL_ON_ERROR(eError);

        /* transition component to idle, verifying that the component does not
           go to IDLE within a certain timeout */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command component to OMX_StateIdle\n");
        OMX_OSAL_EventReset(pCtx->hStateChangeEvent);
        eError = OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0x0);
        OMX_CONF_BAIL_ON_ERROR(eError);

        /* allocate some buffers on the ports, vertifying the component does
           not transition to idle */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Allocate some buffers on all ports\n");
        eError = BufferTest_AllocateAllButOne(pCtx);
        OMX_CONF_BAIL_ON_ERROR(eError);

        OMX_OSAL_EventWait(pCtx->hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_FAILURE, &bTimeout);
        if (OMX_FALSE == bTimeout)
        {
            OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Unexpected state transition to OMX_StateIdle\n");
        }

        /* allocate all buffers on the ports, vertifying the component does
           transition to idle */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Allocate remaining buffers on all ports\n");
        eError = BufferTest_AllocateAllPlusOne(pCtx);
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_EventWait(pCtx->hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (OMX_TRUE == bTimeout)
        {
            OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "State transition to OMX_StateIdle never occured\n");
        }

        /* transition the component to from idle to loaded, verifying the component
           does not transition */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command component to OMX_StateLoaded\n");
        OMX_OSAL_EventReset(pCtx->hStateChangeEvent);
        eError = OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateLoaded, 0x0);
        OMX_CONF_BAIL_ON_ERROR(eError);

        /* free some buffers */
        eError = BufferTest_FreeAllButOne(pCtx);
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_EventWait(pCtx->hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_FAILURE, &bTimeout);
        if (OMX_FALSE == bTimeout)
        {
            OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Unexpected state transition to OMX_StateLoaded\n");
        }

        /* free all buffers and confirm component transitions to loaded */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Free buffers on all ports\n");
        eError = BufferTest_FreeAll(pCtx);
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_EventWait(pCtx->hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (OMX_TRUE == bTimeout)
        {
            OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Expected state transition to OMX_StateLoaded\n");
        }

        /* stop all ports */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command all ports to disabled\n");
        pCtx->bStopAllPorts = OMX_TRUE;
        pCtx->nNumPortsStopped = 0x0;
        OMX_OSAL_EventReset(pCtx->hPortDisableEvent);
        eError = OMX_SendCommand(hWrappedComp, OMX_CommandPortDisable, OMX_ALL, 0x0);
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_EventWait(pCtx->hPortDisableEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (OMX_TRUE == bTimeout)
        {
            OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "All ports not disabled\n");
        }
        pCtx->bStopAllPorts = OMX_FALSE;

        /* set the component to idle */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command component to OMX_StateIdle\n");
        OMX_OSAL_EventReset(pCtx->hStateChangeEvent);
        eError = OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0x0);
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_EventWait(pCtx->hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (OMX_TRUE == bTimeout)
        {
            OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Expected state transition to OMX_StateIdle\n");
        }

        pPort = pCtx->aPorts;

        for (i = 0; i < pCtx->nNumPorts; i++)
        {
            /* verify port enable and populated status */
            nPortIndex =  pPort->sPortDef.nPortIndex;
            OMX_CONF_INIT_STRUCT(sPortDefinition, OMX_PARAM_PORTDEFINITIONTYPE);
            sPortDefinition.nPortIndex = nPortIndex;
            eError = OMX_GetParameter(pCtx->hWrappedComp, OMX_IndexParamPortDefinition,
                                      (OMX_PTR) & sPortDefinition);
            OMX_CONF_BAIL_ON_ERROR(eError);

            OMX_CONF_ASSERT(eError, (OMX_FALSE == sPortDefinition.bEnabled),
                            "Incorrect value in PortDefinition bEnabled field\n");
            OMX_CONF_ASSERT(eError, (OMX_FALSE == sPortDefinition.bPopulated),
                            "Incorrect value in PortDefinition bPopulated field\n");

            /* enable port, and verify it does not restart */
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command port %i to enabled\n", nPortIndex);
            OMX_OSAL_EventReset(pCtx->hPortEnableEvent);
            pCtx->nRestartPort = nPortIndex;
            eError = OMX_SendCommand(hWrappedComp, OMX_CommandPortEnable, nPortIndex, 0x0);
            OMX_CONF_BAIL_ON_ERROR(eError);
            OMX_OSAL_EventWait(pCtx->hPortEnableEvent, OMX_CONF_TIMEOUT_EXPECTING_FAILURE, &bTimeout);
            if (OMX_FALSE == bTimeout)
            {
                OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Port enabled unexpectedly\n");
            }

            /* verify port enabled, but not populated */
            OMX_CONF_INIT_STRUCT(sPortDefinition, OMX_PARAM_PORTDEFINITIONTYPE);
            sPortDefinition.nPortIndex = nPortIndex;
            eError = OMX_GetParameter(pCtx->hWrappedComp, OMX_IndexParamPortDefinition,
                                      (OMX_PTR) & sPortDefinition);
            OMX_CONF_BAIL_ON_ERROR(eError);

            OMX_CONF_ASSERT(eError, (OMX_TRUE == sPortDefinition.bEnabled),
                            "Incorrect value in PortDefinition bEnabled field\n");
            OMX_CONF_ASSERT(eError, (OMX_FALSE == sPortDefinition.bPopulated),
                            "Incorrect value in PortDefinition bPopulated field\n");

            /* allocate buffers on the port, and verify it restarts */
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Allocate buffers on port %i\n", nPortIndex);
            eError = BufferTest_PortAllocateNumBuffers(pCtx, pPort, (pPort->sPortDef.nBufferCountActual));
            OMX_CONF_BAIL_ON_ERROR(eError);
            OMX_OSAL_EventWait(pCtx->hPortEnableEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
            if (OMX_TRUE == bTimeout)
            {
                OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Port never enabled\n");
            }

            /* verify port enabled and populated */
            OMX_CONF_INIT_STRUCT(sPortDefinition, OMX_PARAM_PORTDEFINITIONTYPE);
            sPortDefinition.nPortIndex = nPortIndex;
            eError = OMX_GetParameter(pCtx->hWrappedComp, OMX_IndexParamPortDefinition,
                                      (OMX_PTR) & sPortDefinition);
            OMX_CONF_BAIL_ON_ERROR(eError);

            OMX_CONF_ASSERT(eError, (OMX_TRUE == sPortDefinition.bEnabled),
                            "Incorrect value in PortDefinition bEnabled field\n");
            OMX_CONF_ASSERT(eError, (OMX_TRUE == sPortDefinition.bPopulated),
                            "Incorrect value in PortDefinition bPopulated field\n");

            /* stop port, verifying it does not stop */
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command port %i to disabled\n", nPortIndex);
            OMX_OSAL_EventReset(pCtx->hPortDisableEvent);
            pCtx->nStopPort = nPortIndex;
            eError = OMX_SendCommand(hWrappedComp, OMX_CommandPortDisable, nPortIndex, 0x0);
            OMX_CONF_BAIL_ON_ERROR(eError);
            OMX_OSAL_EventWait(pCtx->hPortDisableEvent, OMX_CONF_TIMEOUT_EXPECTING_FAILURE, &bTimeout);
            if (OMX_FALSE == bTimeout)
            {
                OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Port disabled unexpectedly\n");
            }

            /* free buffers on the port, verifying it stops */
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Free buffers on port %i\n", nPortIndex);
            eError = BufferTest_PortFreeNumBuffers(pCtx, pPort, LIFO_INQUEUE(pPort->pLifo));
            OMX_CONF_BAIL_ON_ERROR(eError);
            OMX_OSAL_EventWait(pCtx->hPortDisableEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
            if (OMX_TRUE == bTimeout)
            {
                OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Port never disabled\n");
            }

            /* verify port not enabled, not populated */
            OMX_CONF_INIT_STRUCT(sPortDefinition, OMX_PARAM_PORTDEFINITIONTYPE);
            sPortDefinition.nPortIndex = nPortIndex;
            eError = OMX_GetParameter(pCtx->hWrappedComp, OMX_IndexParamPortDefinition,
                                      (OMX_PTR) & sPortDefinition);
            OMX_CONF_BAIL_ON_ERROR(eError);

            OMX_CONF_ASSERT(eError, (OMX_FALSE == sPortDefinition.bEnabled),
                            "Incorrect value in PortDefinition bEnabled field\n");
            OMX_CONF_ASSERT(eError, (OMX_FALSE == sPortDefinition.bPopulated),
                            "Incorrect value in PortDefinition bPopulated field\n");

            /* enable the port and allocate buffers */
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command port %i to enabled\n", nPortIndex);
            OMX_OSAL_EventReset(pCtx->hPortEnableEvent);
            eError = OMX_SendCommand(hWrappedComp, OMX_CommandPortEnable, nPortIndex, 0x0);
            OMX_CONF_BAIL_ON_ERROR(eError);
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Allocate buffers on port %i\n", nPortIndex);
            eError = BufferTest_PortAllocateNumBuffers(pCtx, pPort, (pPort->sPortDef.nBufferCountActual));
            OMX_CONF_BAIL_ON_ERROR(eError);
            OMX_OSAL_EventWait(pCtx->hPortEnableEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
            if (OMX_TRUE == bTimeout)
            {
                OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Port never enabled\n");
            }

            /* test the port errors when buffers are freed */
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Free buffers on port %i\n", nPortIndex);
            OMX_OSAL_EventReset(pCtx->hPortErrorEvent);
            eError = BufferTest_PortFreeNumBuffers(pCtx, pPort, LIFO_INQUEUE(pPort->pLifo));
            OMX_CONF_BAIL_ON_ERROR(eError);

            /* waiting for component to report error due to lost buffers */
            OMX_OSAL_EventWait(pCtx->hPortErrorEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
            if (OMX_TRUE == bTimeout)
            {
                OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined,
                                        "Component did not report OMX_ErrorPortUnpopulated\n");
            }

            /* verify port enabled, but not populated */
            OMX_CONF_INIT_STRUCT(sPortDefinition, OMX_PARAM_PORTDEFINITIONTYPE);
            sPortDefinition.nPortIndex = nPortIndex;
            eError = OMX_GetParameter(pCtx->hWrappedComp, OMX_IndexParamPortDefinition,
                                      (OMX_PTR) & sPortDefinition);
            OMX_CONF_BAIL_ON_ERROR(eError);

            OMX_CONF_ASSERT(eError, (OMX_TRUE == sPortDefinition.bEnabled),
                            "Incorrect value in PortDefinition bEnabled field\n");
            OMX_CONF_ASSERT(eError, (OMX_FALSE == sPortDefinition.bPopulated),
                            "Incorrect value in PortDefinition bPopulated field\n");

            /* stop the port */
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command port %i to disabled\n", nPortIndex);
            OMX_OSAL_EventReset(pCtx->hPortDisableEvent);
            pCtx->nStopPort = nPortIndex;
            eError = OMX_SendCommand(hWrappedComp, OMX_CommandPortDisable, nPortIndex, 0x0);
            OMX_OSAL_EventWait(pCtx->hPortDisableEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
            if (OMX_TRUE == bTimeout)
            {
                OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Port never disabled\n");
            }

            /* verify port not enabled, but not populated */
            OMX_CONF_INIT_STRUCT(sPortDefinition, OMX_PARAM_PORTDEFINITIONTYPE);
            sPortDefinition.nPortIndex = nPortIndex;
            eError = OMX_GetParameter(pCtx->hWrappedComp, OMX_IndexParamPortDefinition,
                                      (OMX_PTR) & sPortDefinition);
            OMX_CONF_BAIL_ON_ERROR(eError);

            OMX_CONF_ASSERT(eError, (OMX_FALSE == sPortDefinition.bEnabled),
                            "Incorrect value in PortDefinition bEnabled field\n");
            OMX_CONF_ASSERT(eError, (OMX_FALSE == sPortDefinition.bPopulated),
                            "Incorrect value in PortDefinition bPopulated field\n");

            pPort++;
        }

        /* transition component from idle to loaded */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command component to OMX_StateLoaded\n");
        OMX_OSAL_EventReset(pCtx->hStateChangeEvent);
        eError = OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateLoaded, 0x0);
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_EventWait(pCtx->hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (OMX_TRUE == bTimeout)
        {
            OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "Expected state transition to OMX_StateLoaded\n");
        }

        /* restart all ports */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Command all ports to enable\n");
        pCtx->bRestartAllPorts = OMX_TRUE;
        pCtx->nNumPortsRestarted = 0x0;
        OMX_OSAL_EventReset(pCtx->hPortEnableEvent);
        eError = OMX_SendCommand(hWrappedComp, OMX_CommandPortEnable, OMX_ALL, 0x0);
        OMX_CONF_BAIL_ON_ERROR(eError);
        OMX_OSAL_EventWait(pCtx->hPortEnableEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (OMX_TRUE == bTimeout)
        {
            OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorUndefined, "All ports not enabled\n");
        }
        pCtx->bRestartAllPorts = OMX_FALSE;


OMX_CONF_TEST_BAIL:

        eCleanupError = BufferTest_FreePortStructures(pCtx);

        if (hWrappedComp)
        {
            OMX_CONF_ComponentTracerDestroy(hWrappedComp);
        }

        if (hComp)
        {
            if (OMX_ErrorNone == eCleanupError)
            {
                eCleanupError = OMX_FreeHandle(hComp);

            }
            else
            {
                OMX_FreeHandle(hComp);
            }
        }

        if (OMX_ErrorNone != eCleanupError)
        {
            OMX_Deinit();

        }
        else
        {
            eCleanupError = OMX_Deinit();
        }

        OMX_OSAL_EventDestroy(pCtx->hStateChangeEvent);
        OMX_OSAL_EventDestroy(pCtx->hPortDisableEvent);
        OMX_OSAL_EventDestroy(pCtx->hPortEnableEvent);
        OMX_OSAL_EventDestroy(pCtx->hPortErrorEvent);

        if (OMX_ErrorNone == eError)
        {
            /* if there were no failures during the test, report any errors found
               during cleanup */
            eError = eCleanupError;
        }

        return(eError);
    }
    OMX_ERRORTYPE OMX_CONF_ResourceExhaustionTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_ERRORTYPE eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE oCallbacks;
        ResourceExhaustionTestContext oAppData;
        OMX_CALLBACKTYPE *pWrapCallbacks;
        OMX_PTR pWrapAppData;
        ResourceExhaustionTestContext *pCtxt;
        OMX_U32 i;

        pCtxt = &oAppData;
        memset(pCtxt, 0x0, sizeof(ResourceExhaustionTestContext));

        oCallbacks.EventHandler    =  ResourceExhaustionTest_EventHandler;
        oCallbacks.EmptyBufferDone =  StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone  =  StubbedFillBufferDone;

        eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR)pCtxt, cComponentName,
                                               &pWrapCallbacks, &pWrapAppData);

        OMX_OSAL_EventCreate(&pCtxt->hStateSetEvent);
        OMX_OSAL_EventReset(pCtxt->hStateSetEvent);

        /* Initialize OpenMax */
        eError = OMX_Init();
        OMX_CONF_BAIL_IF_ERROR(eError);

        eError = ResourceExhaustionTest_LOAD(pCtxt, cComponentName, pWrapAppData, pWrapCallbacks);
        OMX_CONF_BAIL_IF_ERROR(eError);

        /* detect all audio ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[0], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp[pCtxt->nInst], OMX_IndexParamAudioInit,
                                  (OMX_PTR) & pCtxt->sPortParam[0]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i audio ports starting at %i \n",
                       pCtxt->sPortParam[0].nPorts, pCtxt->sPortParam[0].nStartPortNumber);

        /* detect all video ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[1], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp[pCtxt->nInst], OMX_IndexParamVideoInit,
                                  (OMX_PTR) & pCtxt->sPortParam[1]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i video ports starting at %i \n",
                       pCtxt->sPortParam[1].nPorts, pCtxt->sPortParam[1].nStartPortNumber);

        /* detect all image ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[2], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp[pCtxt->nInst], OMX_IndexParamImageInit,
                                  (OMX_PTR) & pCtxt->sPortParam[2]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i image ports starting at %i \n",
                       pCtxt->sPortParam[2].nPorts, pCtxt->sPortParam[2].nStartPortNumber);

        /* detect all other ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[3], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp[pCtxt->nInst], OMX_IndexParamOtherInit,
                                  (OMX_PTR) & pCtxt->sPortParam[3]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i other ports starting at %i \n",
                       pCtxt->sPortParam[3].nPorts, pCtxt->sPortParam[3].nStartPortNumber);

        OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateIdle));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Repeatedly load and idle component\n");
        /* JVW-NVIDIA: set bound to MAX_INSTANCE-1 http://cvs.khronos.org/bugzilla/show_bug.cgi?id=219 */
        while (pCtxt->nInst++ < MAX_INSTANCE - 1)
        {
            eError = ResourceExhaustionTest_LOAD(pCtxt, cComponentName, pWrapAppData, pWrapCallbacks);
            if (eError != OMX_ErrorNone)
                break;

            eError = ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateIdle);
            if (eError != OMX_ErrorNone)
                break;
        }
        if (eError == OMX_ErrorInsufficientResources)
            eError = OMX_ErrorNone;

        if (pCtxt->nInst == MAX_INSTANCE)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Resources not exhausted - increase max instance\n");
            eError = OMX_ErrorUndefined;
        }
        OMX_CONF_BAIL_IF_ERROR(eError);

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Resources exhausted by instance %d\n", pCtxt->nInst);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Alternatively de-allocate/allocate last 2 instances\n");

        for (i = 0x0; i < MAX_ITERATIONS; i++)
        {
            /* Unload last successfully idled instance */
            pCtxt->nInst--;
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateLoaded));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_UNLOAD(pCtxt));

            /* Load last failing instance */
            pCtxt->nInst++;
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_UNLOAD(pCtxt));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_LOAD(pCtxt, cComponentName, pWrapAppData, pWrapCallbacks));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateIdle));

            /* Unload last successfully idled instance */
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateLoaded));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_UNLOAD(pCtxt));

            /* Load last failing instance */
            pCtxt->nInst--;
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_LOAD(pCtxt, cComponentName, pWrapAppData, pWrapCallbacks));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateIdle));

            pCtxt->nInst++;
        }

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "De-allocate all instances\n");
        while (pCtxt->nInst--)
        {
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateLoaded));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_UNLOAD(pCtxt));
        }

OMX_CONF_TEST_BAIL:
        /* cleanup: return function errors rather than closing errors if appropriate */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Cleanup\n");
        if (OMX_ErrorNone == eError)
        {
            eError = OMX_CONF_CallbackTracerDestroy(pWrapCallbacks, pWrapAppData);
            eError = OMX_Deinit();
        }
        else
        {
            do
            {
                if (pCtxt->hWComp[pCtxt->nInst])
                {
                    ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateInvalid);
                    ResourceExhaustionTest_DeInitBuffer(pCtxt);
                    ResourceExhaustionTest_UNLOAD(pCtxt);
                }
            }
            while (pCtxt->nInst--);

            OMX_CONF_CallbackTracerDestroy(pWrapCallbacks, pWrapAppData);
            OMX_Deinit();
        }

        OMX_OSAL_EventDestroy(pCtxt->hStateSetEvent);

        return eError;
    }
    /* Main entrypoint into the Incomplete Stop Test */
    OMX_ERRORTYPE OMX_CONF_IncompleteStopTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_PTR pWrappedAppData;
        OMX_CALLBACKTYPE *pWrappedCallbacks;
        OMX_HANDLETYPE hComp, hWrappedComp, hTTComp, hWrappedTTComp;
        OMX_ERRORTYPE  eTemp, eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE oCallbacks;
        ISTDATATYPE oAppData;
        OMX_BOOL bTimedOut;

        /* create state change event */
        OMX_OSAL_EventCreate(&oAppData.hStateChangeEvent);
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_OSAL_EventCreate(&oAppData.hEOSEvent);
        OMX_OSAL_EventReset(oAppData.hEOSEvent);

        /* init component handles */
        hComp = hWrappedComp = hTTComp = hWrappedTTComp = 0;

        oCallbacks.EventHandler    = ISTEventHandler;
        oCallbacks.EmptyBufferDone = StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone  = StubbedFillBufferDone;
        eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR) & oAppData, cComponentName,
                                               &pWrappedCallbacks, &pWrappedAppData);

        /* Initialize OpenMax */
        eError = OMX_Init();

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Creating component under test and tunnel test component.\n");

        /* Acquire component under test handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_GetHandle(&hComp, cComponentName, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hComp, cComponentName, &hWrappedComp));
        oAppData.hCUT = hComp;

        /* Acquire tunnel test component handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_GetTunnelTestComponentHandle(&hTTComp, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hTTComp, "OMX.CONF.tunnel.test", &hWrappedTTComp));

        /* Connect CUT to TTC */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Connecting all ports.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_TTCConnectAllPorts(hWrappedTTComp, hWrappedComp));

        /* Force all CUT ports to be suppliers */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Forcing all component ports to be suppliers.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ForceSuppliers(hWrappedComp, OMX_TRUE));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ForceSuppliers(hWrappedTTComp, OMX_FALSE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transitioning to executing.\n");

        /* transition CUT to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition TTC to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition CUT to executing */
        OMX_CONF_FAIL_IF_ERROR(ISTWaitForState(&oAppData, OMX_StateIdle));
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateExecuting, 0));
        OMX_CONF_FAIL_IF_ERROR(ISTWaitForState(&oAppData, OMX_StateExecuting));

        /* transition TTC to executing  */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateExecuting, 0));

        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_WaitForBufferTraffic(hTTComp));

        /* tell TTC to hold buffers */
        TTCHoldBuffers(hTTComp);

        /* transition CUT to back to idle */
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* wait for change to idle - this must time out */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Holding outstanding buffers, waiting for transition to idle.\n");
        OMX_OSAL_EventWait(oAppData.hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_FAILURE, &bTimedOut);
        if (!bTimedOut)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-ERROR: Transitioned to idle.\n");
            eError = OMX_ErrorUndefined;
        }
        else
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-OK: Didn't transitioned to idle.\n");
        }

        /* tell TTC to release buffers */
        TTCReleaseBuffers(hTTComp);

        /* wait for change to idle - this must succeed */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Released outstanding buffers, waiting for transition to idle.\n");
        OMX_OSAL_EventWait(oAppData.hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimedOut);
        if (bTimedOut || oAppData.eState != OMX_StateIdle)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-ERROR: Didn't transition to idle.\n");
            eError = OMX_ErrorUndefined;
        }
        else
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-OK: Transitioned to idle.\n");
        }

OMX_CONF_TEST_FAIL:

        /* Cleanup: Return function errors rather than closing errors if appropriate */

        /* transition CUT to Loaded state */
        if (hWrappedComp)
        {
            OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        /* transition TTC to Loaded state */
        if (hWrappedTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        OMX_CONF_REMEMBER_ERROR(ISTWaitForState(&oAppData, OMX_StateLoaded));

        /* destroy state change event */
        OMX_OSAL_EventDestroy(oAppData.hStateChangeEvent);
        OMX_OSAL_EventDestroy(oAppData.hEOSEvent);

        if (hWrappedComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedComp));
        }

        if (hComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_FreeHandle(hComp));
        }

        if (hTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_FreeTunnelTestComponentHandle(hTTComp));
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedTTComp));
        }

        OMX_CONF_REMEMBER_ERROR(OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData));
        OMX_CONF_REMEMBER_ERROR(OMX_Deinit());

        return eError;
    }
    /* Main entrypoint into the Seeking Component Test */
    OMX_ERRORTYPE OMX_CONF_SeekingComponentTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_TIME_CONFIG_SEEKMODETYPE oSeekMode;
        OMX_TIME_CONFIG_TIMESTAMPTYPE oTimeStamp;
        OMX_PTR pWrappedAppData;
        OMX_CALLBACKTYPE *pWrappedCallbacks;
        OMX_HANDLETYPE hComp, hWrappedComp, hTTComp, hWrappedTTComp;
        OMX_ERRORTYPE  eTemp, eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE oCallbacks;
        SCTDATATYPE oAppData;

        /* create state change event */
        OMX_OSAL_EventCreate(&oAppData.hStateChangeEvent);
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_OSAL_EventCreate(&oAppData.hEOSEvent);
        OMX_OSAL_EventReset(oAppData.hEOSEvent);

        /* init component handles */
        hComp = hWrappedComp = hTTComp = hWrappedTTComp = 0;

        oCallbacks.EventHandler    = SCTEventHandler;
        oCallbacks.EmptyBufferDone = StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone  = StubbedFillBufferDone;
        eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR) & oAppData, cComponentName,
                                               &pWrappedCallbacks, &pWrappedAppData);

        /* Initialize OpenMax */
        eError = OMX_Init();

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Creating component under test and tunnel test component.\n");

        /* Acquire component under test handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_GetHandle(&hComp, cComponentName, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hComp, cComponentName, &hWrappedComp));
        oAppData.hCUT = hComp;

        /* Acquire tunnel test component handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_GetTunnelTestComponentHandle(&hTTComp, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hTTComp, "OMX.CONF.tunnel.test", &hWrappedTTComp));

        /* Set the OnEmptyThisBuffer callback */
        OMX_CONF_SetTTCOnEmptyThisBuffer(hTTComp, SCTOnEmptyThisBuffer);

        /* Connect CUT to TTC */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Connecting all ports.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_TTCConnectAllPorts(hWrappedTTComp, hWrappedComp));

        /* Force all CUT ports to be suppliers */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Forcing all component ports to be suppliers.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ForceSuppliers(hWrappedComp, OMX_TRUE));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ForceSuppliers(hWrappedTTComp, OMX_FALSE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transitioning to executing.\n");

        /* transition CUT to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition TTC to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition CUT to executing */
        OMX_CONF_FAIL_IF_ERROR(SCTWaitForState(&oAppData, OMX_StateIdle));
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateExecuting, 0));
        OMX_CONF_FAIL_IF_ERROR(SCTWaitForState(&oAppData, OMX_StateExecuting));

        /* transition TTC to executing  */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateExecuting, 0));

        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_WaitForBufferTraffic(hTTComp));

        /* Get/Set OMX_IndexConfigTimeSeekMode */
        INIT_CONFIG(oSeekMode);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Confirm support for OMX_IndexConfigTimeSeekMode\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_GetConfig(hComp, OMX_IndexConfigTimeSeekMode, (OMX_PTR)&oSeekMode));
        oSeekMode.eType = OMX_TIME_SeekModeAccurate;
        OMX_CONF_FAIL_IF_ERROR(OMX_SetConfig(hComp, OMX_IndexConfigTimeSeekMode, (OMX_PTR)&oSeekMode));

        /* Get OMX_IndexConfigTimePosition */
        INIT_CONFIG(oTimeStamp);
        oTimeStamp.nPortIndex = 0; /* ignored - but we clear it anyway */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Confirm support for OMX_IndexConfigTimePosition\n");
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-Get the current position (remember it for later).\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_GetConfig(hComp, OMX_IndexConfigTimePosition, (OMX_PTR)&oTimeStamp));

        /* Set OMX_IndexConfigTimePosition */
        /* Wait for the position to move on and then return to it */
        g_StartTimeDetected = OMX_FALSE;
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-Run for a while.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_WaitForBufferTraffic(hTTComp));
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-Seek to the remembered position.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_SetConfig(hComp, OMX_IndexConfigTimePosition, (OMX_PTR)&oTimeStamp));
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-Run for a while - wait for seek (i.e. a OMX_BUFFERFLAG_STARTTIME).\n");
        OMX_CONF_WaitForBufferTraffic(hTTComp);

        if (g_StartTimeDetected)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "--OK: Saw OMX_BUFFERFLAG_STARTTIME.\n");
        }
        else
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "--ERROR: No OMX_BUFFERFLAG_STARTTIME.\n");
            eError = OMX_ErrorUndefined;
        }

OMX_CONF_TEST_FAIL:

        /* Cleanup: Return function errors rather than closing errors if appropriate */

        /* transition CUT and TTC to Loaded state */
        if (hWrappedComp)
        {
            OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));
        }
        if (hWrappedTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));
            TTCReleaseBuffers(hTTComp);
        }
        if (hWrappedComp)
        {
            OMX_CONF_REMEMBER_ERROR(SCTWaitForState(&oAppData, OMX_StateIdle));
            OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
            OMX_CONF_REMEMBER_ERROR(SCTWaitForState(&oAppData, OMX_StateLoaded));
        }
        if (hWrappedTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        /* destroy state change event */
        OMX_OSAL_EventDestroy(oAppData.hStateChangeEvent);
        OMX_OSAL_EventDestroy(oAppData.hEOSEvent);

        if (hWrappedComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedComp));
        }

        if (hComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_FreeHandle(hComp));
        }

        if (hTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_FreeTunnelTestComponentHandle(hTTComp));
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedTTComp));
        }

        OMX_CONF_REMEMBER_ERROR(OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData));
        OMX_CONF_REMEMBER_ERROR(OMX_Deinit());

        return eError;
    }
    /* Main entrypoint into the Valid Input Output Test */
    OMX_ERRORTYPE OMX_CONF_ValidInputOutputTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_PTR pWrappedAppData;
        OMX_CALLBACKTYPE *pWrappedCallbacks;
        OMX_HANDLETYPE hComp, hWrappedComp, hTTComp, hWrappedTTComp;
        OMX_ERRORTYPE  eTemp, eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE oCallbacks;
        VIOTDATATYPE oAppData;

        /* create state change event */
        OMX_OSAL_EventCreate(&oAppData.hStateChangeEvent);
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);

        /* init component handles */
        hComp = hWrappedComp = hTTComp = hWrappedTTComp = 0;

        oCallbacks.EventHandler    = VIOTEventHandler;
        oCallbacks.EmptyBufferDone = StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone  = StubbedFillBufferDone;
        eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR) & oAppData, cComponentName,
                                               &pWrappedCallbacks, &pWrappedAppData);

        /* Initialize OpenMax */
        eError = OMX_Init();

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Creating component under test and tunnel test component.\n");

        /* Acquire component under test handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_GetHandle(&hComp, cComponentName, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hComp, cComponentName, &hWrappedComp));
        oAppData.hCUT = hComp;

        /* Acquire tunnel test component handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_GetTunnelTestComponentHandle(&hTTComp, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hTTComp, "OMX.CONF.tunnel.test", &hWrappedTTComp));

        /* Connect CUT to TTC */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Connecting all ports.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_TTCConnectAllPorts(hWrappedTTComp, hWrappedComp));

        /* transition CUT to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition TTC to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));
        OMX_CONF_FAIL_IF_ERROR(VOITWaitForState(&oAppData, OMX_StateIdle));

OMX_CONF_TEST_FAIL:

        /* Cleanup: Return function errors rather than closing errors if appropriate */

        /* transition CUT to Loaded state */
        if (hWrappedComp)
        {
            OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        /* transition TTC to Loaded state */
        if (hWrappedTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        OMX_CONF_REMEMBER_ERROR(VOITWaitForState(&oAppData, OMX_StateLoaded));

        /* destroy state change event */
        OMX_OSAL_EventDestroy(oAppData.hStateChangeEvent);

        if (hWrappedComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedComp));
        }

        if (hComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_FreeHandle(hComp));
        }

        if (hTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_FreeTunnelTestComponentHandle(hTTComp));
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedTTComp));
        }

        OMX_CONF_REMEMBER_ERROR(OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData));
        OMX_CONF_REMEMBER_ERROR(OMX_Deinit());

        return eError;
    }
    OMX_ERRORTYPE OMX_CONF_PortCommunicationTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_ERRORTYPE eError = OMX_ErrorNone;
        OMX_HANDLETYPE hComp  = 0;
        OMX_CALLBACKTYPE sCallbacks;
        PortCommTestCtxt sContext;
        OMX_HANDLETYPE hWrappedComp = 0;
        OMX_CALLBACKTYPE *pWrappedCallbacks;
        OMX_PTR pWrappedAppData;
        PortCommTestCtxt *pCtxt;
        pCtxt = &sContext;
        memset(pCtxt, 0x0, sizeof(PortCommTestCtxt));

        sCallbacks.EventHandler    =  PortCommTest_EventHandler;
        sCallbacks.EmptyBufferDone =  PortCommTest_EmptyBufferDone;
        sCallbacks.FillBufferDone  =  PortCommTest_FillBufferDone;

        eError = OMX_CONF_CallbackTracerCreate(&sCallbacks, (OMX_PTR)pCtxt, cComponentName,
                                               &pWrappedCallbacks, &pWrappedAppData);

        /* initialize events to track callbacks */
        OMX_OSAL_EventCreate(&pCtxt->hStateSetEvent);
        OMX_OSAL_EventReset(pCtxt->hStateSetEvent);
        OMX_OSAL_EventCreate(&pCtxt->hPortDisableEvent);
        OMX_OSAL_EventReset(pCtxt->hPortDisableEvent);
        OMX_OSAL_EventCreate(&pCtxt->hPortEnableEvent);
        OMX_OSAL_EventReset(pCtxt->hPortEnableEvent);
        OMX_OSAL_EventCreate(&pCtxt->hBufDoneEvent);
        OMX_OSAL_EventReset(pCtxt->hBufDoneEvent);
        OMX_OSAL_EventCreate(&pCtxt->hEmptyBufDoneEvent);
        OMX_OSAL_EventReset(pCtxt->hEmptyBufDoneEvent);

        /* Initialize OpenMax */
        eError = OMX_Init();
        OMX_CONF_BAIL_IF_ERROR(eError);

        OMX_CONF_BAIL_IF_ERROR(OMX_GetHandle(&hComp, cComponentName, pWrappedAppData,
                                             pWrappedCallbacks));
        OMX_CONF_BAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hComp, cComponentName,
                               &hWrappedComp));
        pCtxt->hWComp = hWrappedComp;

        /* Verify start in Loaded state */
        OMX_CONF_BAIL_IF_ERROR(OMX_GetState(pCtxt->hWComp, &pCtxt->eState));
        if (pCtxt->eState != OMX_StateLoaded)
            OMX_CONF_SET_ERROR_BAIL("Component not in loaded state at init\n", OMX_ErrorUndefined);

        /* detect all audio ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[0], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp, OMX_IndexParamAudioInit,
                                  (OMX_PTR) & pCtxt->sPortParam[0]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i audio ports starting at %i \n",
                       pCtxt->sPortParam[0].nPorts, pCtxt->sPortParam[0].nStartPortNumber);

        /* detect all video ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[1], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp, OMX_IndexParamVideoInit,
                                  (OMX_PTR) & pCtxt->sPortParam[1]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i video ports starting at %i \n",
                       pCtxt->sPortParam[1].nPorts, pCtxt->sPortParam[1].nStartPortNumber);

        /* detect all image ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[2], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp, OMX_IndexParamImageInit,
                                  (OMX_PTR) & pCtxt->sPortParam[2]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i image ports starting at %i \n",
                       pCtxt->sPortParam[2].nPorts, pCtxt->sPortParam[2].nStartPortNumber);

        /* detect all other ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[3], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp, OMX_IndexParamOtherInit,
                                  (OMX_PTR) & pCtxt->sPortParam[3]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i other ports starting at %i \n",
                       pCtxt->sPortParam[3].nPorts, pCtxt->sPortParam[3].nStartPortNumber);

        pCtxt->nPorts = pCtxt->sPortParam[0].nPorts + pCtxt->sPortParam[1].nPorts +
                        pCtxt->sPortParam[2].nPorts + pCtxt->sPortParam[3].nPorts;

        /* 3.4.1. Non-Tunneling Setup Test */
        /* TODO: reference core does not take null as port */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Non-Tunneling Setup Test\n");
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_OperateOnPorts(pCtxt, NonTunnelTest));

        /* 3.4.2. Transmit Buffers Between Input and Output Ports and Application */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transmit Test - Client allocates - Full payload\n");
        pCtxt->nBufFactor = 1;
        pCtxt->bClientAllocBuf = OMX_TRUE;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_TransmitTest(pCtxt, OMX_TRUE, OMX_TRUE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transmit Test - Client allocates - Half payload\n");
        pCtxt->nBufFactor = 2;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_TransmitTest(pCtxt, OMX_TRUE, OMX_TRUE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transmit Test - Client allocates - Quarter payload\n");
        pCtxt->nBufFactor = 4;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_TransmitTest(pCtxt, OMX_TRUE, OMX_TRUE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transmit Test - Component allocates - Full payload\n");
        pCtxt->bClientAllocBuf = OMX_FALSE;
        pCtxt->nBufFactor = 1;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_TransmitTest(pCtxt, OMX_TRUE, OMX_TRUE));

        /* 3.4.3. Port Repack Test */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Repack Test\n");
        pCtxt->bClientAllocBuf = OMX_TRUE;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_RepackTest(pCtxt));

        /* 3.4.4. Port Stop and Restart Test */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Port Stop and Restart Test\n");
        pCtxt->nBufFactor = 1;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_StopRestartTest(pCtxt));

        /* 3.4.5. Component Pause and Resume Test*/
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Component Pause and Resume Test\n");
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_PauseResume(pCtxt));

OMX_CONF_TEST_BAIL:
        /* cleanup: return function errors rather than closing errors if appropriate */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Cleanup\n");

        if (OMX_ErrorNone == eError)
        {
            if (hWrappedComp)
            {
                eError = OMX_CONF_ComponentTracerDestroy(hWrappedComp);
            }
            if (hComp)
            {
                eError = OMX_FreeHandle(hComp);
            }
            eError = OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData);

            eError = OMX_Deinit();
        }
        else
        {
            PortCommTest_TransitionWait(OMX_StateInvalid, pCtxt);
            PortCommTest_DeInitBuffer(pCtxt);

            if (hWrappedComp)
            {
                OMX_CONF_ComponentTracerDestroy(hWrappedComp);
            }
            if (hComp)
            {
                OMX_FreeHandle(hComp);
            }
            OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData);
            OMX_Deinit();
        }

        OMX_OSAL_EventDestroy(pCtxt->hStateSetEvent);
        OMX_OSAL_EventDestroy(pCtxt->hPortDisableEvent);
        OMX_OSAL_EventDestroy(pCtxt->hPortEnableEvent);
        OMX_OSAL_EventDestroy(pCtxt->hBufDoneEvent);
        OMX_OSAL_EventDestroy(pCtxt->hEmptyBufDoneEvent);

        return eError;
    }