Remove unused voe_stress_test.cc
BUG=webrtc:4690 Review-Url: https://codereview.webrtc.org/2681153003 Cr-Commit-Position: refs/heads/master@{#16513}
This commit is contained in:
parent
3dd5ad9d50
commit
0289364abc
@ -387,8 +387,6 @@ if (rtc_include_tests) {
|
||||
"test/auto_test/voe_conference_test.cc",
|
||||
"test/auto_test/voe_standard_test.cc",
|
||||
"test/auto_test/voe_standard_test.h",
|
||||
"test/auto_test/voe_stress_test.cc",
|
||||
"test/auto_test/voe_stress_test.h",
|
||||
"test/auto_test/voe_test_defines.h",
|
||||
"test/auto_test/voe_test_interface.h",
|
||||
]
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
class TestRtpObserver : public webrtc::VoERTPObserver {
|
||||
public:
|
||||
TestRtpObserver() : changed_ssrc_event_(voetest::EventWrapper::Create()) {}
|
||||
TestRtpObserver() : changed_ssrc_event_(webrtc::EventWrapper::Create()) {}
|
||||
virtual ~TestRtpObserver() {}
|
||||
virtual void OnIncomingCSRCChanged(int channel,
|
||||
unsigned int CSRC,
|
||||
@ -28,7 +28,7 @@ class TestRtpObserver : public webrtc::VoERTPObserver {
|
||||
unsigned int SSRC);
|
||||
void WaitForChangedSsrc() {
|
||||
// 10 seconds should be enough.
|
||||
EXPECT_EQ(voetest::kEventSignaled, changed_ssrc_event_->Wait(10*1000));
|
||||
EXPECT_EQ(webrtc::kEventSignaled, changed_ssrc_event_->Wait(10*1000));
|
||||
}
|
||||
void SetIncomingSsrc(unsigned int ssrc) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
@ -37,7 +37,7 @@ class TestRtpObserver : public webrtc::VoERTPObserver {
|
||||
public:
|
||||
rtc::CriticalSection crit_;
|
||||
unsigned int incoming_ssrc_;
|
||||
std::unique_ptr<voetest::EventWrapper> changed_ssrc_event_;
|
||||
std::unique_ptr<webrtc::EventWrapper> changed_ssrc_event_;
|
||||
};
|
||||
|
||||
void TestRtpObserver::OnIncomingSSRCChanged(int channel,
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/voice_engine/include/voe_neteq_stats.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/automated_mode.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/voe_stress_test.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/voe_test_defines.h"
|
||||
#include "webrtc/voice_engine/voice_engine_defines.h"
|
||||
|
||||
@ -85,166 +84,6 @@ void SubAPIManager::DisplayStatus() const {
|
||||
TEST_LOG(" AudioProcessing\n");
|
||||
ANL();
|
||||
}
|
||||
|
||||
VoETestManager::VoETestManager()
|
||||
: initialized_(false),
|
||||
voice_engine_(NULL),
|
||||
voe_base_(0),
|
||||
voe_codec_(0),
|
||||
voe_xmedia_(0),
|
||||
voe_file_(0),
|
||||
voe_hardware_(0),
|
||||
voe_network_(0),
|
||||
voe_neteq_stats_(NULL),
|
||||
voe_rtp_rtcp_(0),
|
||||
voe_vsync_(0),
|
||||
voe_volume_control_(0),
|
||||
voe_apm_(0) {
|
||||
}
|
||||
|
||||
VoETestManager::~VoETestManager() {
|
||||
}
|
||||
|
||||
bool VoETestManager::Init() {
|
||||
if (initialized_)
|
||||
return true;
|
||||
|
||||
voice_engine_ = VoiceEngine::Create();
|
||||
if (!voice_engine_) {
|
||||
TEST_LOG("Failed to create VoiceEngine\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void VoETestManager::GetInterfaces() {
|
||||
if (voice_engine_) {
|
||||
voe_base_ = VoEBase::GetInterface(voice_engine_);
|
||||
voe_codec_ = VoECodec::GetInterface(voice_engine_);
|
||||
voe_volume_control_ = VoEVolumeControl::GetInterface(voice_engine_);
|
||||
voe_rtp_rtcp_ = VoERTP_RTCP::GetInterface(voice_engine_);
|
||||
voe_apm_ = VoEAudioProcessing::GetInterface(voice_engine_);
|
||||
voe_network_ = VoENetwork::GetInterface(voice_engine_);
|
||||
voe_file_ = VoEFile::GetInterface(voice_engine_);
|
||||
#ifdef _TEST_VIDEO_SYNC_
|
||||
voe_vsync_ = VoEVideoSync::GetInterface(voice_engine_);
|
||||
#endif
|
||||
voe_hardware_ = VoEHardware::GetInterface(voice_engine_);
|
||||
// Set the audio layer to use in all tests
|
||||
if (voe_hardware_) {
|
||||
int res = voe_hardware_->SetAudioDeviceLayer(TESTED_AUDIO_LAYER);
|
||||
if (res < 0) {
|
||||
printf("\nERROR: failed to set audio layer to use in "
|
||||
"testing\n");
|
||||
} else {
|
||||
printf("\nAudio layer %d will be used in testing\n",
|
||||
TESTED_AUDIO_LAYER);
|
||||
}
|
||||
}
|
||||
#ifdef _TEST_XMEDIA_
|
||||
voe_xmedia_ = VoEExternalMedia::GetInterface(voice_engine_);
|
||||
#endif
|
||||
voe_neteq_stats_ = VoENetEqStats::GetInterface(voice_engine_);
|
||||
}
|
||||
}
|
||||
|
||||
int VoETestManager::ReleaseInterfaces() {
|
||||
bool releaseOK(true);
|
||||
|
||||
if (voe_base_) {
|
||||
voe_base_->Release();
|
||||
voe_base_ = NULL;
|
||||
}
|
||||
if (voe_codec_) {
|
||||
voe_codec_->Release();
|
||||
voe_codec_ = NULL;
|
||||
}
|
||||
if (voe_volume_control_) {
|
||||
voe_volume_control_->Release();
|
||||
voe_volume_control_ = NULL;
|
||||
}
|
||||
if (voe_rtp_rtcp_) {
|
||||
voe_rtp_rtcp_->Release();
|
||||
voe_rtp_rtcp_ = NULL;
|
||||
}
|
||||
if (voe_apm_) {
|
||||
voe_apm_->Release();
|
||||
voe_apm_ = NULL;
|
||||
}
|
||||
if (voe_network_) {
|
||||
voe_network_->Release();
|
||||
voe_network_ = NULL;
|
||||
}
|
||||
if (voe_file_) {
|
||||
voe_file_->Release();
|
||||
voe_file_ = NULL;
|
||||
}
|
||||
#ifdef _TEST_VIDEO_SYNC_
|
||||
if (voe_vsync_) {
|
||||
voe_vsync_->Release();
|
||||
voe_vsync_ = NULL;
|
||||
}
|
||||
#endif
|
||||
if (voe_hardware_) {
|
||||
voe_hardware_->Release();
|
||||
voe_hardware_ = NULL;
|
||||
}
|
||||
#ifdef _TEST_XMEDIA_
|
||||
if (voe_xmedia_) {
|
||||
voe_xmedia_->Release();
|
||||
voe_xmedia_ = NULL;
|
||||
}
|
||||
#endif
|
||||
if (voe_neteq_stats_) {
|
||||
voe_neteq_stats_->Release();
|
||||
voe_neteq_stats_ = NULL;
|
||||
}
|
||||
if (false == VoiceEngine::Delete(voice_engine_)) {
|
||||
TEST_LOG("\n\nVoiceEngine::Delete() failed. \n");
|
||||
releaseOK = false;
|
||||
}
|
||||
|
||||
return (releaseOK == true) ? 0 : -1;
|
||||
}
|
||||
|
||||
int run_auto_test(TestType test_type) {
|
||||
assert(test_type != Standard);
|
||||
|
||||
SubAPIManager api_manager;
|
||||
api_manager.DisplayStatus();
|
||||
|
||||
////////////////////////////////////
|
||||
// Create VoiceEngine and sub API:s
|
||||
|
||||
voetest::VoETestManager test_manager;
|
||||
if (!test_manager.Init()) {
|
||||
return -1;
|
||||
}
|
||||
test_manager.GetInterfaces();
|
||||
|
||||
int result = -1;
|
||||
if (test_type == Stress) {
|
||||
VoEStressTest stressTest(test_manager);
|
||||
result = stressTest.DoTest();
|
||||
} else {
|
||||
// Should never end up here
|
||||
assert(false);
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Release/Delete
|
||||
|
||||
int release_ok = test_manager.ReleaseInterfaces();
|
||||
|
||||
if ((0 == result) && (release_ok != -1)) {
|
||||
TEST_LOG("\n\n*** All tests passed *** \n\n");
|
||||
} else {
|
||||
TEST_LOG("\n\n*** Test failed! *** \n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace voetest
|
||||
|
||||
int RunInManualMode() {
|
||||
@ -257,42 +96,22 @@ int RunInManualMode() {
|
||||
printf("Select type of test\n\n");
|
||||
printf(" (0) Quit\n");
|
||||
printf(" (1) Standard test\n");
|
||||
printf(" (2) [OBSOLETE: Extended test(s)...]\n");
|
||||
printf(" (3) Stress test(s)...\n");
|
||||
printf(" (4) [OBSOLETE: Unit test(s)...]\n");
|
||||
printf("\n: ");
|
||||
|
||||
int selection(0);
|
||||
dummy = scanf("%d", &selection);
|
||||
|
||||
TestType test_type = Invalid;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
test_type = Standard;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
test_type = Stress;
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
TEST_LOG("\n\n+++ Running standard tests +++\n\n");
|
||||
// Currently, all googletest-rewritten tests are in the "automated" suite.
|
||||
return RunInAutomatedMode();
|
||||
default:
|
||||
TEST_LOG("Invalid selection!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (test_type == Standard) {
|
||||
TEST_LOG("\n\n+++ Running standard tests +++\n\n");
|
||||
|
||||
// Currently, all googletest-rewritten tests are in the "automated" suite.
|
||||
return RunInAutomatedMode();
|
||||
}
|
||||
|
||||
// Function that can be called from other entry functions.
|
||||
return run_auto_test(test_type);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@ -16,23 +16,7 @@
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/voice_engine/include/voe_audio_processing.h"
|
||||
#include "webrtc/voice_engine/include/voe_base.h"
|
||||
#include "webrtc/voice_engine/include/voe_errors.h"
|
||||
#include "webrtc/voice_engine/include/voe_file.h"
|
||||
#include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/voe_test_common.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/voe_test_interface.h"
|
||||
#include "webrtc/voice_engine/include/voe_codec.h"
|
||||
#include "webrtc/voice_engine/include/voe_external_media.h"
|
||||
#include "webrtc/voice_engine/include/voe_hardware.h"
|
||||
#include "webrtc/voice_engine/include/voe_network.h"
|
||||
#include "webrtc/voice_engine/include/voe_video_sync.h"
|
||||
#include "webrtc/voice_engine/include/voe_volume_control.h"
|
||||
|
||||
namespace webrtc {
|
||||
class VoENetEqStats;
|
||||
}
|
||||
|
||||
#if defined(WEBRTC_ANDROID)
|
||||
extern char mobileLogMsg[640];
|
||||
@ -76,83 +60,6 @@ class SubAPIManager {
|
||||
bool _netEqStats, _network, _rtp_rtcp, _videoSync, _volumeControl, _apm;
|
||||
};
|
||||
|
||||
class VoETestManager {
|
||||
public:
|
||||
VoETestManager();
|
||||
~VoETestManager();
|
||||
|
||||
// Must be called after construction.
|
||||
bool Init();
|
||||
|
||||
void GetInterfaces();
|
||||
int ReleaseInterfaces();
|
||||
|
||||
const char* AudioFilename() const {
|
||||
const std::string& result =
|
||||
webrtc::test::ResourcePath("voice_engine/audio_long16", "pcm");
|
||||
return result.c_str();
|
||||
}
|
||||
|
||||
VoiceEngine* VoiceEnginePtr() const {
|
||||
return voice_engine_;
|
||||
}
|
||||
VoEBase* BasePtr() const {
|
||||
return voe_base_;
|
||||
}
|
||||
VoECodec* CodecPtr() const {
|
||||
return voe_codec_;
|
||||
}
|
||||
VoEVolumeControl* VolumeControlPtr() const {
|
||||
return voe_volume_control_;
|
||||
}
|
||||
VoERTP_RTCP* RTP_RTCPPtr() const {
|
||||
return voe_rtp_rtcp_;
|
||||
}
|
||||
VoEAudioProcessing* APMPtr() const {
|
||||
return voe_apm_;
|
||||
}
|
||||
|
||||
VoENetwork* NetworkPtr() const {
|
||||
return voe_network_;
|
||||
}
|
||||
|
||||
VoEFile* FilePtr() const {
|
||||
return voe_file_;
|
||||
}
|
||||
|
||||
VoEHardware* HardwarePtr() const {
|
||||
return voe_hardware_;
|
||||
}
|
||||
|
||||
VoEVideoSync* VideoSyncPtr() const {
|
||||
return voe_vsync_;
|
||||
}
|
||||
|
||||
VoEExternalMedia* ExternalMediaPtr() const {
|
||||
return voe_xmedia_;
|
||||
}
|
||||
|
||||
VoENetEqStats* NetEqStatsPtr() const {
|
||||
return voe_neteq_stats_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool initialized_;
|
||||
|
||||
VoiceEngine* voice_engine_;
|
||||
VoEBase* voe_base_;
|
||||
VoECodec* voe_codec_;
|
||||
VoEExternalMedia* voe_xmedia_;
|
||||
VoEFile* voe_file_;
|
||||
VoEHardware* voe_hardware_;
|
||||
VoENetwork* voe_network_;
|
||||
VoENetEqStats* voe_neteq_stats_;
|
||||
VoERTP_RTCP* voe_rtp_rtcp_;
|
||||
VoEVideoSync* voe_vsync_;
|
||||
VoEVolumeControl* voe_volume_control_;
|
||||
VoEAudioProcessing* voe_apm_;
|
||||
};
|
||||
|
||||
} // namespace voetest
|
||||
|
||||
#endif // WEBRTC_VOICE_ENGINE_VOE_STANDARD_TEST_H
|
||||
|
||||
@ -1,403 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// Some ideas of improvements:
|
||||
// Break out common init and maybe terminate to separate function(s).
|
||||
// How much trace should we have enabled?
|
||||
// API error counter, to print info and return -1 if any error.
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#if defined(_WIN32)
|
||||
#include <conio.h>
|
||||
#endif
|
||||
|
||||
#include "webrtc/voice_engine/test/auto_test/voe_stress_test.h"
|
||||
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
#include "webrtc/voice_engine/test/channel_transport/channel_transport.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/voe_standard_test.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/voe_test_defines.h"
|
||||
#include "webrtc/voice_engine/voice_engine_defines.h" // defines build macros
|
||||
|
||||
using namespace webrtc;
|
||||
using namespace test;
|
||||
|
||||
namespace voetest {
|
||||
|
||||
#define VALIDATE_STRESS(expr) \
|
||||
if (expr) \
|
||||
{ \
|
||||
printf("Error at line: %i, %s \n", __LINE__, #expr); \
|
||||
printf("Error code: %i \n", base->LastError()); \
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Pause if supported
|
||||
#define PAUSE_OR_SLEEP(x) PAUSE;
|
||||
#else
|
||||
// Sleep a bit instead if pause not supported
|
||||
#define PAUSE_OR_SLEEP(x) SleepMs(x);
|
||||
#endif
|
||||
|
||||
int VoEStressTest::DoTest() {
|
||||
int test(-1);
|
||||
while (test != 0) {
|
||||
test = MenuSelection();
|
||||
switch (test) {
|
||||
case 0:
|
||||
// Quit stress test
|
||||
break;
|
||||
case 1:
|
||||
// All tests
|
||||
StartStopTest();
|
||||
CreateDeleteChannelsTest();
|
||||
MultipleThreadsTest();
|
||||
break;
|
||||
case 2:
|
||||
StartStopTest();
|
||||
break;
|
||||
case 3:
|
||||
CreateDeleteChannelsTest();
|
||||
break;
|
||||
case 4:
|
||||
MultipleThreadsTest();
|
||||
break;
|
||||
default:
|
||||
// Should not be possible
|
||||
printf("Invalid selection! (Test code error)\n");
|
||||
assert(false);
|
||||
} // switch
|
||||
} // while
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VoEStressTest::MenuSelection() {
|
||||
printf("------------------------------------------------\n");
|
||||
printf("Select stress test\n\n");
|
||||
printf(" (0) Quit\n");
|
||||
printf(" (1) All\n");
|
||||
printf("- - - - - - - - - - - - - - - - - - - - - - - - \n");
|
||||
printf(" (2) Start/stop\n");
|
||||
printf(" (3) Create/delete channels\n");
|
||||
printf(" (4) Multiple threads\n");
|
||||
|
||||
const int maxMenuSelection = 4;
|
||||
int selection(-1);
|
||||
|
||||
while ((selection < 0) || (selection > maxMenuSelection)) {
|
||||
printf("\n: ");
|
||||
int retval = scanf("%d", &selection);
|
||||
if ((retval != 1) || (selection < 0) || (selection > maxMenuSelection)) {
|
||||
printf("Invalid selection!\n");
|
||||
}
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
int VoEStressTest::StartStopTest() {
|
||||
printf("------------------------------------------------\n");
|
||||
printf("Running start/stop test\n");
|
||||
printf("------------------------------------------------\n");
|
||||
|
||||
printf("\nNOTE: this thest will fail after a while if Core audio is used\n");
|
||||
printf("because MS returns AUDCLNT_E_CPUUSAGE_EXCEEDED (VoE Error 10013).\n");
|
||||
|
||||
// Get sub-API pointers
|
||||
VoEBase* base = _mgr.BasePtr();
|
||||
VoENetwork* voe_network = _mgr.NetworkPtr();
|
||||
|
||||
// Set trace
|
||||
// VALIDATE_STRESS(base->SetTraceFileName(
|
||||
// GetFilename("VoEStressTest_StartStop_trace.txt")));
|
||||
// VALIDATE_STRESS(base->SetDebugTraceFileName(
|
||||
// GetFilename("VoEStressTest_StartStop_trace_debug.txt")));
|
||||
// VALIDATE_STRESS(base->SetTraceFilter(kTraceStateInfo |
|
||||
// kTraceWarning | kTraceError |
|
||||
// kTraceCritical | kTraceApiCall |
|
||||
// kTraceMemory | kTraceInfo));
|
||||
VALIDATE_STRESS(base->Init());
|
||||
VALIDATE_STRESS(base->CreateChannel());
|
||||
|
||||
///////////// Start test /////////////
|
||||
|
||||
int numberOfLoops(2000);
|
||||
int loopSleep(200);
|
||||
int i(0);
|
||||
int markInterval(20);
|
||||
|
||||
printf("Running %d loops with %d ms sleep. Mark every %d loop. \n",
|
||||
numberOfLoops, loopSleep, markInterval);
|
||||
printf("Test will take approximately %d minutes. \n",
|
||||
numberOfLoops * loopSleep / 1000 / 60 + 1);
|
||||
|
||||
std::unique_ptr<VoiceChannelTransport> voice_channel_transport(
|
||||
new VoiceChannelTransport(voe_network, 0));
|
||||
|
||||
for (i = 0; i < numberOfLoops; ++i) {
|
||||
voice_channel_transport->SetSendDestination("127.0.0.1", 4800);
|
||||
voice_channel_transport->SetLocalReceiver(4800);
|
||||
VALIDATE_STRESS(base->StartPlayout(0));
|
||||
VALIDATE_STRESS(base->StartSend(0));
|
||||
if (!(i % markInterval))
|
||||
MARK();
|
||||
SleepMs(loopSleep);
|
||||
VALIDATE_STRESS(base->StopSend(0));
|
||||
VALIDATE_STRESS(base->StopPlayout(0));
|
||||
}
|
||||
ANL();
|
||||
|
||||
VALIDATE_STRESS(voice_channel_transport->SetSendDestination("127.0.0.1",
|
||||
4800));
|
||||
VALIDATE_STRESS(voice_channel_transport->SetLocalReceiver(4800));
|
||||
VALIDATE_STRESS(base->StartPlayout(0));
|
||||
VALIDATE_STRESS(base->StartSend(0));
|
||||
printf("Verify that audio is good. \n");
|
||||
PAUSE_OR_SLEEP(20000);
|
||||
VALIDATE_STRESS(base->StopSend(0));
|
||||
VALIDATE_STRESS(base->StopPlayout(0));
|
||||
|
||||
///////////// End test /////////////
|
||||
|
||||
|
||||
// Terminate
|
||||
VALIDATE_STRESS(base->DeleteChannel(0));
|
||||
VALIDATE_STRESS(base->Terminate());
|
||||
|
||||
printf("Test finished \n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VoEStressTest::CreateDeleteChannelsTest() {
|
||||
printf("------------------------------------------------\n");
|
||||
printf("Running create/delete channels test\n");
|
||||
printf("------------------------------------------------\n");
|
||||
|
||||
// Get sub-API pointers
|
||||
VoEBase* base = _mgr.BasePtr();
|
||||
|
||||
// Set trace
|
||||
// VALIDATE_STRESS(base->SetTraceFileName(
|
||||
// GetFilename("VoEStressTest_CreateChannels_trace.txt")));
|
||||
// VALIDATE_STRESS(base->SetDebugTraceFileName(
|
||||
// GetFilename("VoEStressTest_CreateChannels_trace_debug.txt")));
|
||||
// VALIDATE_STRESS(base->SetTraceFilter(kTraceStateInfo |
|
||||
// kTraceWarning | kTraceError |
|
||||
// kTraceCritical | kTraceApiCall |
|
||||
// kTraceMemory | kTraceInfo));
|
||||
VALIDATE_STRESS(base->Init());
|
||||
|
||||
///////////// Start test /////////////
|
||||
|
||||
int numberOfLoops(10000);
|
||||
int loopSleep(10);
|
||||
int i(0);
|
||||
int markInterval(200);
|
||||
|
||||
printf("Running %d loops with %d ms sleep. Mark every %d loop. \n",
|
||||
numberOfLoops, loopSleep, markInterval);
|
||||
printf("Test will take approximately %d minutes. \n",
|
||||
numberOfLoops * loopSleep / 1000 / 60 + 1);
|
||||
|
||||
// Some possible extensions include:
|
||||
// Different sleep times (fixed or random) or zero.
|
||||
// Start call on all or some channels.
|
||||
// Two parts: first have a slight overweight to creating channels,
|
||||
// then to deleting. (To ensure we hit max channels and go to zero.)
|
||||
// Make sure audio is OK after test has finished.
|
||||
|
||||
// Set up, start with maxChannels/2 channels
|
||||
const int maxChannels = 100;
|
||||
VALIDATE_STRESS(maxChannels < 1); // Should always have at least one channel
|
||||
bool* channelState = new bool[maxChannels];
|
||||
memset(channelState, 0, maxChannels * sizeof(bool));
|
||||
int channel(0);
|
||||
int noOfActiveChannels(0);
|
||||
for (i = 0; i < (maxChannels / 2); ++i) {
|
||||
channel = base->CreateChannel();
|
||||
VALIDATE_STRESS(channel < 0);
|
||||
if (channel >= 0) {
|
||||
channelState[channel] = true;
|
||||
++noOfActiveChannels;
|
||||
}
|
||||
}
|
||||
srand((unsigned int) time(NULL));
|
||||
bool action(false);
|
||||
double rnd(0.0);
|
||||
int res(0);
|
||||
|
||||
// Create/delete channels with slight
|
||||
for (i = 0; i < numberOfLoops; ++i) {
|
||||
// Randomize action (create or delete channel)
|
||||
action = rand() <= (RAND_MAX / 2);
|
||||
if (action) {
|
||||
if (noOfActiveChannels < maxChannels) {
|
||||
// Create new channel
|
||||
channel = base->CreateChannel();
|
||||
VALIDATE_STRESS(channel < 0);
|
||||
if (channel >= 0) {
|
||||
channelState[channel] = true;
|
||||
++noOfActiveChannels;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (noOfActiveChannels > 0) {
|
||||
// Delete random channel that's created [0, maxChannels - 1]
|
||||
do {
|
||||
rnd = static_cast<double> (rand());
|
||||
channel = static_cast<int> (rnd /
|
||||
(static_cast<double> (RAND_MAX) + 1.0f) *
|
||||
maxChannels);
|
||||
} while (!channelState[channel]); // Must find a created channel
|
||||
|
||||
res = base->DeleteChannel(channel);
|
||||
VALIDATE_STRESS(0 != res);
|
||||
if (0 == res) {
|
||||
channelState[channel] = false;
|
||||
--noOfActiveChannels;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(i % markInterval))
|
||||
MARK();
|
||||
SleepMs(loopSleep);
|
||||
}
|
||||
ANL();
|
||||
|
||||
delete[] channelState;
|
||||
|
||||
///////////// End test /////////////
|
||||
|
||||
|
||||
// Terminate
|
||||
VALIDATE_STRESS(base->Terminate()); // Deletes all channels
|
||||
|
||||
printf("Test finished \n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VoEStressTest::MultipleThreadsTest() {
|
||||
printf("------------------------------------------------\n");
|
||||
printf("Running multiple threads test\n");
|
||||
printf("------------------------------------------------\n");
|
||||
|
||||
// Get sub-API pointers
|
||||
VoEBase* base = _mgr.BasePtr();
|
||||
|
||||
// Set trace
|
||||
// VALIDATE_STRESS(base->SetTraceFileName(
|
||||
// GetFilename("VoEStressTest_MultipleThreads_trace.txt")));
|
||||
// VALIDATE_STRESS(base->SetDebugTraceFileName(
|
||||
// GetFilename("VoEStressTest_MultipleThreads_trace_debug.txt")));
|
||||
// VALIDATE_STRESS(base->SetTraceFilter(kTraceStateInfo |
|
||||
// kTraceWarning | kTraceError |
|
||||
// kTraceCritical | kTraceApiCall |
|
||||
// kTraceMemory | kTraceInfo));
|
||||
|
||||
// Init
|
||||
VALIDATE_STRESS(base->Init());
|
||||
VALIDATE_STRESS(base->CreateChannel());
|
||||
|
||||
///////////// Start test /////////////
|
||||
|
||||
int numberOfLoops(10000);
|
||||
int loopSleep(0);
|
||||
int i(0);
|
||||
int markInterval(1000);
|
||||
|
||||
printf("Running %d loops with %d ms sleep. Mark every %d loop. \n",
|
||||
numberOfLoops, loopSleep, markInterval);
|
||||
printf("Test will take approximately %d minutes. \n",
|
||||
numberOfLoops * loopSleep / 1000 / 60 + 1);
|
||||
|
||||
srand((unsigned int) time(NULL));
|
||||
int rnd(0);
|
||||
|
||||
// Start extra thread
|
||||
_ptrExtraApiThread.reset(
|
||||
new rtc::PlatformThread(RunExtraApi, this, "StressTestExtraApiThread"));
|
||||
_ptrExtraApiThread->Start();
|
||||
|
||||
// Some possible extensions include:
|
||||
// Add more API calls to randomize
|
||||
// More threads
|
||||
// Different sleep times (fixed or random).
|
||||
// Make sure audio is OK after test has finished.
|
||||
|
||||
// Call random API functions here and in extra thread, ignore any error
|
||||
for (i = 0; i < numberOfLoops; ++i) {
|
||||
// This part should be equal to the marked part in the extra thread
|
||||
// --- BEGIN ---
|
||||
rnd = rand();
|
||||
if (rnd < (RAND_MAX / 2)) {
|
||||
// Start playout
|
||||
base->StartPlayout(0);
|
||||
} else {
|
||||
// Stop playout
|
||||
base->StopPlayout(0);
|
||||
}
|
||||
// --- END ---
|
||||
|
||||
if (!(i % markInterval))
|
||||
MARK();
|
||||
SleepMs(loopSleep);
|
||||
}
|
||||
ANL();
|
||||
|
||||
// Stop extra thread
|
||||
_ptrExtraApiThread->Stop();
|
||||
|
||||
///////////// End test /////////////
|
||||
|
||||
// Terminate
|
||||
VALIDATE_STRESS(base->Terminate()); // Deletes all channels
|
||||
|
||||
printf("Test finished \n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Thread functions
|
||||
|
||||
bool VoEStressTest::RunExtraApi(void* ptr) {
|
||||
return static_cast<VoEStressTest*> (ptr)->ProcessExtraApi();
|
||||
}
|
||||
|
||||
bool VoEStressTest::ProcessExtraApi() {
|
||||
// Prepare
|
||||
VoEBase* base = _mgr.BasePtr();
|
||||
int rnd(0);
|
||||
|
||||
// Call random API function, ignore any error
|
||||
|
||||
// This part should be equal to the marked part in the main thread
|
||||
// --- BEGIN ---
|
||||
rnd = rand();
|
||||
if (rnd < (RAND_MAX / 2)) {
|
||||
// Start playout
|
||||
base->StartPlayout(0);
|
||||
} else {
|
||||
// Stop playout
|
||||
base->StopPlayout(0);
|
||||
}
|
||||
// --- END ---
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace voetest
|
||||
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H
|
||||
#define WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
|
||||
namespace voetest {
|
||||
|
||||
class VoETestManager;
|
||||
|
||||
class VoEStressTest {
|
||||
public:
|
||||
VoEStressTest(VoETestManager& mgr) : _mgr(mgr) {
|
||||
}
|
||||
~VoEStressTest() {
|
||||
}
|
||||
int DoTest();
|
||||
|
||||
private:
|
||||
int MenuSelection();
|
||||
int StartStopTest();
|
||||
int CreateDeleteChannelsTest();
|
||||
int MultipleThreadsTest();
|
||||
|
||||
static bool RunExtraApi(void* ptr);
|
||||
bool ProcessExtraApi();
|
||||
|
||||
VoETestManager& _mgr;
|
||||
|
||||
// TODO(pbos): Remove unique_ptr and use PlatformThread directly.
|
||||
std::unique_ptr<rtc::PlatformThread> _ptrExtraApiThread;
|
||||
};
|
||||
|
||||
} // namespace voetest
|
||||
|
||||
#endif // WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H
|
||||
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Interface for starting test
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_VOICE_ENGINE_VOE_TEST_INTERFACE_H
|
||||
#define WEBRTC_VOICE_ENGINE_VOE_TEST_INTERFACE_H
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
namespace voetest {
|
||||
// TODO(andrew): Using directives not permitted.
|
||||
using namespace webrtc;
|
||||
|
||||
// TestType enumerator
|
||||
enum TestType {
|
||||
Invalid = -1,
|
||||
Standard = 0,
|
||||
|
||||
Stress = 2
|
||||
};
|
||||
|
||||
// Main test function
|
||||
int runAutoTest(TestType testType);
|
||||
|
||||
} // namespace voetest
|
||||
#endif // WEBRTC_VOICE_ENGINE_VOE_TEST_INTERFACE_H
|
||||
Loading…
x
Reference in New Issue
Block a user