ref: 46f42ec5f36ec37bbed58434a5630e4002c43847
parent: 25f53a2e3dd3cc978b9bf76fc14467e802c3ebf1
author: Haibo Zhu <haibozhu@cisco.com>
date: Fri Mar 4 10:49:32 EST 2016
Fix the decoder init failed case in UT
--- a/test/BaseDecoderTest.h
+++ b/test/BaseDecoderTest.h
@@ -28,7 +28,7 @@
};
BaseDecoderTest();
- void SetUp();
+ int32_t SetUp();
void TearDown();
void DecodeFile (const char* fileName, Callback* cbk);
--- a/test/api/BaseDecoderTest.cpp
+++ b/test/api/BaseDecoderTest.cpp
@@ -46,10 +46,13 @@
BaseDecoderTest::BaseDecoderTest()
: decoder_ (NULL), decodeStatus_ (OpenFile) {}
-void BaseDecoderTest::SetUp() {
+int32_t BaseDecoderTest::SetUp() {
long rv = WelsCreateDecoder (&decoder_);
- ASSERT_EQ (0, rv);
- ASSERT_TRUE (decoder_ != NULL);
+ EXPECT_EQ (0, rv);
+ EXPECT_TRUE (decoder_ != NULL);
+ if (decoder_ == NULL) {
+ return rv;
+ }
SDecodingParam decParam;
memset (&decParam, 0, sizeof (SDecodingParam));
@@ -58,7 +61,8 @@
decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
rv = decoder_->Initialize (&decParam);
- ASSERT_EQ (0, rv);
+ EXPECT_EQ (0, rv);
+ return (int32_t)rv;
}
void BaseDecoderTest::TearDown() {
--- a/test/api/decode_api_test.cpp
+++ b/test/api/decode_api_test.cpp
@@ -766,6 +766,13 @@
class DecodeParseAPI : public ::testing::TestWithParam<EncodeDecodeFileParamBase>, public EncodeDecodeTestBase {
public:
+ DecodeParseAPI() {
+ memset (&BsInfo_, 0, sizeof (SParserBsInfo));
+ fYuv_ = NULL;
+ iWidth_ = 0;
+ iHeight_ = 0;
+ memset (&ctx_, 0, sizeof (SHA1Context));
+ }
void SetUp() {
SHA1Reset (&ctx_);
EncodeDecodeTestBase::SetUp();
@@ -789,7 +796,9 @@
}
void TearDown() {
EncodeDecodeTestBase::TearDown();
- fclose (fYuv_);
+ if (fYuv_ != NULL) {
+ fclose (fYuv_);
+ }
}
void prepareEncDecParam (const EncodeDecodeFileParamBase p) {
--- a/test/decoder/DecUT_DecExt.cpp
+++ b/test/decoder/DecUT_DecExt.cpp
@@ -3,6 +3,7 @@
#include "codec_def.h"
#include "codec_app_def.h"
#include "codec_api.h"
+#include "error_code.h"
#include "wels_common_basis.h"
#include "memory_align.h"
#include "ls_defines.h"
@@ -25,9 +26,9 @@
}
}
//Init members
- void Init();
+ int32_t Init();
//Init valid members
- void ValidInit();
+ int32_t ValidInit();
//Uninit members
void Uninit();
//Mock input data for test
@@ -77,7 +78,7 @@
};
//Init members
-void DecoderInterfaceTest::Init() {
+int32_t DecoderInterfaceTest::Init() {
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo));
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
@@ -93,10 +94,11 @@
m_szBuffer[3] = 1;
m_iBufLength = 4;
CM_RETURN eRet = (CM_RETURN) m_pDec->Initialize (&m_sDecParam);
- ASSERT_EQ (eRet, cmResultSuccess);
+ EXPECT_EQ (eRet, cmResultSuccess);
+ return (int32_t)eRet;
}
-void DecoderInterfaceTest::ValidInit() {
+int32_t DecoderInterfaceTest::ValidInit() {
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
m_sDecParam.pFileNameRestructed = NULL;
@@ -111,7 +113,8 @@
m_szBuffer[3] = 1;
m_iBufLength = 4;
CM_RETURN eRet = (CM_RETURN) m_pDec->Initialize (&m_sDecParam);
- ASSERT_EQ (eRet, cmResultSuccess);
+ EXPECT_EQ (eRet, cmResultSuccess);
+ return (int32_t)eRet;
}
void DecoderInterfaceTest::Uninit() {
@@ -220,6 +223,7 @@
void DecoderInterfaceTest::TestInitUninit() {
int iOutput;
CM_RETURN eRet;
+ int32_t iRet = ERR_NONE;
//No initialize, no GetOption can be done
m_pDec->Uninitialize();
for (int i = 0; i <= (int) DECODER_OPTION_TRACE_CALLBACK_CONTEXT; ++i) {
@@ -227,9 +231,13 @@
EXPECT_EQ (eRet, cmInitExpected);
}
//Initialize first, can get input color format
- Init();
+ iRet = Init();
+ ASSERT_EQ (iRet, ERR_NONE);
+
m_sDecParam.bParseOnly = false;
- m_pDec->Initialize (&m_sDecParam);
+ eRet = (CM_RETURN)m_pDec->Initialize (&m_sDecParam);
+ ASSERT_EQ (eRet, cmResultSuccess);
+
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOutput);
EXPECT_EQ (eRet, cmResultSuccess);
EXPECT_EQ (iOutput, 0);
@@ -329,8 +337,10 @@
void DecoderInterfaceTest::TestEndOfStream() {
int iTmp, iOut;
CM_RETURN eRet;
+ int32_t iRet = ERR_NONE;
- ValidInit();
+ iRet = ValidInit();
+ ASSERT_EQ (iRet, ERR_NONE);
//invalid input
eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_END_OF_STREAM, NULL);
@@ -391,8 +401,10 @@
void DecoderInterfaceTest::TestVclNal() {
int iTmp, iOut;
CM_RETURN eRet;
+ int32_t iRet = ERR_NONE;
- ValidInit();
+ iRet = ValidInit();
+ ASSERT_EQ (iRet, ERR_NONE);
//Test SetOption
//VclNal never supports SetOption
@@ -453,8 +465,10 @@
void DecoderInterfaceTest::TestErrorConIdc() {
int iTmp, iOut;
CM_RETURN eRet;
+ int32_t iRet = ERR_NONE;
- Init();
+ iRet = Init();
+ ASSERT_EQ (iRet, ERR_NONE);
//Test GetOption
//invalid input
@@ -498,10 +512,12 @@
//DECODER_OPTION_GET_STATISTICS
void DecoderInterfaceTest::TestGetDecStatistics() {
CM_RETURN eRet;
+ int32_t iRet;
SDecoderStatistics sDecStatic;
int32_t iError = 0;
- ValidInit();
+ iRet = ValidInit();
+ ASSERT_EQ (iRet, ERR_NONE);
//GetOption before decoding
m_pDec->GetOption (DECODER_OPTION_GET_STATISTICS, &sDecStatic);
EXPECT_EQ (0u, sDecStatic.uiDecodedFrameCount);
@@ -528,7 +544,8 @@
Uninit();
//Decoder error bs when the first IDR lost
- ValidInit();
+ iRet = ValidInit();
+ ASSERT_EQ (iRet, ERR_NONE);
iError = 2;
m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError);
DecoderBs ("res/BA_MW_D_IDR_LOST.264");
@@ -546,7 +563,9 @@
Uninit();
//ecoder error bs when the first P lost
- ValidInit();
+ iRet = ValidInit();
+ ASSERT_EQ (iRet, ERR_NONE);
+
iError = 2;
m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError);
@@ -567,7 +586,9 @@
//EC enable
//EC Off UT just correc bitstream
- ValidInit();
+ iRet = ValidInit();
+ ASSERT_EQ (iRet, ERR_NONE);
+
iError = 0;
m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError);
DecoderBs ("res/test_vd_1d.264");
--- a/test/decoder/DecUT_ParseSyntax.cpp
+++ b/test/decoder/DecUT_ParseSyntax.cpp
@@ -128,7 +128,7 @@
}
}
//Init members
- void Init();
+ int32_t Init();
//Uninit members
void Uninit();
//Decoder real bitstream
@@ -155,7 +155,7 @@
};
//Init members
-void DecoderParseSyntaxTest::Init() {
+int32_t DecoderParseSyntaxTest::Init() {
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo));
@@ -180,7 +180,7 @@
m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR);
}
CM_RETURN eRet = (CM_RETURN)Initialize (&m_sDecParam, m_pCtx, &m_pWelsTrace->m_sLogCtx);
- (void) eRet;
+ return (int32_t)eRet;
}
void DecoderParseSyntaxTest::Uninit() {
@@ -262,7 +262,9 @@
uint8_t iScalingListPPS[6][16];
memset (iScalingListPPS, 0, 6 * 16 * sizeof (uint8_t));
//Scalinglist matrix not written into sps or pps
- Init();
+ int32_t iRet = ERR_NONE;
+ iRet = Init();
+ ASSERT_EQ (iRet, ERR_NONE);
DecodeBs ("res/BA_MW_D.264");
ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false);
EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
@@ -270,7 +272,8 @@
EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
Uninit();
//Scalinglist value just written into sps and pps
- Init();
+ iRet = Init();
+ ASSERT_EQ (iRet, ERR_NONE);
DecodeBs ("res/test_scalinglist_jm.264");
ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag);
for (int i = 0; i < 6; i++) {
@@ -280,8 +283,6 @@
ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false);
EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
Uninit();
-
-
}
//TEST here for whole tests