ref: b889f392ab866f1b1c451fedc7968e3e3bff8ac1
parent: d188ef65e1a23eb29ee8d1dcaeeaf823b41723a3
parent: 006f5e5031b75bce619e0846192c375db78b08ff
author: huili2 <huili2@cisco.com>
date: Thu May 11 04:43:35 EDT 2017
Merge pull request #2747 from shihuade/NewDesign_UTCrash_V2.0 UT crash issue: assert instead expect to protect ut from crash
--- a/test/encoder/EncUT_SliceBufferReallocate.cpp
+++ b/test/encoder/EncUT_SliceBufferReallocate.cpp
@@ -169,7 +169,7 @@
//param validation
int32_t iRet = m_pEncoder->InitializeExt ((SEncParamExt*)m_EncContext.pSvcParam);
- EXPECT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (cmResultSuccess == iRet);
}
void CSliceBufferReallocatTest::InitParamForSizeLimitSlcModeCase (int32_t iLayerIdx) {
@@ -184,18 +184,18 @@
UnInitLayerSliceBuffer (iLayerIdx);
pSliceArgument->uiSliceMode = SM_SIZELIMITED_SLICE;
iRet = InitParamForSizeLimitSlcMode (&m_EncContext, iLayerIdx);
- EXPECT_TRUE (ENC_RETURN_SUCCESS == iRet);
- EXPECT_TRUE (NULL != m_EncContext.ppDqLayerList[iLayerIdx]);
+ ASSERT_TRUE (ENC_RETURN_SUCCESS == iRet);
+ ASSERT_TRUE (NULL != m_EncContext.ppDqLayerList[iLayerIdx]);
}
//param validation
iRet = m_pEncoder->InitializeExt ((SEncParamExt*)m_EncContext.pSvcParam);
- EXPECT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (cmResultSuccess == iRet);
}
void CSliceBufferReallocatTest::UnInitParamForTestCase (int32_t iLayerIdx) {
int32_t iRet = m_pEncoder->Uninitialize();
- EXPECT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (cmResultSuccess == iRet);
UnInitFrameBsBuffer();
UnInitLayerSliceBuffer (iLayerIdx);
@@ -224,16 +224,16 @@
pCtx->pSvcParam->eSpsPpsIdStrategy = (EParameterSetStrategy) (iParamStraIdx == 4 ? 0x06 : iParamStraIdx);
pCtx->pFuncList = (SWelsFuncPtrList*)pCtx->pMemAlign->WelsMallocz (sizeof (SWelsFuncPtrList), "SWelsFuncPtrList");
- EXPECT_TRUE (NULL != pCtx->pFuncList);
+ ASSERT_TRUE (NULL != pCtx->pFuncList);
pCtx->pFuncList->pParametersetStrategy = IWelsParametersetStrategy::CreateParametersetStrategy (
pCtx->pSvcParam->eSpsPpsIdStrategy,
pCtx->pSvcParam->bSimulcastAVC, pCtx->pSvcParam->iSpatialLayerNum);
- EXPECT_TRUE (NULL != pCtx->pFuncList->pParametersetStrategy);
+ ASSERT_TRUE (NULL != pCtx->pFuncList->pParametersetStrategy);
pCtx->ppDqLayerList = (SDqLayer**)pCtx->pMemAlign->WelsMallocz (pCtx->pSvcParam->iSpatialLayerNum * sizeof (SDqLayer*),
"ppDqLayerList");
- EXPECT_TRUE (NULL != pCtx->ppDqLayerList);
+ ASSERT_TRUE (NULL != pCtx->ppDqLayerList);
}
void CSliceBufferReallocatTest::UnInitParam() {
@@ -269,23 +269,23 @@
int32_t iCountNals = 0;
int32_t iRet = AcquireLayersNals (&pCtx, pCtx->pSvcParam, &pCtx->pSvcParam->iSpatialLayerNum, &iCountNals);
- EXPECT_TRUE (0 == iRet);
+ ASSERT_TRUE (0 == iRet);
// Output
pCtx->pOut = (SWelsEncoderOutput*)pCtx->pMemAlign->WelsMallocz (sizeof (SWelsEncoderOutput), "SWelsEncoderOutput");
- EXPECT_TRUE (NULL != pCtx->pOut);
+ ASSERT_TRUE (NULL != pCtx->pOut);
pCtx->pOut->pBsBuffer = (uint8_t*)pCtx->pMemAlign->WelsMallocz (iCountBsLen, "pOut->pBsBuffer");
- EXPECT_TRUE (NULL != pCtx->pOut->pBsBuffer);
+ ASSERT_TRUE (NULL != pCtx->pOut->pBsBuffer);
pCtx->pOut->uiSize = iCountBsLen;
pCtx->pOut->sNalList = (SWelsNalRaw*)pCtx->pMemAlign->WelsMallocz (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList");
- EXPECT_TRUE (NULL != pCtx->pOut->sNalList);
+ ASSERT_TRUE (NULL != pCtx->pOut->sNalList);
pCtx->pOut->pNalLen = (int32_t*)pCtx->pMemAlign->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen");
- EXPECT_TRUE (NULL != pCtx->pOut->pNalLen);
+ ASSERT_TRUE (NULL != pCtx->pOut->pNalLen);
pCtx->pOut->iCountNals = iCountNals;
pCtx->pOut->iNalIndex = 0;
pCtx->pOut->iLayerBsIndex = 0;
pCtx->pFrameBs = (uint8_t*)pCtx->pMemAlign->WelsMalloc (iCountBsLen, "pFrameBs");
- EXPECT_TRUE (NULL != pCtx->pOut);
+ ASSERT_TRUE (NULL != pCtx->pOut);
pCtx->iFrameBsSize = iCountBsLen;
pCtx->iPosBsBuffer = 0;
}
@@ -357,8 +357,8 @@
iRet = AllocateLayerBuffer (pCtx, iLayerIdx);
}
- EXPECT_TRUE (ENC_RETURN_SUCCESS == iRet);
- EXPECT_TRUE (NULL != pCtx->ppDqLayerList[iLayerIdx]);
+ ASSERT_TRUE (ENC_RETURN_SUCCESS == iRet);
+ ASSERT_TRUE (NULL != pCtx->ppDqLayerList[iLayerIdx]);
pCtx->uiDependencyId = iLayerIdx;
pCtx->pCurDqLayer = pCtx->ppDqLayerList[iLayerIdx];
@@ -376,8 +376,8 @@
if (m_EncContext.pCurDqLayer->bThreadSlcBufferFlag) {
int32_t iCodedSlcNumInThrd = m_EncContext.pCurDqLayer->sSliceBufferInfo[kiThreadIdx].iCodedSliceNum;
- EXPECT_TRUE (NULL != m_EncContext.pCurDqLayer->sSliceBufferInfo[kiThreadIdx].pSliceBuffer);
- EXPECT_TRUE (NULL != &m_EncContext.pCurDqLayer->sSliceBufferInfo[kiThreadIdx].pSliceBuffer[iCodedSlcNumInThrd]);
+ ASSERT_TRUE (NULL != m_EncContext.pCurDqLayer->sSliceBufferInfo[kiThreadIdx].pSliceBuffer);
+ ASSERT_TRUE (NULL != &m_EncContext.pCurDqLayer->sSliceBufferInfo[kiThreadIdx].pSliceBuffer[iCodedSlcNumInThrd]);
m_EncContext.pCurDqLayer->sSliceBufferInfo[kiThreadIdx].pSliceBuffer[iCodedSlcNumInThrd].iSliceIdx = kiSlcIdx;
m_EncContext.pCurDqLayer->sSliceBufferInfo[kiThreadIdx].iCodedSliceNum ++;
@@ -393,7 +393,7 @@
//slice within same partition will encoded by same thread in current design
int32_t iPartitionThrdIdx = RandAvailableThread (&m_EncContext, kiSlcNumInPart);
- EXPECT_TRUE (-1 != iPartitionThrdIdx);
+ ASSERT_TRUE (-1 != iPartitionThrdIdx);
for (int32_t iSlcIdx = 0; iSlcIdx < kiSlcNumInPart; iSlcIdx++) {
iSlcIdxInPart = kiPartIdx + kiPartNum * iSlcIdx;
@@ -428,7 +428,7 @@
} else {
for (int32_t iSlcIdx = 0; iSlcIdx < iSimulateSliceNum; iSlcIdx ++) {
int32_t iSlcThrdIdx = RandAvailableThread (&m_EncContext, 1);
- EXPECT_TRUE (-1 != iSlcThrdIdx);
+ ASSERT_TRUE (-1 != iSlcThrdIdx);
SimulateEncodedOneSlice (iSlcIdx, iSlcThrdIdx);
m_EncContext.pCurDqLayer->sSliceEncCtx.iSliceNumInFrame++;
@@ -445,7 +445,7 @@
pCtx->pCurDqLayer = pCtx->ppDqLayerList[iLayerIdx];
iRet = InitAllSlicesInThread (pCtx);
- EXPECT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (cmResultSuccess == iRet);
//case: reallocate during encoding one partition
// include cases which part num less than thread num
@@ -475,7 +475,7 @@
pCtx->pCurDqLayer = pCtx->ppDqLayerList[iLayerIdx];
iRet = InitAllSlicesInThread (pCtx);
- EXPECT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (cmResultSuccess == iRet);
//case: all partitions encoded by one thread
//example: 3 threads 3 partions
@@ -511,7 +511,7 @@
InitParamForSizeLimitSlcModeCase (iLayerIdx);
pCtx->pCurDqLayer = pCtx->ppDqLayerList[iLayerIdx];
iRet = InitAllSlicesInThread (pCtx);
- EXPECT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (cmResultSuccess == iRet);
//before extend, simulate reallocate slice buffer in one thread
int32_t iReallocateThrdIdx = rand() % pCtx->iActiveThreadsNum;
@@ -520,8 +520,8 @@
iRet = ReallocateSliceList (pCtx, &pCtx->pSvcParam->sSpatialLayers[iLayerIdx].sSliceArgument,
pSlcListInThrd, iSlcBuffNumInThrd, iSlcBuffNumInThrd * 2);
- EXPECT_TRUE (cmResultSuccess == iRet);
- EXPECT_TRUE (NULL != pSlcListInThrd);
+ ASSERT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (NULL != pSlcListInThrd);
pCtx->pCurDqLayer->sSliceBufferInfo[iReallocateThrdIdx].pSliceBuffer = pSlcListInThrd;
pCtx->pCurDqLayer->sSliceBufferInfo[iReallocateThrdIdx].iMaxSliceNum = iSlcBuffNumInThrd * 2;
@@ -575,7 +575,7 @@
pCtx->pCurDqLayer = pCtx->ppDqLayerList[iLayerIdx];
int32_t iRet = InitAllSlicesInThread (pCtx);
- EXPECT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (cmResultSuccess == iRet);
SimulateSliceInOneLayer();
@@ -605,7 +605,7 @@
InitParamForSizeLimitSlcModeCase (iLayerIdx);
pCtx->pCurDqLayer = pCtx->ppDqLayerList[iLayerIdx];
iRet = InitAllSlicesInThread (pCtx);
- EXPECT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (cmResultSuccess == iRet);
SimulateSliceInOneLayer();
@@ -623,8 +623,8 @@
iRet = ReallocateSliceList (pCtx, &pCtx->pSvcParam->sSpatialLayers[iLayerIdx].sSliceArgument,
pSlcListInThrd, iSlcBuffNumInThrd, iSlcBuffNumInThrd * 2);
- EXPECT_TRUE (cmResultSuccess == iRet);
- EXPECT_TRUE (NULL != pSlcListInThrd);
+ ASSERT_TRUE (cmResultSuccess == iRet);
+ ASSERT_TRUE (NULL != pSlcListInThrd);
pCtx->pCurDqLayer->sSliceBufferInfo[iReallocateThrdIdx].pSliceBuffer = pSlcListInThrd;
pCtx->pCurDqLayer->sSliceBufferInfo[iReallocateThrdIdx].iMaxSliceNum = iSlcBuffNumInThrd * 2;
@@ -636,7 +636,7 @@
} else {
iSlcIdxInThrd = pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame;
}
- EXPECT_TRUE (NULL != &pSlcListInThrd[iSlcIdx]);
+ ASSERT_TRUE (NULL != &pSlcListInThrd[iSlcIdx]);
pSlcListInThrd[iSlcIdx].iSliceIdx = iSlcIdxInThrd;
pSlcListInThrd[iSlcIdx].sSliceBs.iNalIndex = rand() % 2 + 1;
pSlcListInThrd[iSlcIdx].sSliceBs.uiBsPos = rand() % pSlcListInThrd[iSlcIdx].sSliceBs.uiSize + 1;
--- a/test/encoder/EncUT_SliceBufferReallocate.h
+++ b/test/encoder/EncUT_SliceBufferReallocate.h
@@ -16,16 +16,16 @@
m_pEncoder = NULL;
int32_t iRet = WelsCreateSVCEncoder (&m_pEncoder);
ASSERT_EQ (0, iRet);
- EXPECT_TRUE (m_pEncoder != NULL);
+ ASSERT_TRUE (m_pEncoder != NULL);
int32_t iCacheLineSize = 16;
m_EncContext.pMemAlign = new CMemoryAlign (iCacheLineSize);
- EXPECT_TRUE (NULL != m_EncContext.pMemAlign);
+ ASSERT_TRUE (NULL != m_EncContext.pMemAlign);
SWelsSvcCodingParam* pCodingParam = (SWelsSvcCodingParam*)m_EncContext.pMemAlign->WelsMalloc (sizeof (
SWelsSvcCodingParam),
"SWelsSvcCodingParam");
- EXPECT_TRUE (NULL != pCodingParam);
+ ASSERT_TRUE (NULL != pCodingParam);
m_EncContext.pSvcParam = pCodingParam;
iRet = m_pEncoder->GetDefaultParams (m_EncContext.pSvcParam);