From 5e7ca608d54043a09ce62193f372bb7b3ba7d8e1 Mon Sep 17 00:00:00 2001 From: "tina.legrand@webrtc.org" Date: Tue, 12 Jun 2012 07:16:24 +0000 Subject: [PATCH] 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 --- src/modules/audio_coding/main/test/APITest.cc | 22 ++-- .../main/test/EncodeDecodeTest.cc | 12 ++- .../audio_coding/main/test/TestAllCodecs.cc | 9 +- src/modules/audio_coding/main/test/Tester.cc | 101 ++++++++---------- 4 files changed, 69 insertions(+), 75 deletions(-) diff --git a/src/modules/audio_coding/main/test/APITest.cc b/src/modules/audio_coding/main/test/APITest.cc index f601567c45..07bbd5252f 100644 --- a/src/modules/audio_coding/main/test/APITest.cc +++ b/src/modules/audio_coding/main/test/APITest.cc @@ -8,21 +8,23 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include -#include #include #include #include +#include +#include +#include +#include + +#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); diff --git a/src/modules/audio_coding/main/test/EncodeDecodeTest.cc b/src/modules/audio_coding/main/test/EncodeDecodeTest.cc index 06aa743904..98c01fdf24 100644 --- a/src/modules/audio_coding/main/test/EncodeDecodeTest.cc +++ b/src/modules/audio_coding/main/test/EncodeDecodeTest.cc @@ -13,12 +13,14 @@ #include #include #include +#include + +#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()); } } diff --git a/src/modules/audio_coding/main/test/TestAllCodecs.cc b/src/modules/audio_coding/main/test/TestAllCodecs.cc index eea41e9af2..cafbc19489 100644 --- a/src/modules/audio_coding/main/test/TestAllCodecs.cc +++ b/src/modules/audio_coding/main/test/TestAllCodecs.cc @@ -10,8 +10,9 @@ #include "TestAllCodecs.h" +#include #include -#include +#include #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 diff --git a/src/modules/audio_coding/main/test/Tester.cc b/src/modules/audio_coding/main/test/Tester.cc index 8362164161..710ea01bc1 100644 --- a/src/modules/audio_coding/main/test/Tester.cc +++ b/src/modules/audio_coding/main/test/Tester.cc @@ -12,28 +12,23 @@ #include #include -#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* tests) { + Trace::CreateTrace(); + Trace::SetTraceFile((webrtc::test::OutputPath() + "acm_trace.txt").c_str()); -void PopulateTests(std::vector* 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 tests; - PopulateTests(&tests); - std::vector::iterator it; - for (it=tests.begin() ; it < tests.end(); it++) - { - (*it)->Perform(); - delete (*it); - } +TEST(AudioCodingModuleTest, RunAllTests) { + std::vector tests; + PopulateTests(&tests); + std::vector::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"); }