Converted to gtest, writing output files properly and no longer uses exceptions.
This test now runs and fails as a gtest should (previously it always exited with 0 even if the tests failed). The audio_coding_module_test target no longer uses exceptions in the generated project. Output files are written to our global output folder, using testsupport/fileutils.h. BUG= TEST=audio_coding_module_test on all platforms, in Debug+Release Review URL: http://webrtc-codereview.appspot.com/334004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1266 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -100,6 +100,7 @@
|
|||||||
'type': 'executable',
|
'type': 'executable',
|
||||||
'dependencies': [
|
'dependencies': [
|
||||||
'audio_coding_module',
|
'audio_coding_module',
|
||||||
|
'<(webrtc_root)/../test/test.gyp:test_support_main',
|
||||||
'<(webrtc_root)/../testing/gtest.gyp:gtest',
|
'<(webrtc_root)/../testing/gtest.gyp:gtest',
|
||||||
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
|
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
|
||||||
],
|
],
|
||||||
@@ -121,18 +122,6 @@
|
|||||||
'../test/TwoWayCommunication.cpp',
|
'../test/TwoWayCommunication.cpp',
|
||||||
'../test/utility.cpp',
|
'../test/utility.cpp',
|
||||||
],
|
],
|
||||||
'conditions': [
|
|
||||||
['OS=="linux" or OS=="mac"', {
|
|
||||||
'cflags': [
|
|
||||||
'-fexceptions', # enable exceptions
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
['OS=="mac"', {
|
|
||||||
'xcode_settings': {
|
|
||||||
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', # -fexceptions
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'target_name': 'audio_coding_unittests',
|
'target_name': 'audio_coding_unittests',
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "thread_wrapper.h"
|
#include "thread_wrapper.h"
|
||||||
#include "tick_util.h"
|
#include "tick_util.h"
|
||||||
|
#include "testsupport/fileutils.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
@@ -32,7 +33,16 @@ namespace webrtc {
|
|||||||
#define NUMBER_OF_SENDER_TESTS 6
|
#define NUMBER_OF_SENDER_TESTS 6
|
||||||
|
|
||||||
#define MAX_FILE_NAME_LENGTH_BYTE 500
|
#define MAX_FILE_NAME_LENGTH_BYTE 500
|
||||||
#define CHECK_THREAD_NULLITY(myThread, S) if(myThread != NULL){unsigned int i; (myThread)->Start(i);}else{throw S; exit(1);}
|
#define CHECK_THREAD_NULLITY(myThread, S) \
|
||||||
|
if(myThread != NULL) \
|
||||||
|
{ \
|
||||||
|
unsigned int i; \
|
||||||
|
(myThread)->Start(i); \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
ADD_FAILURE() << S; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -261,7 +271,8 @@ APITest::SetUp()
|
|||||||
_inFileA.Open(fileName, frequencyHz, "rb", true);
|
_inFileA.Open(fileName, frequencyHz, "rb", true);
|
||||||
|
|
||||||
//--- Output A
|
//--- Output A
|
||||||
strcpy(fileName, "./src/modules/audio_coding/main/test/outA.pcm");
|
std::string outputFileA = webrtc::test::OutputPath() + "outA.pcm";
|
||||||
|
strcpy(fileName, outputFileA.c_str());
|
||||||
printf("Enter output file at side A [%s]: ", fileName);
|
printf("Enter output file at side A [%s]: ", fileName);
|
||||||
PCMFile::ChooseFile(fileName, 499, &frequencyHz);
|
PCMFile::ChooseFile(fileName, 499, &frequencyHz);
|
||||||
_outFileA.Open(fileName, frequencyHz, "wb");
|
_outFileA.Open(fileName, frequencyHz, "wb");
|
||||||
@@ -273,7 +284,8 @@ APITest::SetUp()
|
|||||||
_inFileB.Open(fileName, frequencyHz, "rb", true);
|
_inFileB.Open(fileName, frequencyHz, "rb", true);
|
||||||
|
|
||||||
//--- Output B
|
//--- Output B
|
||||||
strcpy(fileName, "./src/modules/audio_coding/main/test/outB.pcm");
|
std::string outputFileB = webrtc::test::OutputPath() + "outB.pcm";
|
||||||
|
strcpy(fileName, outputFileB.c_str());
|
||||||
printf("Enter output file at side B [%s]: ", fileName);
|
printf("Enter output file at side B [%s]: ", fileName);
|
||||||
PCMFile::ChooseFile(fileName, 499, &frequencyHz);
|
PCMFile::ChooseFile(fileName, 499, &frequencyHz);
|
||||||
_outFileB.Open(fileName, frequencyHz, "wb");
|
_outFileB.Open(fileName, frequencyHz, "wb");
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
#include "testsupport/fileutils.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@@ -158,15 +159,14 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
|
|||||||
if (testMode == 1) {
|
if (testMode == 1) {
|
||||||
playSampFreq=recvCodec.plfreq;
|
playSampFreq=recvCodec.plfreq;
|
||||||
//output file for current run
|
//output file for current run
|
||||||
sprintf(filename,"./src/modules/audio_coding/main/test/out%dFile.pcm",
|
sprintf(filename,"%s/out%dFile.pcm", webrtc::test::OutputPath().c_str(),
|
||||||
codeId);
|
codeId);
|
||||||
_pcmFile.Open(filename, recvCodec.plfreq, "wb+");
|
_pcmFile.Open(filename, recvCodec.plfreq, "wb+");
|
||||||
} else if (testMode == 0) {
|
} else if (testMode == 0) {
|
||||||
playSampFreq=32000;
|
playSampFreq=32000;
|
||||||
//output file for current run
|
//output file for current run
|
||||||
sprintf(filename,
|
sprintf(filename, "%s/encodeDecode_out%d.pcm",
|
||||||
"./src/modules/audio_coding/main/test/encodeDecode_out%d.pcm",
|
webrtc::test::OutputPath().c_str(), codeId);
|
||||||
codeId);
|
|
||||||
_pcmFile.Open(filename, 32000/*recvCodec.plfreq*/, "wb+");
|
_pcmFile.Open(filename, 32000/*recvCodec.plfreq*/, "wb+");
|
||||||
} else {
|
} else {
|
||||||
printf("\nValid output frequencies:\n");
|
printf("\nValid output frequencies:\n");
|
||||||
@@ -174,8 +174,8 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
|
|||||||
printf("which means output freq equal to received signal freq");
|
printf("which means output freq equal to received signal freq");
|
||||||
printf("\n\nChoose output sampling frequency: ");
|
printf("\n\nChoose output sampling frequency: ");
|
||||||
ASSERT_GT(scanf("%d", &playSampFreq), 0);
|
ASSERT_GT(scanf("%d", &playSampFreq), 0);
|
||||||
char fileName[] = "./src/modules/audio_coding/main/test/outFile.pcm";
|
sprintf(filename, "%s/outFile.pcm", webrtc::test::OutputPath().c_str());
|
||||||
_pcmFile.Open(fileName, 32000, "wb+");
|
_pcmFile.Open(filename, 32000, "wb+");
|
||||||
}
|
}
|
||||||
|
|
||||||
_realPayloadSizeBytes = 0;
|
_realPayloadSizeBytes = 0;
|
||||||
@@ -361,8 +361,8 @@ void EncodeDecodeTest::Perform() {
|
|||||||
|
|
||||||
AudioCodingModule *acm = AudioCodingModule::Create(10);
|
AudioCodingModule *acm = AudioCodingModule::Create(10);
|
||||||
RTPFile rtpFile;
|
RTPFile rtpFile;
|
||||||
char fileName[] = "outFile.rtp";
|
std::string fileName = webrtc::test::OutputPath() + "outFile.rtp";
|
||||||
rtpFile.Open(fileName, "rb");
|
rtpFile.Open(fileName.c_str(), "rb");
|
||||||
|
|
||||||
_receiver.codeId = codeId;
|
_receiver.codeId = codeId;
|
||||||
|
|
||||||
@@ -389,8 +389,8 @@ void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
|
|||||||
int testMode) {
|
int testMode) {
|
||||||
AudioCodingModule *acm = AudioCodingModule::Create(0);
|
AudioCodingModule *acm = AudioCodingModule::Create(0);
|
||||||
RTPFile rtpFile;
|
RTPFile rtpFile;
|
||||||
char fileName[] = "outFile.rtp";
|
std::string fileName = webrtc::test::OutputPath() + "outFile.rtp";
|
||||||
rtpFile.Open(fileName, "wb+");
|
rtpFile.Open(fileName.c_str(), "wb+");
|
||||||
rtpFile.WriteHeader();
|
rtpFile.WriteHeader();
|
||||||
|
|
||||||
//for auto_test and logging
|
//for auto_test and logging
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ PCMFile::ChooseFile(
|
|||||||
|
|
||||||
void
|
void
|
||||||
PCMFile::Open(
|
PCMFile::Open(
|
||||||
char* filename,
|
const char* filename,
|
||||||
WebRtc_UWord16 frequency,
|
WebRtc_UWord16 frequency,
|
||||||
const char* mode,
|
const char* mode,
|
||||||
bool autoRewind)
|
bool autoRewind)
|
||||||
@@ -168,8 +168,7 @@ PCMFile::Open(
|
|||||||
if ((_pcmFile = fopen(filename, mode)) == NULL)
|
if ((_pcmFile = fopen(filename, mode)) == NULL)
|
||||||
{
|
{
|
||||||
printf("Cannot open file %s.\n", filename);
|
printf("Cannot open file %s.\n", filename);
|
||||||
throw "Unable to read file";
|
ADD_FAILURE() << "Unable to read file";
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
_frequency = frequency;
|
_frequency = frequency;
|
||||||
_nSamples10Ms = (WebRtc_UWord16)(_frequency / 100);
|
_nSamples10Ms = (WebRtc_UWord16)(_frequency / 100);
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public:
|
|||||||
fclose(_pcmFile);
|
fclose(_pcmFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Open(char *filename, WebRtc_UWord16 frequency, const char *mode, bool autoRewind = false);
|
void Open(const char *filename, WebRtc_UWord16 frequency, const char *mode,
|
||||||
|
bool autoRewind = false);
|
||||||
|
|
||||||
WebRtc_Word32 Read10MsData(AudioFrame& audioFrame);
|
WebRtc_Word32 Read10MsData(AudioFrame& audioFrame);
|
||||||
|
|
||||||
@@ -41,7 +42,8 @@ public:
|
|||||||
void Close();
|
void Close();
|
||||||
bool EndOfFile() const { return _endOfFile; }
|
bool EndOfFile() const { return _endOfFile; }
|
||||||
void Rewind();
|
void Rewind();
|
||||||
static WebRtc_Word16 ChooseFile(char* fileName, WebRtc_Word16 maxLen, WebRtc_UWord16* frequencyHz);
|
static WebRtc_Word16 ChooseFile(char* fileName, WebRtc_Word16 maxLen,
|
||||||
|
WebRtc_UWord16* frequencyHz);
|
||||||
static WebRtc_Word16 ChooseFile(char* fileName, WebRtc_Word16 maxLen);
|
static WebRtc_Word16 ChooseFile(char* fileName, WebRtc_Word16 maxLen);
|
||||||
bool Rewinded();
|
bool Rewinded();
|
||||||
void SaveStereo(
|
void SaveStereo(
|
||||||
|
|||||||
@@ -141,12 +141,12 @@ RTPBuffer::EndOfFile() const
|
|||||||
return eof;
|
return eof;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTPFile::Open(char *filename, const char *mode)
|
void RTPFile::Open(const char *filename, const char *mode)
|
||||||
{
|
{
|
||||||
if ((_rtpFile = fopen(filename, mode)) == NULL)
|
if ((_rtpFile = fopen(filename, mode)) == NULL)
|
||||||
{
|
{
|
||||||
printf("Cannot write file %s.\n", filename);
|
printf("Cannot write file %s.\n", filename);
|
||||||
throw "Unable to write file";
|
ADD_FAILURE() << "Unable to write file";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class RTPFile : public RTPStream
|
|||||||
public:
|
public:
|
||||||
~RTPFile(){}
|
~RTPFile(){}
|
||||||
RTPFile() : _rtpFile(NULL),_rtpEOF(false) {}
|
RTPFile() : _rtpFile(NULL),_rtpEOF(false) {}
|
||||||
void Open(char *outFilename, const char *mode);
|
void Open(const char *outFilename, const char *mode);
|
||||||
void Close();
|
void Close();
|
||||||
void WriteHeader();
|
void WriteHeader();
|
||||||
void ReadHeader();
|
void ReadHeader();
|
||||||
|
|||||||
@@ -13,10 +13,11 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "SpatialAudio.h"
|
|
||||||
#include "utility.h"
|
|
||||||
#include "trace.h"
|
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
|
#include "SpatialAudio.h"
|
||||||
|
#include "trace.h"
|
||||||
|
#include "testsupport/fileutils.h"
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@@ -66,21 +67,27 @@ SpatialAudio::Setup()
|
|||||||
|
|
||||||
if(_testMode == 0)
|
if(_testMode == 0)
|
||||||
{
|
{
|
||||||
strncpy(audioFileName, "./src/modules/audio_coding/main/test/out_spatial_autotest.pcm",
|
std::string outputFile = webrtc::test::OutputPath() +
|
||||||
|
"out_spatial_autotest.pcm";
|
||||||
|
strncpy(audioFileName, outputFile.c_str(),
|
||||||
MAX_FILE_NAME_LENGTH_BYTE - 1);
|
MAX_FILE_NAME_LENGTH_BYTE - 1);
|
||||||
}
|
}
|
||||||
else if(_testMode == 1)
|
else if(_testMode == 1)
|
||||||
{
|
{
|
||||||
printf("\n");
|
printf("\n");
|
||||||
strncpy(audioFileName, "./src/modules/audio_coding/main/test/testspatial_out.pcm",
|
std::string outputFile = webrtc::test::OutputPath() +
|
||||||
|
"testspatial_out.pcm";
|
||||||
|
strncpy(audioFileName, outputFile.c_str(),
|
||||||
MAX_FILE_NAME_LENGTH_BYTE - 1);
|
MAX_FILE_NAME_LENGTH_BYTE - 1);
|
||||||
printf("Enter the output file [%s]: ", audioFileName);
|
printf("Enter the output file [%s]: ", audioFileName);
|
||||||
PCMFile::ChooseFile(audioFileName, MAX_FILE_NAME_LENGTH_BYTE, &sampFreqHz);
|
PCMFile::ChooseFile(audioFileName, MAX_FILE_NAME_LENGTH_BYTE, &sampFreqHz);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(audioFileName, "./src/modules/audio_coding/main/test/testspatial_out.pcm",
|
std::string outputFile = webrtc::test::OutputPath() +
|
||||||
MAX_FILE_NAME_LENGTH_BYTE - 1);
|
"testspatial_out.pcm";
|
||||||
|
strncpy(audioFileName, outputFile.c_str(),
|
||||||
|
MAX_FILE_NAME_LENGTH_BYTE - 1);
|
||||||
}
|
}
|
||||||
_outFile.Open(audioFileName, sampFreqHz, "wb", false);
|
_outFile.Open(audioFileName, sampFreqHz, "wb", false);
|
||||||
_outFile.SaveStereo(true);
|
_outFile.SaveStereo(true);
|
||||||
|
|||||||
@@ -10,11 +10,13 @@
|
|||||||
|
|
||||||
#include "TestAllCodecs.h"
|
#include "TestAllCodecs.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "audio_coding_module_typedefs.h"
|
#include "audio_coding_module_typedefs.h"
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
#include "engine_configurations.h"
|
#include "engine_configurations.h"
|
||||||
#include <cassert>
|
#include "testsupport/fileutils.h"
|
||||||
#include <iostream>
|
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
@@ -838,11 +840,9 @@ void TestAllCodecs::Run(TestPack* channel)
|
|||||||
|
|
||||||
void TestAllCodecs::OpenOutFile(WebRtc_Word16 testNumber)
|
void TestAllCodecs::OpenOutFile(WebRtc_Word16 testNumber)
|
||||||
{
|
{
|
||||||
char fileName[500] = "testallcodecs_out_";
|
char fileName[500];
|
||||||
char cntrStr[10];
|
sprintf(fileName, "%s/testallcodecs_out_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(), testNumber);
|
||||||
sprintf(cntrStr, "%02d.pcm", testNumber);
|
|
||||||
strcat(fileName, cntrStr);
|
|
||||||
_outFileB.Open(fileName, 32000, "wb");
|
_outFileB.Open(fileName, 32000, "wb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,14 @@
|
|||||||
|
|
||||||
#include "TestFEC.h"
|
#include "TestFEC.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "audio_coding_module_typedefs.h"
|
#include "audio_coding_module_typedefs.h"
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
#include "engine_configurations.h"
|
#include "engine_configurations.h"
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <iostream>
|
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
#include "testsupport/fileutils.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@@ -599,15 +600,18 @@ void TestFEC::Run()
|
|||||||
|
|
||||||
void TestFEC::OpenOutFile(WebRtc_Word16 testNumber)
|
void TestFEC::OpenOutFile(WebRtc_Word16 testNumber)
|
||||||
{
|
{
|
||||||
char fileName[500] = "./src/modules/audio_coding/main/test/TestFEC_outFile_";
|
char fileName[500];
|
||||||
char cntrStr[10];
|
|
||||||
|
|
||||||
if(_testMode == 0)
|
if(_testMode == 0)
|
||||||
{
|
{
|
||||||
sprintf(fileName, "./src/modules/audio_coding/main/test/TestFEC_autoFile_");
|
sprintf(fileName, "%s/TestFEC_autoFile_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(), testNumber);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(fileName, "%s/TestFEC_outFile_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(), testNumber);
|
||||||
}
|
}
|
||||||
sprintf(cntrStr, "%02d.pcm", testNumber);
|
|
||||||
strcat(fileName, cntrStr);
|
|
||||||
_outFileB.Open(fileName, 32000, "wb");
|
_outFileB.Open(fileName, 32000, "wb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,15 @@
|
|||||||
|
|
||||||
#include "TestStereo.h"
|
#include "TestStereo.h"
|
||||||
|
|
||||||
#include "common_types.h"
|
|
||||||
#include "audio_coding_module_typedefs.h"
|
|
||||||
#include "engine_configurations.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include "utility.h"
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "audio_coding_module_typedefs.h"
|
||||||
|
#include "common_types.h"
|
||||||
|
#include "engine_configurations.h"
|
||||||
|
#include "testsupport/fileutils.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@@ -528,12 +530,9 @@ void TestStereo::Run(TestPackStereo* channel)
|
|||||||
|
|
||||||
void TestStereo::OpenOutFile(WebRtc_Word16 testNumber)
|
void TestStereo::OpenOutFile(WebRtc_Word16 testNumber)
|
||||||
{
|
{
|
||||||
char fileName[500] = "./src/modules/audio_coding/main/test/teststereo_out_";
|
char fileName[500];
|
||||||
char cntrStr[10];
|
sprintf(fileName, "%s/teststereo_out_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(), testNumber);
|
||||||
sprintf(cntrStr, "%02d.pcm", testNumber);
|
|
||||||
strcat(fileName, cntrStr);
|
|
||||||
|
|
||||||
_outFileB.Open(fileName, 32000, "wb");
|
_outFileB.Open(fileName, 32000, "wb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,14 @@
|
|||||||
|
|
||||||
#include "TestVADDTX.h"
|
#include "TestVADDTX.h"
|
||||||
|
|
||||||
#include "common_types.h"
|
|
||||||
#include "audio_coding_module_typedefs.h"
|
|
||||||
#include "utility.h"
|
|
||||||
#include "engine_configurations.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "audio_coding_module_typedefs.h"
|
||||||
|
#include "common_types.h"
|
||||||
|
#include "engine_configurations.h"
|
||||||
|
#include "testsupport/fileutils.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@@ -351,15 +353,17 @@ void TestVADDTX::Run()
|
|||||||
|
|
||||||
void TestVADDTX::OpenOutFile(WebRtc_Word16 testNumber)
|
void TestVADDTX::OpenOutFile(WebRtc_Word16 testNumber)
|
||||||
{
|
{
|
||||||
char fileName[500] = "./src/modules/audio_coding/main/test/testVADDTX_outFile_";
|
char fileName[500];
|
||||||
char cntrStr[10];
|
|
||||||
|
|
||||||
if(_testMode == 0)
|
if(_testMode == 0)
|
||||||
{
|
{
|
||||||
sprintf(fileName, "./src/modules/audio_coding/main/test/testVADDTX_autoFile_");
|
sprintf(fileName, "%s/testVADDTX_autoFile_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(), testNumber);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(fileName, "%s/testVADDTX_outFile_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(), testNumber);
|
||||||
}
|
}
|
||||||
sprintf(cntrStr, "%02d.pcm", testNumber);
|
|
||||||
strcat(fileName, cntrStr);
|
|
||||||
_outFileB.Open(fileName, 16000, "wb");
|
_outFileB.Open(fileName, 16000, "wb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "audio_coding_module.h"
|
#include "audio_coding_module.h"
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
|
|
||||||
#include "APITest.h"
|
#include "APITest.h"
|
||||||
#include "EncodeDecodeTest.h"
|
#include "EncodeDecodeTest.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
#include "iSACTest.h"
|
#include "iSACTest.h"
|
||||||
#include "SpatialAudio.h"
|
#include "SpatialAudio.h"
|
||||||
#include "TestAllCodecs.h"
|
#include "TestAllCodecs.h"
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
#include "TestStereo.h"
|
#include "TestStereo.h"
|
||||||
#include "TestVADDTX.h"
|
#include "TestVADDTX.h"
|
||||||
#include "TwoWayCommunication.h"
|
#include "TwoWayCommunication.h"
|
||||||
|
#include "testsupport/fileutils.h"
|
||||||
|
|
||||||
using webrtc::AudioCodingModule;
|
using webrtc::AudioCodingModule;
|
||||||
using webrtc::Trace;
|
using webrtc::Trace;
|
||||||
@@ -48,7 +51,8 @@ void PopulateTests(std::vector<ACMTest*>* tests)
|
|||||||
{
|
{
|
||||||
|
|
||||||
Trace::CreateTrace();
|
Trace::CreateTrace();
|
||||||
Trace::SetTraceFile("acm_trace.txt");
|
std::string trace_file = webrtc::test::OutputPath() + "acm_trace.txt";
|
||||||
|
Trace::SetTraceFile(trace_file.c_str());
|
||||||
|
|
||||||
printf("The following tests will be executed:\n");
|
printf("The following tests will be executed:\n");
|
||||||
#ifdef ACM_AUTO_TEST
|
#ifdef ACM_AUTO_TEST
|
||||||
@@ -98,7 +102,9 @@ void PopulateTests(std::vector<ACMTest*>* tests)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
// TODO(kjellander): Make this a proper gtest instead of using this single test
|
||||||
|
// to run all the tests.
|
||||||
|
TEST(AudioCodingModuleTest, RunAllTests)
|
||||||
{
|
{
|
||||||
std::vector<ACMTest*> tests;
|
std::vector<ACMTest*> tests;
|
||||||
PopulateTests(&tests);
|
PopulateTests(&tests);
|
||||||
@@ -113,21 +119,10 @@ int main()
|
|||||||
printf("%s\n", version);
|
printf("%s\n", version);
|
||||||
for (it=tests.begin() ; it < tests.end(); it++)
|
for (it=tests.begin() ; it < tests.end(); it++)
|
||||||
{
|
{
|
||||||
try {
|
(*it)->Perform();
|
||||||
|
|
||||||
(*it)->Perform();
|
|
||||||
}
|
|
||||||
catch (char *except)
|
|
||||||
{
|
|
||||||
printf("Test failed with message: %s", except);
|
|
||||||
getchar();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace::ReturnTrace();
|
Trace::ReturnTrace();
|
||||||
printf("ACM test completed\n");
|
printf("ACM test completed\n");
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "PCMFile.h"
|
#include "PCMFile.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
#include "testsupport/fileutils.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@@ -211,7 +212,8 @@ WebRtc_Word16 TwoWayCommunication::SetUp()
|
|||||||
_inFileA.Open(fileName, frequencyHz, "rb");
|
_inFileA.Open(fileName, frequencyHz, "rb");
|
||||||
|
|
||||||
//--- Output A
|
//--- Output A
|
||||||
strcpy(fileName, "outA.pcm");
|
std::string outputFileA = webrtc::test::OutputPath() + "outA.pcm";
|
||||||
|
strcpy(fileName, outputFileA.c_str());
|
||||||
frequencyHz = 16000;
|
frequencyHz = 16000;
|
||||||
printf("Enter output file at side A [%s]: ", fileName);
|
printf("Enter output file at side A [%s]: ", fileName);
|
||||||
ChooseFile(fileName, 499, &frequencyHz);
|
ChooseFile(fileName, 499, &frequencyHz);
|
||||||
@@ -228,7 +230,8 @@ WebRtc_Word16 TwoWayCommunication::SetUp()
|
|||||||
_inFileB.Open(fileName, frequencyHz, "rb");
|
_inFileB.Open(fileName, frequencyHz, "rb");
|
||||||
|
|
||||||
//--- Output B
|
//--- Output B
|
||||||
strcpy(fileName, "outB.pcm");
|
std::string outputFileB = webrtc::test::OutputPath() + "outB.pcm";
|
||||||
|
strcpy(fileName, outputFileB.c_str());
|
||||||
frequencyHz = 16000;
|
frequencyHz = 16000;
|
||||||
printf("Enter output file at side B [%s]: ", fileName);
|
printf("Enter output file at side B [%s]: ", fileName);
|
||||||
ChooseFile(fileName, 499, &frequencyHz);
|
ChooseFile(fileName, 499, &frequencyHz);
|
||||||
@@ -316,11 +319,12 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
|
|||||||
_inFileA.Open(fileName, frequencyHz, "rb");
|
_inFileA.Open(fileName, frequencyHz, "rb");
|
||||||
|
|
||||||
//--- Output A
|
//--- Output A
|
||||||
strcpy(fileName, "./src/modules/audio_coding/main/test/outAutotestA.pcm");
|
std::string outputFileA = webrtc::test::OutputPath() + "outAutotestA.pcm";
|
||||||
|
strcpy(fileName, outputFileA.c_str());
|
||||||
frequencyHz = 16000;
|
frequencyHz = 16000;
|
||||||
_outFileA.Open(fileName, frequencyHz, "wb");
|
_outFileA.Open(fileName, frequencyHz, "wb");
|
||||||
strcpy(refFileName,
|
std::string outputRefFileA = webrtc::test::OutputPath() + "ref_outAutotestA.pcm";
|
||||||
"./src/modules/audio_coding/main/test/ref_outAutotestA.pcm");
|
strcpy(refFileName, outputRefFileA.c_str());
|
||||||
_outFileRefA.Open(refFileName, frequencyHz, "wb");
|
_outFileRefA.Open(refFileName, frequencyHz, "wb");
|
||||||
|
|
||||||
//--- Input B
|
//--- Input B
|
||||||
@@ -329,11 +333,12 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
|
|||||||
_inFileB.Open(fileName, frequencyHz, "rb");
|
_inFileB.Open(fileName, frequencyHz, "rb");
|
||||||
|
|
||||||
//--- Output B
|
//--- Output B
|
||||||
strcpy(fileName, "./src/modules/audio_coding/main/test/outAutotestB.pcm");
|
std::string outputFileB = webrtc::test::OutputPath() + "outAutotestB.pcm";
|
||||||
|
strcpy(fileName, outputFileB.c_str());
|
||||||
frequencyHz = 16000;
|
frequencyHz = 16000;
|
||||||
_outFileB.Open(fileName, frequencyHz, "wb");
|
_outFileB.Open(fileName, frequencyHz, "wb");
|
||||||
strcpy(refFileName,
|
std::string outputRefFileB = webrtc::test::OutputPath() + "ref_outAutotestB.pcm";
|
||||||
"./src/modules/audio_coding/main/test/ref_outAutotestB.pcm");
|
strcpy(refFileName, outputRefFileB.c_str());
|
||||||
_outFileRefB.Open(refFileName, frequencyHz, "wb");
|
_outFileRefB.Open(refFileName, frequencyHz, "wb");
|
||||||
|
|
||||||
//--- Set A-to-B channel
|
//--- Set A-to-B channel
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "iSACTest.h"
|
#include "iSACTest.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
#include "testsupport/fileutils.h"
|
||||||
#include "tick_util.h"
|
#include "tick_util.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@@ -200,20 +200,10 @@ ISACTest::Setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_inFileA.Open(_fileNameSWB, 32000, "rb");
|
_inFileA.Open(_fileNameSWB, 32000, "rb");
|
||||||
if(_testMode == 0)
|
std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm";
|
||||||
{
|
std::string fileNameB = webrtc::test::OutputPath() + "testisac_b.pcm";
|
||||||
char fileNameA[] = "./src/modules/audio_coding/main/test/testisac_a.pcm";
|
_outFileA.Open(fileNameA.c_str(), 32000, "wb");
|
||||||
char fileNameB[] = "./src/modules/audio_coding/main/test/testisac_b.pcm";
|
_outFileB.Open(fileNameB.c_str(), 32000, "wb");
|
||||||
_outFileA.Open(fileNameA, 32000, "wb");
|
|
||||||
_outFileB.Open(fileNameB, 32000, "wb");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char fileNameA[] = "./src/modules/audio_coding/main/test/testisac_a.pcm";
|
|
||||||
char fileNameB[] = "./src/modules/audio_coding/main/test/testisac_b.pcm";
|
|
||||||
_outFileA.Open(fileNameA, 32000, "wb");
|
|
||||||
_outFileB.Open(fileNameB, 32000, "wb");
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!_inFileA.EndOfFile())
|
while(!_inFileA.EndOfFile())
|
||||||
{
|
{
|
||||||
@@ -395,14 +385,16 @@ ISACTest::EncodeDecode(
|
|||||||
if(_testMode == 0)
|
if(_testMode == 0)
|
||||||
{
|
{
|
||||||
sprintf(fileNameOut,
|
sprintf(fileNameOut,
|
||||||
"./src/modules/audio_coding/main/test/out_iSACTest_%s_%02d.pcm",
|
"%s/out_iSACTest_%s_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(),
|
||||||
"A",
|
"A",
|
||||||
testNr);
|
testNr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(fileNameOut,
|
sprintf(fileNameOut,
|
||||||
"./src/modules/audio_coding/main/test/out%s_%02d.pcm",
|
"%s/out%s_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(),
|
||||||
"A",
|
"A",
|
||||||
testNr);
|
testNr);
|
||||||
}
|
}
|
||||||
@@ -413,14 +405,16 @@ ISACTest::EncodeDecode(
|
|||||||
if(_testMode == 0)
|
if(_testMode == 0)
|
||||||
{
|
{
|
||||||
sprintf(fileNameOut,
|
sprintf(fileNameOut,
|
||||||
"./src/modules/audio_coding/main/test/out_iSACTest_%s_%02d.pcm",
|
"%s/out_iSACTest_%s_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(),
|
||||||
"B",
|
"B",
|
||||||
testNr);
|
testNr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(fileNameOut,
|
sprintf(fileNameOut,
|
||||||
"./src/modules/audio_coding/main/test/out%s_%02d.pcm",
|
"%s/out%s_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(),
|
||||||
"B",
|
"B",
|
||||||
testNr);
|
testNr);
|
||||||
}
|
}
|
||||||
@@ -504,7 +498,8 @@ ISACTest::SwitchingSamplingRate(
|
|||||||
if(_testMode == 0)
|
if(_testMode == 0)
|
||||||
{
|
{
|
||||||
sprintf(fileNameOut,
|
sprintf(fileNameOut,
|
||||||
"./src/modules/audio_coding/main/test/out_iSACTest_%s_%02d.pcm",
|
"%s/out_iSACTest_%s_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(),
|
||||||
"A",
|
"A",
|
||||||
testNr);
|
testNr);
|
||||||
}
|
}
|
||||||
@@ -513,7 +508,8 @@ ISACTest::SwitchingSamplingRate(
|
|||||||
printf("\nTest %d", testNr);
|
printf("\nTest %d", testNr);
|
||||||
printf(" Alternate between WB and SWB at the sender Side\n\n");
|
printf(" Alternate between WB and SWB at the sender Side\n\n");
|
||||||
sprintf(fileNameOut,
|
sprintf(fileNameOut,
|
||||||
"./src/modules/audio_coding/main/test/out%s_%02d.pcm",
|
"%s/out%s_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(),
|
||||||
"A",
|
"A",
|
||||||
testNr);
|
testNr);
|
||||||
}
|
}
|
||||||
@@ -524,13 +520,15 @@ ISACTest::SwitchingSamplingRate(
|
|||||||
if(_testMode == 0)
|
if(_testMode == 0)
|
||||||
{
|
{
|
||||||
sprintf(fileNameOut,
|
sprintf(fileNameOut,
|
||||||
"./src/modules/audio_coding/main/test/out_iSACTest_%s_%02d.pcm",
|
"%s/out_iSACTest_%s_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(),
|
||||||
"B",
|
"B",
|
||||||
testNr);
|
testNr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(fileNameOut, "./src/modules/audio_coding/main/test/out%s_%02d.pcm",
|
sprintf(fileNameOut, "%s/out%s_%02d.pcm",
|
||||||
|
webrtc::test::OutputPath().c_str(),
|
||||||
"B",
|
"B",
|
||||||
testNr);
|
testNr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,28 +12,21 @@
|
|||||||
#define ACM_TEST_UTILITY_H
|
#define ACM_TEST_UTILITY_H
|
||||||
|
|
||||||
#include "audio_coding_module.h"
|
#include "audio_coding_module.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
//-----------------------------
|
//-----------------------------
|
||||||
#define CHECK_ERROR(f) \
|
#define CHECK_ERROR(f) \
|
||||||
do { \
|
do { \
|
||||||
if(f < 0) { \
|
EXPECT_GE(f, 0) << "Error Calling API"; \
|
||||||
char errString[500]; \
|
|
||||||
sprintf(errString, "Error Calling API in file %s at line %d \n", \
|
|
||||||
__FILE__, __LINE__); \
|
|
||||||
throw errString; \
|
|
||||||
} \
|
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
//-----------------------------
|
//-----------------------------
|
||||||
#define CHECK_PROTECTED(f) \
|
#define CHECK_PROTECTED(f) \
|
||||||
do { \
|
do { \
|
||||||
if(f >= 0) { \
|
if(f >= 0) { \
|
||||||
char errString[500]; \
|
ADD_FAILURE() << "Error Calling API"; \
|
||||||
sprintf(errString, "Error Calling API in file %s at line %d \n", \
|
|
||||||
__FILE__, __LINE__); \
|
|
||||||
throw errString; \
|
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
printf("An expected error is caught.\n"); \
|
printf("An expected error is caught.\n"); \
|
||||||
|
|||||||
Reference in New Issue
Block a user