diff --git a/src/modules/audio_coding/codecs/g711/test/testG711.cpp b/src/modules/audio_coding/codecs/g711/test/testG711.cpp index fe831280a..747f9229e 100644 --- a/src/modules/audio_coding/codecs/g711/test/testG711.cpp +++ b/src/modules/audio_coding/codecs/g711/test/testG711.cpp @@ -42,7 +42,7 @@ int readframe(WebRtc_Word16 *data, FILE *inp, int length) { int main(int argc, char* argv[]) { char inname[80], outname[40], bitname[40]; - FILE *inp, *outp, *bitp; + FILE *inp, *outp, *bitp = NULL; int framecnt, endfile; WebRtc_Word16 framelength = 80; diff --git a/src/modules/audio_coding/codecs/g722/test/testG722.cpp b/src/modules/audio_coding/codecs/g722/test/testG722.cpp index 24d794f10..9ef8f2d91 100644 --- a/src/modules/audio_coding/codecs/g722/test/testG722.cpp +++ b/src/modules/audio_coding/codecs/g722/test/testG722.cpp @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) /* Runtime statistics */ double starttime; - double runtime; + double runtime = 0; double length_file; WebRtc_Word16 stream_len = 0; diff --git a/src/modules/audio_coding/codecs/iSAC/fix/test/kenny.c b/src/modules/audio_coding/codecs/iSAC/fix/test/kenny.c index 524298cd4..3aaaf2e7d 100644 --- a/src/modules/audio_coding/codecs/iSAC/fix/test/kenny.c +++ b/src/modules/audio_coding/codecs/iSAC/fix/test/kenny.c @@ -101,13 +101,13 @@ int main(int argc, char* argv[]) WebRtc_Word16 CodingMode; WebRtc_Word16 bottleneck; WebRtc_Word16 framesize = 30; /* ms */ - int cur_framesmpls, err, lostPackets = 0; + int cur_framesmpls, err = 0, lostPackets = 0; /* Runtime statistics */ double starttime, runtime, length_file; WebRtc_Word16 stream_len = 0; - WebRtc_Word16 framecnt, declen; + WebRtc_Word16 framecnt, declen = 0; WebRtc_Word16 shortdata[FRAMESAMPLES_10ms]; WebRtc_Word16 decoded[MAX_FRAMESAMPLES]; WebRtc_UWord16 streamdata[500]; @@ -119,7 +119,7 @@ int main(int argc, char* argv[]) WebRtc_Word32 payloadRate = 0; int setControlBWE = 0; int readLoss; - FILE *plFile; + FILE *plFile = NULL; char version_number[20]; char tmpBit[5] = ".bit"; @@ -396,7 +396,9 @@ int main(int argc, char* argv[]) if (fscanf(f_bn, "%d", &aux_var) == EOF) { /* Set pointer to beginning of file */ fseek(f_bn, 0L, SEEK_SET); - fscanf(f_bn, "%d", &aux_var); + if (fscanf(f_bn, "%d", &aux_var) == EOF) { + exit(0); + } } bottleneck = (WebRtc_Word16)aux_var; /* Bottleneck is a cosine function @@ -640,7 +642,9 @@ int main(int argc, char* argv[]) if (fscanf(f_bn, "%d", &aux_var) == EOF) { /* Set pointer to beginning of file */ fseek(f_bn, 0L, SEEK_SET); - fscanf(f_bn, "%d", &aux_var); + if (fscanf(f_bn, "%d", &aux_var) == EOF) { + exit(0); + } } bottleneck = (WebRtc_Word16)aux_var; if (CodingMode == 1) { @@ -675,11 +679,12 @@ int main(int argc, char* argv[]) if (fp_gns != NULL) { if (fscanf(fp_gns, "%d", &cur_delay) == EOF) { fseek(fp_gns, 0L, SEEK_SET); - fscanf(fp_gns, "%d", &cur_delay); + if (fscanf(fp_gns, "%d", &cur_delay) == EOF) { + exit(0); + } } } - /* simulate packet handling through NetEq and the modem */ if (!(testNum == 3 && framecnt == 0)) { if (gns == 0) { diff --git a/src/modules/audio_coding/codecs/iSAC/main/test/ReleaseTest-API/ReleaseTest-API.cc b/src/modules/audio_coding/codecs/iSAC/main/test/ReleaseTest-API/ReleaseTest-API.cc index 05e3a12a9..b0c28aa3b 100644 --- a/src/modules/audio_coding/codecs/iSAC/main/test/ReleaseTest-API/ReleaseTest-API.cc +++ b/src/modules/audio_coding/codecs/iSAC/main/test/ReleaseTest-API/ReleaseTest-API.cc @@ -58,7 +58,7 @@ int main(int argc, char* argv[]) double starttime, runtime, length_file; WebRtc_Word16 stream_len = 0; - WebRtc_Word16 declen, lostFrame = 0, declenTC; + WebRtc_Word16 declen, lostFrame = 0, declenTC = 0; WebRtc_Word16 shortdata[SWBFRAMESAMPLES_10ms]; WebRtc_Word16 vaddata[SWBFRAMESAMPLES_10ms*3]; @@ -97,10 +97,10 @@ int main(int argc, char* argv[]) bool doTransCoding = false; WebRtc_Word32 rateTransCoding = 0; WebRtc_UWord16 streamDataTransCoding[600]; - WebRtc_Word16 streamLenTransCoding; - FILE* transCodingFile; - FILE* transcodingBitstream; - WebRtc_UWord32 numTransCodingBytes=0; + WebRtc_Word16 streamLenTransCoding = 0; + FILE* transCodingFile = NULL; + FILE* transcodingBitstream = NULL; + WebRtc_UWord32 numTransCodingBytes = 0; /* only one structure used for ISAC encoder */ ISACStruct* ISAC_main_inst; @@ -368,7 +368,9 @@ int main(int argc, char* argv[]) { /* Set pointer to beginning of file */ fseek(f_bn, 0L, SEEK_SET); - fscanf(f_bn, "%d", &bottleneck); + if (fscanf(f_bn, "%d", &bottleneck) == EOF) { + exit(0); + } } /* Bottleneck is a cosine function @@ -744,7 +746,9 @@ int main(int argc, char* argv[]) { /* Set pointer to beginning of file */ fseek(f_bn, 0L, SEEK_SET); - fscanf(f_bn, "%d", &bottleneck); + if (fscanf(f_bn, "%d", &bottleneck) == EOF) { + exit(0); + } } if(CodingMode == 1) { diff --git a/src/modules/audio_coding/codecs/iSAC/main/test/simpleKenny.c b/src/modules/audio_coding/codecs/iSAC/main/test/simpleKenny.c index f5b2a20db..dc3603580 100644 --- a/src/modules/audio_coding/codecs/iSAC/main/test/simpleKenny.c +++ b/src/modules/audio_coding/codecs/iSAC/main/test/simpleKenny.c @@ -108,7 +108,7 @@ int main(int argc, char* argv[]) WebRtc_UWord16 payload[600]; WebRtc_UWord16 payloadRCU[600]; WebRtc_UWord16 packetLossPercent = 0; - WebRtc_Word16 rcuStreamLen; + WebRtc_Word16 rcuStreamLen = 0; int onlyEncode; int onlyDecode; diff --git a/src/modules/audio_coding/main/source/audio_coding_module.gypi b/src/modules/audio_coding/main/source/audio_coding_module.gypi index 044b65e06..6d0deb8b7 100644 --- a/src/modules/audio_coding/main/source/audio_coding_module.gypi +++ b/src/modules/audio_coding/main/source/audio_coding_module.gypi @@ -100,6 +100,7 @@ 'type': 'executable', 'dependencies': [ 'audio_coding_module', + '<(webrtc_root)/../testing/gtest.gyp:gtest', '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', ], 'sources': [ diff --git a/src/modules/audio_coding/main/test/APITest.cpp b/src/modules/audio_coding/main/test/APITest.cpp index 7d7e3e5f5..06f0d78f0 100644 --- a/src/modules/audio_coding/main/test/APITest.cpp +++ b/src/modules/audio_coding/main/test/APITest.cpp @@ -9,20 +9,21 @@ */ #include -#include -#include -#include #include #include +#include +#include +#include #include "APITest.h" -#include "thread_wrapper.h" +#include "common_types.h" +#include "engine_configurations.h" #include "event_wrapper.h" +#include "gtest/gtest.h" +#include "thread_wrapper.h" #include "tick_util.h" #include "trace.h" #include "utility.h" -#include "common_types.h" -#include "engine_configurations.h" #define TEST_DURATION_SEC 600 @@ -310,7 +311,7 @@ APITest::SetUp() char print[11]; printf("\nRandom Test (y/n)?"); - fgets(print, 10, stdin); + EXPECT_TRUE(fgets(print, 10, stdin) != NULL); print[10] = '\0'; if(strstr(print, "y") != NULL) { @@ -327,11 +328,11 @@ APITest::SetUp() Trace::SetTraceFile("ACMAPITest.txt", true); _randomTest = false; printf("\nPrint Tests (y/n)? "); - fgets(print, 10, stdin); + EXPECT_TRUE(fgets(print, 10, stdin) != NULL); print[10] = '\0'; if(strstr(print, "y") == NULL) { - freopen("APITest_log.txt", "w", stdout); + EXPECT_TRUE(freopen("APITest_log.txt", "w", stdout) != 0); _verbose = false; } } @@ -1139,8 +1140,8 @@ void APITest::TestPlayout(char receiveSide) { AudioCodingModule* receiveACM; - AudioPlayoutMode* playoutMode; - ACMBackgroundNoiseMode* bgnMode; + AudioPlayoutMode* playoutMode = NULL; + ACMBackgroundNoiseMode* bgnMode = NULL; switch(receiveSide) { case 'A': diff --git a/src/modules/audio_coding/main/test/EncodeDecodeTest.cpp b/src/modules/audio_coding/main/test/EncodeDecodeTest.cpp index c0fdbf1b4..d46fa87f6 100644 --- a/src/modules/audio_coding/main/test/EncodeDecodeTest.cpp +++ b/src/modules/audio_coding/main/test/EncodeDecodeTest.cpp @@ -9,10 +9,12 @@ */ #include "EncodeDecodeTest.h" -#include "common_types.h" #include #include + +#include "common_types.h" +#include "gtest/gtest.h" #include "trace.h" #include "utility.h" @@ -62,8 +64,8 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) { printf("\nValid output frequencies:\n"); printf("8000\n16000\n32000\n-1, which means output freq equal to received signal freq"); - printf("\n\nChoose output sampling frequency: "); - scanf("%d", &playSampFreq); + printf("\n\nChoose output sampling frequency: "); + ASSERT_GT(scanf("%d", &playSampFreq), 0); char fileName[] = "./src/modules/audio_coding/main/test/outFile.pcm"; _pcmFile.Open(fileName, 32000, "wb+"); } diff --git a/src/modules/audio_coding/main/test/EncodeToFileTest.cpp b/src/modules/audio_coding/main/test/EncodeToFileTest.cpp index eb7affe98..01e7db115 100644 --- a/src/modules/audio_coding/main/test/EncodeToFileTest.cpp +++ b/src/modules/audio_coding/main/test/EncodeToFileTest.cpp @@ -9,8 +9,6 @@ */ #include "EncodeToFileTest.h" -#include "audio_coding_module.h" -#include "common_types.h" #ifdef WIN32 # include @@ -18,11 +16,14 @@ # include #endif - #include #include #include +#include "audio_coding_module.h" +#include "common_types.h" +#include "gtest/gtest.h" + TestPacketization::TestPacketization(RTPStream *rtpStream, WebRtc_UWord16 frequency) : _frequency(frequency), @@ -90,8 +91,7 @@ void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream) printf("%d %s\n", n, sendCodec.plname); } printf("Choose your codec:"); - - scanf("%d", &codecNo); + ASSERT_GT(scanf("%d", &codecNo), 0); char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm"; _pcmFile.Open(fileName, 32000, "rb"); } diff --git a/src/modules/audio_coding/main/test/PCMFile.cpp b/src/modules/audio_coding/main/test/PCMFile.cpp index 7418a3e34..e14101f5f 100644 --- a/src/modules/audio_coding/main/test/PCMFile.cpp +++ b/src/modules/audio_coding/main/test/PCMFile.cpp @@ -1,3 +1,4 @@ + /* * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. * @@ -8,12 +9,13 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "PCMFile.h" + #include #include #include - -#include "PCMFile.h" +#include "gtest/gtest.h" #include "module_common_types.h" #define MAX_FILE_NAME_LENGTH_BYTE 500 @@ -54,7 +56,7 @@ PCMFile::ChooseFile( WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE]; //strcpy(_fileName, "in.pcm"); //printf("\n\nPlease enter the input file: "); - fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin); + EXPECT_TRUE(fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin) != NULL); tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0'; WebRtc_Word16 n = 0; @@ -106,7 +108,7 @@ PCMFile::ChooseFile( WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE]; //strcpy(_fileName, "in.pcm"); //printf("\n\nPlease enter the input file: "); - fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin); + EXPECT_TRUE(fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin) != NULL); tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0'; WebRtc_Word16 n = 0; @@ -147,7 +149,7 @@ PCMFile::ChooseFile( strncpy(fileName, tmpName, len+1); } printf("Enter the sampling frequency (in Hz) of the above file [%u]: ", *frequencyHz); - fgets(tmpName, 10, stdin); + EXPECT_TRUE(fgets(tmpName, 10, stdin) != NULL); WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName); if(tmpFreq > 0) { diff --git a/src/modules/audio_coding/main/test/RTPFile.cpp b/src/modules/audio_coding/main/test/RTPFile.cpp index 23d78d761..04648bebc 100644 --- a/src/modules/audio_coding/main/test/RTPFile.cpp +++ b/src/modules/audio_coding/main/test/RTPFile.cpp @@ -9,8 +9,7 @@ */ #include "RTPFile.h" -#include "rw_lock_wrapper.h" -#include "engine_configurations.h" + #include #ifdef WIN32 @@ -20,6 +19,9 @@ #endif #include "audio_coding_module.h" +#include "engine_configurations.h" +#include "gtest/gtest.h" +#include "rw_lock_wrapper.h" void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const WebRtc_UWord8* rtpHeader) { @@ -186,16 +188,16 @@ void RTPFile::ReadHeader() WebRtc_UWord32 start_sec, start_usec, source; WebRtc_UWord16 port, padding; char fileHeader[40]; - fgets(fileHeader, 40, _rtpFile); - fread(&start_sec, 4, 1, _rtpFile); + EXPECT_TRUE(fgets(fileHeader, 40, _rtpFile) != 0); + EXPECT_GT(fread(&start_sec, 4, 1, _rtpFile), 0u); start_sec=ntohl(start_sec); - fread(&start_usec, 4, 1, _rtpFile); + EXPECT_GT(fread(&start_usec, 4, 1, _rtpFile), 0u); start_usec=ntohl(start_usec); - fread(&source, 4, 1, _rtpFile); + EXPECT_GT(fread(&source, 4, 1, _rtpFile), 0u); source=ntohl(source); - fread(&port, 2, 1, _rtpFile); + EXPECT_GT(fread(&port, 2, 1, _rtpFile), 0u); port=ntohs(port); - fread(&padding, 2, 1, _rtpFile); + EXPECT_GT(fread(&padding, 2, 1, _rtpFile), 0u); padding=ntohs(padding); } @@ -237,19 +239,19 @@ WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo, WebRtc_UWord16 lengthBytes; WebRtc_UWord16 plen; WebRtc_UWord8 rtpHeader[12]; - fread(&lengthBytes, 2, 1, _rtpFile); + EXPECT_GT(fread(&lengthBytes, 2, 1, _rtpFile), 0u); if (feof(_rtpFile)) { _rtpEOF = true; return 0; } - fread(&plen, 2, 1, _rtpFile); + EXPECT_GT(fread(&plen, 2, 1, _rtpFile), 0u); if (feof(_rtpFile)) { _rtpEOF = true; return 0; } - fread(offset, 4, 1, _rtpFile); + EXPECT_GT(fread(offset, 4, 1, _rtpFile), 0u); if (feof(_rtpFile)) { _rtpEOF = true; @@ -263,7 +265,7 @@ WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo, throw "Unable to read RTP file"; exit(1); } - fread(rtpHeader, 12, 1, _rtpFile); + EXPECT_GT(fread(rtpHeader, 12, 1, _rtpFile), 0u); if (feof(_rtpFile)) { _rtpEOF = true; @@ -287,7 +289,7 @@ WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo, exit(1); } lengthBytes -= 20; - fread(payloadData, 1, lengthBytes, _rtpFile); + EXPECT_GT(fread(payloadData, 1, lengthBytes, _rtpFile), 0u); if (feof(_rtpFile)) { _rtpEOF = true; diff --git a/src/modules/audio_coding/main/test/TwoWayCommunication.cpp b/src/modules/audio_coding/main/test/TwoWayCommunication.cpp index afa925325..bad71abf5 100644 --- a/src/modules/audio_coding/main/test/TwoWayCommunication.cpp +++ b/src/modules/audio_coding/main/test/TwoWayCommunication.cpp @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "TwoWayCommunication.h" + #include #include #include @@ -16,12 +18,12 @@ #include #endif -#include "TwoWayCommunication.h" -#include "engine_configurations.h" -#include "PCMFile.h" -#include "utility.h" -#include "trace.h" #include "common_types.h" +#include "engine_configurations.h" +#include "gtest/gtest.h" +#include "PCMFile.h" +#include "trace.h" +#include "utility.h" using namespace webrtc; @@ -79,11 +81,11 @@ TwoWayCommunication::ChooseCodec(WebRtc_UWord8* codecID_A, WebRtc_UWord8* codecI } printf("\nChoose a send codec for side A [0]: "); char myStr[15] = ""; - fgets(myStr, 10, stdin); + EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL); *codecID_A = (WebRtc_UWord8)atoi(myStr); printf("\nChoose a send codec for side B [0]: "); - fgets(myStr, 10, stdin); + EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL); *codecID_B = (WebRtc_UWord8)atoi(myStr); AudioCodingModule::Destroy(tmpACM); @@ -97,7 +99,7 @@ TwoWayCommunication::ChooseFile(char* fileName, WebRtc_Word16 maxLen, WebRtc_UWo WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE]; //strcpy(_fileName, "in.pcm"); //printf("\n\nPlease enter the input file: "); - fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin); + EXPECT_TRUE(fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin) != NULL); tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0'; WebRtc_Word16 n = 0; @@ -138,7 +140,7 @@ TwoWayCommunication::ChooseFile(char* fileName, WebRtc_Word16 maxLen, WebRtc_UWo strncpy(fileName, tmpName, len+1); } printf("Enter the sampling frequency (in Hz) of the above file [%u]: ", *frequencyHz); - fgets(tmpName, 6, stdin); + EXPECT_TRUE(fgets(tmpName, 6, stdin) != NULL); WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName); if(tmpFreq > 0) { diff --git a/src/modules/audio_coding/main/test/iSACTest.cpp b/src/modules/audio_coding/main/test/iSACTest.cpp index 5c6daff58..86271c27f 100644 --- a/src/modules/audio_coding/main/test/iSACTest.cpp +++ b/src/modules/audio_coding/main/test/iSACTest.cpp @@ -298,7 +298,7 @@ ISACTest::Perform() testNr++; EncodeDecode(testNr, wbISACConfig, swbISACConfig); - int dummy; + int user_input; if((_testMode == 0) || (_testMode == 1)) { swbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)200; @@ -307,11 +307,11 @@ ISACTest::Perform() else { printf("Enter the max payload-size for side A: "); - scanf("%d", &dummy); - swbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)dummy; + CHECK_ERROR(scanf("%d", &user_input)); + swbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)user_input; printf("Enter the max payload-size for side B: "); - scanf("%d", &dummy); - wbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)dummy; + CHECK_ERROR(scanf("%d", &user_input)); + wbISACConfig.maxPayloadSizeByte = (WebRtc_UWord16)user_input; } testNr++; EncodeDecode(testNr, wbISACConfig, swbISACConfig); @@ -329,11 +329,11 @@ ISACTest::Perform() else { printf("Enter the max rate for side A: "); - scanf("%d", &dummy); - swbISACConfig.maxRateBitPerSec = (WebRtc_UWord32)dummy; + CHECK_ERROR(scanf("%d", &user_input)); + swbISACConfig.maxRateBitPerSec = (WebRtc_UWord32)user_input; printf("Enter the max rate for side B: "); - scanf("%d", &dummy); - wbISACConfig.maxRateBitPerSec = (WebRtc_UWord32)dummy; + CHECK_ERROR(scanf("%d", &user_input)); + wbISACConfig.maxRateBitPerSec = (WebRtc_UWord32)user_input; } testNr++; diff --git a/src/modules/audio_coding/main/test/utility.cpp b/src/modules/audio_coding/main/test/utility.cpp index 58a2cf13f..5f83d96e4 100644 --- a/src/modules/audio_coding/main/test/utility.cpp +++ b/src/modules/audio_coding/main/test/utility.cpp @@ -9,14 +9,14 @@ */ #include "utility.h" + #include #include #include - #include "audio_coding_module.h" #include "common_types.h" - +#include "gtest/gtest.h" #define NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE 13 @@ -128,7 +128,7 @@ ChooseCodec( do { printf("\nChoose a codec [0]: "); - fgets(myStr, 10, stdin); + EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL); codecID = atoi(myStr); if((codecID < 0) || (codecID >= noCodec)) { diff --git a/src/modules/audio_coding/neteq/neteq.gypi b/src/modules/audio_coding/neteq/neteq.gypi index 8911328fc..261c0e5f1 100644 --- a/src/modules/audio_coding/neteq/neteq.gypi +++ b/src/modules/audio_coding/neteq/neteq.gypi @@ -177,6 +177,9 @@ { 'target_name': 'RTPjitter', 'type': 'executable', + 'dependencies': [ + '<(webrtc_root)/../testing/gtest.gyp:gtest', + ], 'sources': [ 'test/RTPjitter.cc', ], @@ -186,6 +189,7 @@ 'type': 'executable', 'dependencies': [ 'NetEqTestTools', + '<(webrtc_root)/../testing/gtest.gyp:gtest', ], 'sources': [ 'test/RTPanalyze.cc', @@ -196,6 +200,7 @@ 'type': 'executable', 'dependencies': [ 'NetEqTestTools', + '<(webrtc_root)/../testing/gtest.gyp:gtest', ], 'sources': [ 'test/RTPchange.cc', @@ -206,6 +211,7 @@ 'type': 'executable', 'dependencies': [ 'NetEqTestTools', + '<(webrtc_root)/../testing/gtest.gyp:gtest', ], 'sources': [ 'test/RTPtimeshift.cc', @@ -216,6 +222,7 @@ 'type': 'executable', 'dependencies': [ 'NetEqTestTools', + '<(webrtc_root)/../testing/gtest.gyp:gtest', ], 'sources': [ 'test/RTPcat.cc', @@ -232,6 +239,7 @@ 'iLBC', 'iSAC', 'CNG', + '<(webrtc_root)/../testing/gtest.gyp:gtest', ], 'direct_dependent_settings': { 'include_dirs': [ diff --git a/src/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc b/src/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc index 30ee4171a..0412f0657 100644 --- a/src/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc +++ b/src/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc @@ -21,6 +21,8 @@ #include +#include "gtest/gtest.h" + #define HDR_SIZE 8 // rtpplay packet header size in bytes @@ -145,7 +147,9 @@ int NETEQTEST_RTPpacket::skipFileHeader(FILE *fp) const int kFirstLineLength = 40; char firstline[kFirstLineLength]; - fgets(firstline, kFirstLineLength, fp); + if (fgets(firstline, kFirstLineLength, fp) == NULL) { + return -1; + } if (strncmp(firstline, "#!rtpplay", 9) == 0) { if (strncmp(firstline, "#!rtpplay1.0", 12) != 0) { return -1; diff --git a/src/modules/audio_coding/neteq/test/RTPanalyze.cc b/src/modules/audio_coding/neteq/test/RTPanalyze.cc index f70ca8b6c..682dfbda6 100644 --- a/src/modules/audio_coding/neteq/test/RTPanalyze.cc +++ b/src/modules/audio_coding/neteq/test/RTPanalyze.cc @@ -19,8 +19,6 @@ /* Misc. definitions */ /*********************/ -#define FIRSTLINELEN 40 - enum {kRedPayloadType = 127}; int main(int argc, char* argv[]) @@ -44,12 +42,8 @@ int main(int argc, char* argv[]) // print file header fprintf(outFile, "SeqNo TimeStamp SendTime Size PT M\n"); - // read file header - char firstline[FIRSTLINELEN]; - fgets(firstline, FIRSTLINELEN, inFile); - fread(firstline, 4+4+4+2+2, 1, inFile); // start_sec + start_usec + source + port + padding - + NETEQTEST_RTPpacket::skipFileHeader(inFile); NETEQTEST_RTPpacket packet; while (packet.readFromFile(inFile) >= 0) diff --git a/src/modules/audio_coding/neteq/test/RTPcat.cc b/src/modules/audio_coding/neteq/test/RTPcat.cc index fe4223e6d..c40cd591c 100644 --- a/src/modules/audio_coding/neteq/test/RTPcat.cc +++ b/src/modules/audio_coding/neteq/test/RTPcat.cc @@ -13,6 +13,7 @@ #include #include "NETEQTEST_RTPpacket.h" +#include "gtest/gtest.h" /*********************/ /* Misc. definitions */ @@ -42,16 +43,18 @@ int main(int argc, char* argv[]) // read file header and write directly to output file char firstline[FIRSTLINELEN]; - fgets(firstline, FIRSTLINELEN, inFile); - fputs(firstline, outFile); - fread(firstline, 4 + 4 + 4 + 2 + 2, 1, inFile); // start_sec + start_usec + source + port + padding - fwrite(firstline, 4 + 4 + 4 + 2 + 2, 1, outFile); + const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2; + EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, inFile) != NULL); + EXPECT_GT(fputs(firstline, outFile), 0); + EXPECT_EQ(kRtpDumpHeaderSize, fread(firstline, 1, kRtpDumpHeaderSize, + inFile)); + EXPECT_EQ(kRtpDumpHeaderSize, fwrite(firstline, 1, kRtpDumpHeaderSize, + outFile)); // close input file and re-open it later (easier to write the loop below) fclose(inFile); for (int i = 1; i < argc - 1; i++) { - inFile = fopen(argv[i], "rb"); if (!inFile) { printf("Cannot open input file %s\n", argv[i]); @@ -60,28 +63,18 @@ int main(int argc, char* argv[]) printf("Input RTP file: %s\n", argv[i]); // skip file header - fgets(firstline, FIRSTLINELEN, inFile); - fread(firstline, 4 + 4 + 4 + 2 + 2, 1, inFile); // start_sec + start_usec + source + port + padding - + NETEQTEST_RTPpacket::skipFileHeader(inFile); NETEQTEST_RTPpacket packet; int packLen = packet.readFromFile(inFile); if (packLen < 0) { exit(1); } - while (packLen >= 0) { - packet.writeToFile(outFile); - packLen = packet.readFromFile(inFile); - } - fclose(inFile); - } - fclose(outFile); - return 0; } diff --git a/src/modules/audio_coding/neteq/test/RTPchange.cc b/src/modules/audio_coding/neteq/test/RTPchange.cc index 7dc80e692..9c9a6bd23 100644 --- a/src/modules/audio_coding/neteq/test/RTPchange.cc +++ b/src/modules/audio_coding/neteq/test/RTPchange.cc @@ -13,7 +13,7 @@ #include #include "NETEQTEST_RTPpacket.h" - +#include "gtest/gtest.h" /*********************/ /* Misc. definitions */ @@ -38,26 +38,29 @@ int main(int argc, char* argv[]) printf("Input RTP file: %s\n",argv[1]); FILE *statFile=fopen(argv[2],"rt"); - if (!statFile) + if (!statFile) { printf("Cannot open timing file %s\n", argv[2]); return(-1); } printf("Timing file: %s\n",argv[2]); - FILE *outFile=fopen(argv[3],"wb"); - if (!outFile) + FILE *outFile=fopen(argv[3],"wb"); + if (!outFile) { printf("Cannot open output file %s\n", argv[3]); return(-1); } - printf("Output RTP file: %s\n\n",argv[3]); + printf("Output RTP file: %s\n\n",argv[3]); // read all statistics and insert into map // read first line char tempStr[100]; - fgets(tempStr, 100, statFile); - + if (fgets(tempStr, 100, statFile) == NULL) + { + printf("Failed to read timing file %s\n", argv[2]); + return (-1); + } // define map std::map, WebRtc_UWord32> packetStats; @@ -76,11 +79,25 @@ int main(int argc, char* argv[]) fclose(statFile); // read file header and write directly to output file - char firstline[FIRSTLINELEN]; - fgets(firstline, FIRSTLINELEN, inFile); - fputs(firstline, outFile); - fread(firstline, 4+4+4+2+2, 1, inFile); // start_sec + start_usec + source + port + padding - fwrite(firstline, 4+4+4+2+2, 1, outFile); + char firstline[FIRSTLINELEN]; + if (fgets(firstline, FIRSTLINELEN, inFile) == NULL) + { + printf("Failed to read first line of input file %s\n", argv[1]); + return (-1); + } + fputs(firstline, outFile); + // start_sec + start_usec + source + port + padding + const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2; + if (fread(firstline, 1, kRtpDumpHeaderSize, inFile) != kRtpDumpHeaderSize) + { + printf("Failed to read RTP dump header from input file %s\n", argv[1]); + return (-1); + } + if (fwrite(firstline, 1, kRtpDumpHeaderSize, outFile) != kRtpDumpHeaderSize) + { + printf("Failed to write RTP dump header to output file %s\n", argv[3]); + return (-1); + } std::vector packetVec; diff --git a/src/modules/audio_coding/neteq/test/RTPencode.cc b/src/modules/audio_coding/neteq/test/RTPencode.cc index e48d5b78c..461309c79 100644 --- a/src/modules/audio_coding/neteq/test/RTPencode.cc +++ b/src/modules/audio_coding/neteq/test/RTPencode.cc @@ -277,7 +277,7 @@ int main(int argc, char* argv[]) bool dtmfSent = false; #endif bool usingStereo = false; - int stereoMode; + int stereoMode = 0; int numChannels = 1; /* check number of parameters */ @@ -1609,7 +1609,7 @@ int NetEQTest_free_coders(enum WebRtcNetEQDecoder coder, int numChannels) { int NetEQTest_encode(int coder, WebRtc_Word16 *indata, int frameLen, unsigned char * encoded,int sampleRate , int * vad, int useVAD, int bitrate, int numChannels){ - short cdlen; + short cdlen = 0; WebRtc_Word16 *tempdata; static int first_cng=1; WebRtc_Word16 tempLen; diff --git a/src/modules/audio_coding/neteq/test/RTPjitter.cc b/src/modules/audio_coding/neteq/test/RTPjitter.cc index e29272bf0..4b21e0563 100644 --- a/src/modules/audio_coding/neteq/test/RTPjitter.cc +++ b/src/modules/audio_coding/neteq/test/RTPjitter.cc @@ -22,6 +22,8 @@ #include #include +#include "gtest/gtest.h" + /*********************/ /* Misc. definitions */ /*********************/ @@ -68,7 +70,8 @@ int main(int argc, char* argv[]) unsigned int dat_len, rtp_len, Npack, k; arr_time *time_vec; char firstline[FIRSTLINELEN]; - unsigned char *rtp_vec, **packet_ptr, *temp_packet; + unsigned char *rtp_vec = NULL, **packet_ptr, *temp_packet; + const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2; WebRtc_UWord16 len; WebRtc_UWord32 *offset; @@ -126,10 +129,12 @@ int main(int argc, char* argv[]) } // read file header and write directly to output file - fgets(firstline, FIRSTLINELEN, in_file); - fputs(firstline, out_file); - fread(firstline, 4+4+4+2+2, 1, in_file); // start_sec + start_usec + source + port + padding - fwrite(firstline, 4+4+4+2+2, 1, out_file); + EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, in_file) != NULL); + EXPECT_GT(fputs(firstline, out_file), 0); + EXPECT_EQ(kRtpDumpHeaderSize, fread(firstline, 1, kRtpDumpHeaderSize, + in_file)); + EXPECT_EQ(kRtpDumpHeaderSize, fwrite(firstline, 1, kRtpDumpHeaderSize, + out_file)); // read all RTP packets into vector rtp_len=0; diff --git a/src/modules/audio_coding/neteq/test/RTPtimeshift.cc b/src/modules/audio_coding/neteq/test/RTPtimeshift.cc index 97b6da0f8..dc7ff9fb7 100644 --- a/src/modules/audio_coding/neteq/test/RTPtimeshift.cc +++ b/src/modules/audio_coding/neteq/test/RTPtimeshift.cc @@ -13,7 +13,7 @@ #include #include "NETEQTEST_RTPpacket.h" - +#include "gtest/gtest.h" /*********************/ /* Misc. definitions */ @@ -47,12 +47,14 @@ int main(int argc, char* argv[]) printf("Output RTP file: %s\n\n",argv[2]); // read file header and write directly to output file + const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2; char firstline[FIRSTLINELEN]; - fgets(firstline, FIRSTLINELEN, inFile); - fputs(firstline, outFile); - fread(firstline, 4+4+4+2+2, 1, inFile); // start_sec + start_usec + source + port + padding - fwrite(firstline, 4+4+4+2+2, 1, outFile); - + EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, inFile) != NULL); + EXPECT_GT(fputs(firstline, outFile), 0); + EXPECT_EQ(kRtpDumpHeaderSize, + fread(firstline, 1, kRtpDumpHeaderSize, inFile)); + EXPECT_EQ(kRtpDumpHeaderSize, + fwrite(firstline, 1, kRtpDumpHeaderSize, outFile)); NETEQTEST_RTPpacket packet; int packLen = packet.readFromFile(inFile); if (packLen < 0) diff --git a/src/modules/audio_device/main/test/func_test_manager.cc b/src/modules/audio_device/main/test/func_test_manager.cc index f27f77fb6..4566da2ba 100644 --- a/src/modules/audio_device/main/test/func_test_manager.cc +++ b/src/modules/audio_device/main/test/func_test_manager.cc @@ -776,7 +776,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection() { TEST_LOG("Would you like to try kWindowsCoreAudio instead " "[requires Win Vista or Win 7] (Y/N)?\n: "); - scanf(" %c", &ch); + TEST(scanf(" %c", &ch) > 0); ch = toupper(ch); if (ch == 'Y') { @@ -785,7 +785,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection() } else if (audioLayer == AudioDeviceModule::kWindowsCoreAudio) { TEST_LOG("Would you like to try kWindowsWaveAudio instead (Y/N)?\n: "); - scanf(" %c", &ch); + TEST(scanf(" %c", &ch) > 0); ch = toupper(ch); if (ch == 'Y') { @@ -1695,7 +1695,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneVolume() RecordedMicrophoneVolumeFile); char ch; bool fileRecording(false); - scanf(" %c", &ch); + TEST(scanf(" %c", &ch) > 0); ch = toupper(ch); if (ch == 'Y') { @@ -1834,7 +1834,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneMute() RecordedMicrophoneMuteFile); char ch; bool fileRecording(false); - scanf(" %c", &ch); + TEST(scanf(" %c", &ch) > 0); ch = toupper(ch); if (ch == 'Y') { @@ -1970,7 +1970,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneBoost() RecordedMicrophoneBoostFile); char ch; bool fileRecording(false); - scanf(" %c", &ch); + TEST(scanf(" %c", &ch) > 0); ch = toupper(ch); if (ch == 'Y') { @@ -2107,7 +2107,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneAGC() RecordedMicrophoneAGCFile); char ch; bool fileRecording(false); - scanf(" %c", &ch); + TEST(scanf(" %c", &ch) > 0); ch = toupper(ch); if (ch == 'Y') { @@ -2567,11 +2567,8 @@ WebRtc_Word32 FuncTestManager::SelectRecordingDevice() TEST_LOG(" (%d) Device %d (%s)\n", i, i, name); } TEST_LOG("\n: "); - int sel(0); - - scanf("%u", &sel); - + TEST(scanf("%u", &sel) > 0); if (sel < (nDevices)) { TEST((ret = _audioDevice->SetRecordingDevice(sel)) == 0); @@ -2634,13 +2631,9 @@ WebRtc_Word32 FuncTestManager::SelectPlayoutDevice() TEST_LOG(" (%d) Device %d (%s)\n", i, i, name); } TEST_LOG("\n: "); - int sel(0); - - scanf("%u", &sel); - + TEST(scanf("%u", &sel) > 0); WebRtc_Word32 ret(0); - if (sel < (nDevices)) { TEST((ret = _audioDevice->SetPlayoutDevice(sel)) == 0); diff --git a/src/modules/video_coding/codecs/test_framework/normal_async_test.cc b/src/modules/video_coding/codecs/test_framework/normal_async_test.cc index 854724965..4f7be7f22 100644 --- a/src/modules/video_coding/codecs/test_framework/normal_async_test.cc +++ b/src/modules/video_coding/codecs/test_framework/normal_async_test.cc @@ -9,12 +9,15 @@ */ #include "normal_async_test.h" -#include "typedefs.h" + #include #include #include #include + +#include "gtest/gtest.h" #include "tick_util.h" +#include "typedefs.h" using namespace webrtc; @@ -391,7 +394,7 @@ bool NormalAsyncTest::Encode() { _lengthEncFrame = 0; - fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile); + EXPECT_GT(fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile), 0u); _inputVideoBuffer.CopyBuffer(_lengthSourceFrame, _sourceBuffer); _inputVideoBuffer.SetTimeStamp((unsigned int) (_encFrameCnt * 9e4 / _inst.maxFramerate)); @@ -448,6 +451,7 @@ NormalAsyncTest::Encode() webrtc::CodecSpecificInfo* codecSpecificInfo = CreateEncoderSpecificInfo(); int ret = _encoder->Encode(rawImage, codecSpecificInfo, &frameType); + EXPECT_EQ(ret, WEBRTC_VIDEO_CODEC_OK); if (codecSpecificInfo != NULL) { delete codecSpecificInfo; diff --git a/src/modules/video_coding/codecs/test_framework/normal_test.cc b/src/modules/video_coding/codecs/test_framework/normal_test.cc index d3a4b2c65..2edad9790 100644 --- a/src/modules/video_coding/codecs/test_framework/normal_test.cc +++ b/src/modules/video_coding/codecs/test_framework/normal_test.cc @@ -9,10 +9,13 @@ */ #include "normal_test.h" + #include #include #include +#include "gtest/gtest.h" + NormalTest::NormalTest() : Test("Normal Test 1", "A test of normal execution of the codec"), @@ -169,7 +172,7 @@ bool NormalTest::Encode() { _lengthEncFrame = 0; - fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile); + EXPECT_GT(fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile), 0u); if (feof(_sourceFile) != 0) { return true; diff --git a/src/modules/video_coding/codecs/test_framework/performance_test.cc b/src/modules/video_coding/codecs/test_framework/performance_test.cc index 7603c3514..a3666efbd 100644 --- a/src/modules/video_coding/codecs/test_framework/performance_test.cc +++ b/src/modules/video_coding/codecs/test_framework/performance_test.cc @@ -9,9 +9,12 @@ */ #include "performance_test.h" -#include "tick_util.h" + #include +#include "gtest/gtest.h" +#include "tick_util.h" + using namespace webrtc; #define NUM_FRAMES 300 @@ -129,7 +132,8 @@ PerformanceTest::Perform() // Read a new frame from file WriteLockScoped imageLock(*_rawImageLock); _lengthEncFrame = 0; - fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile); + EXPECT_GT(fread(_sourceBuffer, 1, _lengthSourceFrame, _sourceFile), + 0u); if (feof(_sourceFile) != 0) { rewind(_sourceFile); @@ -269,6 +273,7 @@ bool PerformanceTest::Encode() } webrtc::CodecSpecificInfo* codecSpecificInfo = CreateEncoderSpecificInfo(); int ret = _encoder->Encode(rawImage, codecSpecificInfo, &frameType); + EXPECT_EQ(ret, WEBRTC_VIDEO_CODEC_OK); if (codecSpecificInfo != NULL) { delete codecSpecificInfo; diff --git a/src/modules/video_coding/codecs/test_framework/test_framework.gypi b/src/modules/video_coding/codecs/test_framework/test_framework.gypi index 9194f9e23..2e6f10e2b 100644 --- a/src/modules/video_coding/codecs/test_framework/test_framework.gypi +++ b/src/modules/video_coding/codecs/test_framework/test_framework.gypi @@ -16,6 +16,7 @@ 'type': '<(library)', 'dependencies': [ + '<(webrtc_root)/../testing/gtest.gyp:gtest', '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', '<(webrtc_root)/common_video/common_video.gyp:webrtc_vplib', ], diff --git a/src/modules/video_coding/main/source/video_coding_test.gypi b/src/modules/video_coding/main/source/video_coding_test.gypi index 57c34d0b9..e0eab3297 100644 --- a/src/modules/video_coding/main/source/video_coding_test.gypi +++ b/src/modules/video_coding/main/source/video_coding_test.gypi @@ -11,6 +11,7 @@ 'target_name': 'video_coding_test', 'type': 'executable', 'dependencies': [ + '<(webrtc_root)/../testing/gtest.gyp:gtest', '<(webrtc_root)/../test/test.gyp:test_support', 'webrtc_video_coding', 'rtp_rtcp', diff --git a/src/modules/video_coding/main/test/codec_database_test.cc b/src/modules/video_coding/main/test/codec_database_test.cc index 56b022a38..44a9627d7 100644 --- a/src/modules/video_coding/main/test/codec_database_test.cc +++ b/src/modules/video_coding/main/test/codec_database_test.cc @@ -121,7 +121,7 @@ CodecDataBaseTest::Perform(CmdArgs& args) VideoFrame sourceFrame; sourceFrame.VerifyAndAllocate(_lengthSourceFrame); WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame]; - fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); + TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.SetHeight(_height); sourceFrame.SetWidth(_width); @@ -324,7 +324,7 @@ CodecDataBaseTest::Perform(CmdArgs& args) for (j=0; j < int(300/VideoCodingModule::NumberOfCodecs()); j++)// assuming 300 frames, NumberOfCodecs <= 10 { frameCnt++; - fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); + TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0); // building source frame sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.SetHeight(_height); diff --git a/src/modules/video_coding/main/test/generic_codec_test.cc b/src/modules/video_coding/main/test/generic_codec_test.cc index adb9e2512..cc2af5edf 100644 --- a/src/modules/video_coding/main/test/generic_codec_test.cc +++ b/src/modules/video_coding/main/test/generic_codec_test.cc @@ -143,7 +143,7 @@ GenericCodecTest::Perform(CmdArgs& args) _vcm->RegisterReceiveCodec(&receiveCodec, 1); } WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame]; - fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); + TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0); // building source frame sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.SetHeight(_height); @@ -191,7 +191,7 @@ GenericCodecTest::Perform(CmdArgs& args) //encoding 1 second of video for (i = 0; i < _frameRate; i++) { - fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); + TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.SetHeight(_height); sourceFrame.SetWidth(_width); @@ -265,7 +265,7 @@ GenericCodecTest::Perform(CmdArgs& args) sourceFrame.VerifyAndAllocate(_lengthSourceFrame); const float bitRate[] = {100, 400, 600, 1000, 2000, 3000}; const float nBitrates = sizeof(bitRate)/sizeof(*bitRate); - float _bitRate; + float _bitRate = 0; int _frameCnt = 0; WebRtc_Word64 startTime, currentTime, oneSecTime; float totalBytesOneSec;//, totalBytesTenSec; @@ -377,7 +377,7 @@ GenericCodecTest::Perform(CmdArgs& args) encodeComplete = false; while (encodeComplete == false) { - fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); + TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0); _frameCnt++; sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.SetHeight(_height); @@ -467,7 +467,7 @@ GenericCodecTest::Perform(CmdArgs& args) rewind(_sourceFile); while (!feof(_sourceFile)) { - fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); + TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0); sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.SetHeight(_height); sourceFrame.SetWidth(_width); diff --git a/src/modules/video_coding/main/test/jitter_buffer_test.cc b/src/modules/video_coding/main/test/jitter_buffer_test.cc index a842e18ff..d651c4b0a 100644 --- a/src/modules/video_coding/main/test/jitter_buffer_test.cc +++ b/src/modules/video_coding/main/test/jitter_buffer_test.cc @@ -102,7 +102,7 @@ int JitterBufferTest(CmdArgs& args) packet.seqNum = seqNum; packet.payloadType = 126; seqNum++; - fb->InsertPacket(packet, VCMTickTime::MillisecondTimestamp()); + fb->InsertPacket(packet, VCMTickTime::MillisecondTimestamp(), false, 0); TEST(frameList.Insert(fb) == 0); } VCMFrameListItem* item = NULL; @@ -1907,8 +1907,8 @@ int JitterBufferTest(CmdArgs& args) seqNum = 65485; timeStampStart = timeStamp + 33*90; WebRtc_UWord32 timeStampFirstKey = 0; - VCMEncodedFrame* ptrLastDeltaFrame; - VCMEncodedFrame* ptrFirstKeyFrame; + VCMEncodedFrame* ptrLastDeltaFrame = NULL; + VCMEncodedFrame* ptrFirstKeyFrame = NULL; // insert MAX_NUMBER_OF_FRAMES frames do { diff --git a/src/modules/video_coding/main/test/media_opt_test.cc b/src/modules/video_coding/main/test/media_opt_test.cc index 36832dc61..1ece9f6ff 100644 --- a/src/modules/video_coding/main/test/media_opt_test.cc +++ b/src/modules/video_coding/main/test/media_opt_test.cc @@ -128,7 +128,7 @@ MediaOptTest::Setup(int testType, CmdArgs& args) _fpinp = fopen("dat_inp","rb"); _fpout = fopen("test_runs/dat_out","ab"); _fpout2 = fopen("test_runs/dat_out2","ab"); - fscanf(_fpinp,"%f %f %d \n",&rateTest,&lossTest,&numRuns); + TEST(fscanf(_fpinp,"%f %f %d \n",&rateTest,&lossTest,&numRuns) > 0); _bitRate = rateTest; _lossRate = lossTest; _testNum = 0; @@ -311,7 +311,7 @@ MediaOptTest::Perform() while (feof(_sourceFile)== 0) { - fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); + TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0); _frameCnt++; sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); diff --git a/src/modules/video_coding/main/test/mt_rx_tx_test.cc b/src/modules/video_coding/main/test/mt_rx_tx_test.cc index 2e7c83a72..2989af265 100644 --- a/src/modules/video_coding/main/test/mt_rx_tx_test.cc +++ b/src/modules/video_coding/main/test/mt_rx_tx_test.cc @@ -55,7 +55,7 @@ MainSenderThread(void* obj) } if (feof(state->_sourceFile) == 0) { - fread(tmpBuffer, 1, lengthSourceFrame,state->_sourceFile); + TEST(fread(tmpBuffer, 1, lengthSourceFrame,state->_sourceFile) > 0); state->_frameCnt++; sourceFrame.CopyFrame(lengthSourceFrame, tmpBuffer); sourceFrame.SetHeight(height); diff --git a/src/modules/video_coding/main/test/normal_test.cc b/src/modules/video_coding/main/test/normal_test.cc index 76d61e913..e1ebd7ab5 100644 --- a/src/modules/video_coding/main/test/normal_test.cc +++ b/src/modules/video_coding/main/test/normal_test.cc @@ -279,7 +279,7 @@ NormalTest::Perform(CmdArgs& args) #if !(defined(TICK_TIME_DEBUG) || defined(EVENT_DEBUG)) WebRtc_Word64 processStartTime = VCMTickTime::MillisecondTimestamp(); #endif - fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); + TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0); _frameCnt++; sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.SetHeight(_height); diff --git a/src/modules/video_coding/main/test/quality_modes_test.cc b/src/modules/video_coding/main/test/quality_modes_test.cc index f39c786bf..fd5d7466e 100644 --- a/src/modules/video_coding/main/test/quality_modes_test.cc +++ b/src/modules/video_coding/main/test/quality_modes_test.cc @@ -236,7 +236,7 @@ QualityModesTest::Perform() while (feof(_sourceFile)== 0) { - fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile); + TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0); _frameCnt++; sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer); sourceFrame.SetHeight(_nativeHeight); diff --git a/src/modules/video_coding/main/test/rtp_player.cc b/src/modules/video_coding/main/test/rtp_player.cc index 797e272d6..d3dadde77 100644 --- a/src/modules/video_coding/main/test/rtp_player.cc +++ b/src/modules/video_coding/main/test/rtp_player.cc @@ -9,9 +9,6 @@ */ #include "rtp_player.h" -#include "../source/internal_defines.h" -#include "rtp_rtcp.h" -#include "tick_time.h" #include #ifdef WIN32 @@ -21,6 +18,11 @@ #include #endif +#include "../source/internal_defines.h" +#include "gtest/gtest.h" +#include "rtp_rtcp.h" +#include "tick_time.h" + using namespace webrtc; RawRtpPacket::RawRtpPacket(WebRtc_UWord8* data, WebRtc_UWord16 len) @@ -231,7 +233,7 @@ WebRtc_Word32 RTPPlayer::ReadHeader() { return -1; } - fgets(firstline, FIRSTLINELEN, _rtpFile); + EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, _rtpFile) != NULL); if(strncmp(firstline,"#!rtpplay",9) == 0) { if(strncmp(firstline,"#!rtpplay1.0",12) != 0){ printf("ERROR: wrong rtpplay version, must be 1.0\n"); @@ -255,15 +257,15 @@ WebRtc_Word32 RTPPlayer::ReadHeader() WebRtc_UWord16 port; WebRtc_UWord16 padding; - fread(&start_sec, 4, 1, _rtpFile); + EXPECT_GT(fread(&start_sec, 4, 1, _rtpFile), 0u); start_sec=ntohl(start_sec); - fread(&start_usec, 4, 1, _rtpFile); + EXPECT_GT(fread(&start_usec, 4, 1, _rtpFile), 0u); start_usec=ntohl(start_usec); - fread(&source, 4, 1, _rtpFile); + EXPECT_GT(fread(&source, 4, 1, _rtpFile), 0u); source=ntohl(source); - fread(&port, 2, 1, _rtpFile); + EXPECT_GT(fread(&port, 2, 1, _rtpFile), 0u); port=ntohs(port); - fread(&padding, 2, 1, _rtpFile); + EXPECT_GT(fread(&padding, 2, 1, _rtpFile), 0u); padding=ntohs(padding); return 0; } diff --git a/src/modules/video_processing/main/test/unit_test/unit_test.cc b/src/modules/video_processing/main/test/unit_test/unit_test.cc index ba6c7c621..dc2e7aa79 100644 --- a/src/modules/video_processing/main/test/unit_test/unit_test.cc +++ b/src/modules/video_processing/main/test/unit_test/unit_test.cc @@ -298,7 +298,7 @@ TEST_F(VideoProcessingModuleTest, Resampler) // Reading test frame VideoFrame sourceFrame; ASSERT_EQ(0, sourceFrame.VerifyAndAllocate(lengthSourceFrame)); - fread(sourceFrame.Buffer(), 1, lengthSourceFrame, _sourceFile); + EXPECT_GT(fread(sourceFrame.Buffer(), 1, lengthSourceFrame, _sourceFile), 0u); ASSERT_EQ(0, sourceFrame.SetLength(lengthSourceFrame)); sourceFrame.SetHeight(height); sourceFrame.SetWidth(width); diff --git a/webrtc.gyp b/webrtc.gyp index 5d5111723..d7c307ca9 100644 --- a/webrtc.gyp +++ b/webrtc.gyp @@ -17,8 +17,7 @@ 'dependencies': [ 'src/common_audio/common_audio.gyp:*', 'src/common_video/common_video.gyp:*', - # TODO(andrew): enable when Linux-Release errors are fixed. - #'src/modules/modules.gyp:*', + 'src/modules/modules.gyp:*', 'src/system_wrappers/source/system_wrappers.gyp:*', 'src/video_engine/video_engine.gyp:*', 'src/voice_engine/voice_engine.gyp:*',