Use new fileutil functions for trace in ACM

I this CL I have changed to use filutil functions in the ACM tests. I have also reformated the file Tester.cc, and fixe one minor bug in TestAllCodecs.cc.

BUG=issue195
TEST=audio_coding_module_test

Review URL: https://webrtc-codereview.appspot.com/636006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2394 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org 2012-06-12 07:16:24 +00:00
parent 1c284734cd
commit 5e7ca608d5
4 changed files with 69 additions and 75 deletions

View File

@ -8,21 +8,23 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <cctype>
#include <iostream>
#include <ostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cctype>
#include <iostream>
#include <ostream>
#include <string>
#include "gtest/gtest.h"
#include "APITest.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 "testsupport/fileutils.h"
#include "tick_util.h"
#include "trace.h"
#include "utility.h"
@ -323,6 +325,11 @@ APITest::SetUp()
char print[11];
// Create a trace file.
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_api_trace.txt").c_str());
printf("\nRandom Test (y/n)?");
EXPECT_TRUE(fgets(print, 10, stdin) != NULL);
print[10] = '\0';
@ -331,14 +338,9 @@ APITest::SetUp()
_randomTest = true;
_verbose = false;
_writeToFile = false;
Trace::CreateTrace();
Trace::SetTraceFile("ACMAPITest.txt");
//freopen("APITest_log.txt", "w", stdout);
}
else
{
Trace::CreateTrace();
Trace::SetTraceFile("ACMAPITest.txt", true);
_randomTest = false;
printf("\nPrint Tests (y/n)? ");
EXPECT_TRUE(fgets(print, 10, stdin) != NULL);

View File

@ -13,12 +13,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "gtest/gtest.h"
#include "audio_coding_module.h"
#include "common_types.h"
#include "gtest/gtest.h"
#include "trace.h"
#include "testsupport/fileutils.h"
#include "trace.h"
#include "utility.h"
namespace webrtc {
@ -270,7 +272,8 @@ void Receiver::Run() {
EncodeDecodeTest::EncodeDecodeTest() {
_testMode = 2;
Trace::CreateTrace();
Trace::SetTraceFile("acm_encdec_test.txt");
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_encdec_trace.txt").c_str());
}
EncodeDecodeTest::EncodeDecodeTest(int testMode) {
@ -280,7 +283,8 @@ EncodeDecodeTest::EncodeDecodeTest(int testMode) {
_testMode = testMode;
if(_testMode != 0) {
Trace::CreateTrace();
Trace::SetTraceFile("acm_encdec_test.txt");
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_encdec_trace.txt").c_str());
}
}

View File

@ -10,8 +10,9 @@
#include "TestAllCodecs.h"
#include <stdio.h>
#include <cassert>
#include <iostream>
#include <string>
#include "audio_coding_module_typedefs.h"
#include "common_types.h"
@ -659,11 +660,11 @@ void TestAllCodecs::Perform()
_testCntr++;
OpenOutFile(_testCntr);
char codecCELT_32[] = "CELT";
RegisterSendCodec('A', codecCELT_32, 32000, 48000, 320, 0);
RegisterSendCodec('A', codecCELT_32, 32000, 48000, 640, 0);
Run(_channelA2B);
RegisterSendCodec('A', codecCELT_32, 32000, 64000, 320, 0);
RegisterSendCodec('A', codecCELT_32, 32000, 64000, 640, 0);
Run(_channelA2B);
RegisterSendCodec('A', codecCELT_32, 32000, 128000, 320, 0);
RegisterSendCodec('A', codecCELT_32, 32000, 128000, 640, 0);
Run(_channelA2B);
_outFileB.Close();
#endif

View File

@ -12,28 +12,23 @@
#include <string>
#include <vector>
#include "audio_coding_module.h"
#include "trace.h"
#include "gtest/gtest.h"
#include "APITest.h"
#include "audio_coding_module.h"
#include "EncodeDecodeTest.h"
#include "gtest/gtest.h"
#include "iSACTest.h"
#include "SpatialAudio.h"
#include "TestAllCodecs.h"
#include "TestFEC.h"
#include "TestStereo.h"
#include "TestVADDTX.h"
#include "TwoWayCommunication.h"
#include "testsupport/fileutils.h"
#include "TestVADDTX.h"
#include "trace.h"
#include "TwoWayCommunication.h"
using webrtc::AudioCodingModule;
using webrtc::Trace;
// Be sure to create the following directories before running the tests:
// ./modules/audio_coding/main/test/res_tests
// ./modules/audio_coding/main/test/res_autotests
// Choose what tests to run by defining one or more of the following:
#define ACM_AUTO_TEST // Most common codecs and settings will be tested
//#define ACM_TEST_ENC_DEC // You decide what to test in run time.
@ -46,75 +41,67 @@ using webrtc::Trace;
//#define ACM_TEST_CODEC_SPEC_API // Only iSAC has codec specfic APIs in this version
//#define ACM_TEST_FULL_API // Test all APIs with threads (long test)
void PopulateTests(std::vector<ACMTest*>* tests) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() + "acm_trace.txt").c_str());
void PopulateTests(std::vector<ACMTest*>* tests)
{
Trace::CreateTrace();
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
printf(" ACM auto test\n");
tests->push_back(new webrtc::EncodeDecodeTest(0));
tests->push_back(new webrtc::TwoWayCommunication(0));
tests->push_back(new webrtc::TestAllCodecs(0));
tests->push_back(new webrtc::TestStereo(0));
// tests->push_back(new webrtc::SpatialAudio(0));
tests->push_back(new webrtc::TestVADDTX(0));
tests->push_back(new webrtc::TestFEC(0));
tests->push_back(new webrtc::ISACTest(0));
printf(" ACM auto test\n");
tests->push_back(new webrtc::EncodeDecodeTest(0));
tests->push_back(new webrtc::TwoWayCommunication(0));
tests->push_back(new webrtc::TestAllCodecs(0));
tests->push_back(new webrtc::TestStereo(0));
tests->push_back(new webrtc::TestVADDTX(0));
tests->push_back(new webrtc::TestFEC(0));
tests->push_back(new webrtc::ISACTest(0));
#endif
#ifdef ACM_TEST_ENC_DEC
printf(" ACM encode-decode test\n");
tests->push_back(new webrtc::EncodeDecodeTest(2));
printf(" ACM encode-decode test\n");
tests->push_back(new webrtc::EncodeDecodeTest(2));
#endif
#ifdef ACM_TEST_TWO_WAY
printf(" ACM two-way communication test\n");
tests->push_back(new webrtc::TwoWayCommunication(1));
printf(" ACM two-way communication test\n");
tests->push_back(new webrtc::TwoWayCommunication(1));
#endif
#ifdef ACM_TEST_ALL_ENC_DEC
printf(" ACM all codecs test\n");
tests->push_back(new webrtc::TestAllCodecs(1));
printf(" ACM all codecs test\n");
tests->push_back(new webrtc::TestAllCodecs(1));
#endif
#ifdef ACM_TEST_STEREO
printf(" ACM stereo test\n");
tests->push_back(new webrtc::TestStereo(1));
//tests->push_back(new webrtc::SpatialAudio(2));
printf(" ACM stereo test\n");
tests->push_back(new webrtc::TestStereo(1));
#endif
#ifdef ACM_TEST_VAD_DTX
printf(" ACM VAD-DTX test\n");
tests->push_back(new webrtc::TestVADDTX(1));
printf(" ACM VAD-DTX test\n");
tests->push_back(new webrtc::TestVADDTX(1));
#endif
#ifdef ACM_TEST_FEC
printf(" ACM FEC test\n");
tests->push_back(new webrtc::TestFEC(1));
printf(" ACM FEC test\n");
tests->push_back(new webrtc::TestFEC(1));
#endif
#ifdef ACM_TEST_CODEC_SPEC_API
printf(" ACM codec API test\n");
tests->push_back(new webrtc::ISACTest(1));
printf(" ACM codec API test\n");
tests->push_back(new webrtc::ISACTest(1));
#endif
#ifdef ACM_TEST_FULL_API
printf(" ACM full API test\n");
tests->push_back(new webrtc::APITest());
printf(" ACM full API test\n");
tests->push_back(new webrtc::APITest());
#endif
printf("\n");
printf("\n");
}
// 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;
PopulateTests(&tests);
std::vector<ACMTest*>::iterator it;
for (it=tests.begin() ; it < tests.end(); it++)
{
(*it)->Perform();
delete (*it);
}
TEST(AudioCodingModuleTest, RunAllTests) {
std::vector<ACMTest*> tests;
PopulateTests(&tests);
std::vector<ACMTest*>::iterator it;
for (it = tests.begin(); it < tests.end(); it++) {
(*it)->Perform();
delete (*it);
}
Trace::ReturnTrace();
printf("ACM test completed\n");
Trace::ReturnTrace();
printf("ACM test completed\n");
}