andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 11 | #include "webrtc/voice_engine/test/auto_test/voe_standard_test.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 12 | |
| 13 | #include <stdio.h> |
| 14 | #include <string.h> |
| 15 | |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 16 | #include "webrtc/engine_configurations.h" |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 17 | #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 18 | #include "webrtc/system_wrappers/interface/event_wrapper.h" |
| 19 | #include "webrtc/voice_engine/include/voe_neteq_stats.h" |
| 20 | #include "webrtc/voice_engine/test/auto_test/automated_mode.h" |
| 21 | #include "webrtc/voice_engine/test/auto_test/voe_cpu_test.h" |
| 22 | #include "webrtc/voice_engine/test/auto_test/voe_extended_test.h" |
| 23 | #include "webrtc/voice_engine/test/auto_test/voe_stress_test.h" |
| 24 | #include "webrtc/voice_engine/test/auto_test/voe_test_defines.h" |
| 25 | #include "webrtc/voice_engine/test/auto_test/voe_unit_test.h" |
| 26 | #include "webrtc/voice_engine/voice_engine_defines.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 27 | |
| 28 | DEFINE_bool(include_timing_dependent_tests, true, |
| 29 | "If true, we will include tests / parts of tests that are known " |
| 30 | "to break in slow execution environments (such as valgrind)."); |
| 31 | DEFINE_bool(automated, false, |
| 32 | "If true, we'll run the automated tests we have in noninteractive " |
| 33 | "mode."); |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 34 | DEFINE_bool(use_acm_version_2, false, |
| 35 | "If true, we'll run the tests with Audio Coding Module version 2."); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 36 | |
| 37 | using namespace webrtc; |
| 38 | |
| 39 | namespace voetest { |
| 40 | |
| 41 | int dummy = 0; // Dummy used in different functions to avoid warnings |
| 42 | |
| 43 | void SubAPIManager::DisplayStatus() const { |
| 44 | TEST_LOG("Supported sub APIs:\n\n"); |
| 45 | if (_base) |
| 46 | TEST_LOG(" Base\n"); |
| 47 | if (_callReport) |
| 48 | TEST_LOG(" CallReport\n"); |
| 49 | if (_codec) |
| 50 | TEST_LOG(" Codec\n"); |
| 51 | if (_dtmf) |
| 52 | TEST_LOG(" Dtmf\n"); |
| 53 | if (_encryption) |
| 54 | TEST_LOG(" Encryption\n"); |
| 55 | if (_externalMedia) |
| 56 | TEST_LOG(" ExternalMedia\n"); |
| 57 | if (_file) |
| 58 | TEST_LOG(" File\n"); |
| 59 | if (_hardware) |
| 60 | TEST_LOG(" Hardware\n"); |
| 61 | if (_netEqStats) |
| 62 | TEST_LOG(" NetEqStats\n"); |
| 63 | if (_network) |
| 64 | TEST_LOG(" Network\n"); |
| 65 | if (_rtp_rtcp) |
| 66 | TEST_LOG(" RTP_RTCP\n"); |
| 67 | if (_videoSync) |
| 68 | TEST_LOG(" VideoSync\n"); |
| 69 | if (_volumeControl) |
| 70 | TEST_LOG(" VolumeControl\n"); |
| 71 | if (_apm) |
| 72 | TEST_LOG(" AudioProcessing\n"); |
| 73 | ANL(); |
| 74 | TEST_LOG("Excluded sub APIs:\n\n"); |
| 75 | if (!_base) |
| 76 | TEST_LOG(" Base\n"); |
| 77 | if (!_callReport) |
| 78 | TEST_LOG(" CallReport\n"); |
| 79 | if (!_codec) |
| 80 | TEST_LOG(" Codec\n"); |
| 81 | if (!_dtmf) |
| 82 | TEST_LOG(" Dtmf\n"); |
| 83 | if (!_encryption) |
| 84 | TEST_LOG(" Encryption\n"); |
| 85 | if (!_externalMedia) |
| 86 | TEST_LOG(" ExternamMedia\n"); |
| 87 | if (!_file) |
| 88 | TEST_LOG(" File\n"); |
| 89 | if (!_hardware) |
| 90 | TEST_LOG(" Hardware\n"); |
| 91 | if (!_netEqStats) |
| 92 | TEST_LOG(" NetEqStats\n"); |
| 93 | if (!_network) |
| 94 | TEST_LOG(" Network\n"); |
| 95 | if (!_rtp_rtcp) |
| 96 | TEST_LOG(" RTP_RTCP\n"); |
| 97 | if (!_videoSync) |
| 98 | TEST_LOG(" VideoSync\n"); |
| 99 | if (!_volumeControl) |
| 100 | TEST_LOG(" VolumeControl\n"); |
| 101 | if (!_apm) |
| 102 | TEST_LOG(" AudioProcessing\n"); |
| 103 | ANL(); |
| 104 | } |
| 105 | |
| 106 | bool SubAPIManager::GetExtendedMenuSelection(ExtendedSelection& sel) { |
| 107 | printf("------------------------------------------------\n"); |
| 108 | printf("Select extended test\n\n"); |
| 109 | printf(" (0) None\n"); |
| 110 | printf("- - - - - - - - - - - - - - - - - - - - - - - - \n"); |
| 111 | printf(" (1) Base"); |
| 112 | if (_base) |
| 113 | printf("\n"); |
| 114 | else |
| 115 | printf(" (NA)\n"); |
| 116 | printf(" (2) CallReport"); |
| 117 | if (_callReport) |
| 118 | printf("\n"); |
| 119 | else |
| 120 | printf(" (NA)\n"); |
| 121 | printf(" (3) Codec"); |
| 122 | if (_codec) |
| 123 | printf("\n"); |
| 124 | else |
| 125 | printf(" (NA)\n"); |
| 126 | printf(" (4) Dtmf"); |
| 127 | if (_dtmf) |
| 128 | printf("\n"); |
| 129 | else |
| 130 | printf(" (NA)\n"); |
| 131 | printf(" (5) Encryption"); |
| 132 | if (_encryption) |
| 133 | printf("\n"); |
| 134 | else |
| 135 | printf(" (NA)\n"); |
| 136 | printf(" (6) VoEExternalMedia"); |
| 137 | if (_externalMedia) |
| 138 | printf("\n"); |
| 139 | else |
| 140 | printf(" (NA)\n"); |
| 141 | printf(" (7) File"); |
| 142 | if (_file) |
| 143 | printf("\n"); |
| 144 | else |
| 145 | printf(" (NA)\n"); |
| 146 | printf(" (8) Hardware"); |
| 147 | if (_hardware) |
| 148 | printf("\n"); |
| 149 | else |
| 150 | printf(" (NA)\n"); |
| 151 | printf(" (9) NetEqStats"); |
| 152 | if (_netEqStats) |
| 153 | printf("\n"); |
| 154 | else |
| 155 | printf(" (NA)\n"); |
| 156 | printf(" (10) Network"); |
| 157 | if (_network) |
| 158 | printf("\n"); |
| 159 | else |
| 160 | printf(" (NA)\n"); |
| 161 | printf(" (11) RTP_RTCP"); |
| 162 | if (_rtp_rtcp) |
| 163 | printf("\n"); |
| 164 | else |
| 165 | printf(" (NA)\n"); |
| 166 | printf(" (12) VideoSync"); |
| 167 | if (_videoSync) |
| 168 | printf("\n"); |
| 169 | else |
| 170 | printf(" (NA)\n"); |
| 171 | printf(" (13) VolumeControl"); |
| 172 | if (_volumeControl) |
| 173 | printf("\n"); |
| 174 | else |
| 175 | printf(" (NA)\n"); |
| 176 | printf("\n: "); |
| 177 | |
| 178 | ExtendedSelection xsel(XSEL_Invalid); |
| 179 | int selection(0); |
| 180 | dummy = scanf("%d", &selection); |
| 181 | |
| 182 | switch (selection) { |
| 183 | case 0: |
| 184 | xsel = XSEL_None; |
| 185 | break; |
| 186 | case 1: |
| 187 | if (_base) |
| 188 | xsel = XSEL_Base; |
| 189 | break; |
| 190 | case 2: |
| 191 | if (_callReport) |
| 192 | xsel = XSEL_CallReport; |
| 193 | break; |
| 194 | case 3: |
| 195 | if (_codec) |
| 196 | xsel = XSEL_Codec; |
| 197 | break; |
| 198 | case 4: |
| 199 | if (_dtmf) |
| 200 | xsel = XSEL_DTMF; |
| 201 | break; |
| 202 | case 5: |
| 203 | if (_encryption) |
| 204 | xsel = XSEL_Encryption; |
| 205 | break; |
| 206 | case 6: |
| 207 | if (_externalMedia) |
| 208 | xsel = XSEL_ExternalMedia; |
| 209 | break; |
| 210 | case 7: |
| 211 | if (_file) |
| 212 | xsel = XSEL_File; |
| 213 | break; |
| 214 | case 8: |
| 215 | if (_hardware) |
| 216 | xsel = XSEL_Hardware; |
| 217 | break; |
| 218 | case 9: |
| 219 | if (_netEqStats) |
| 220 | xsel = XSEL_NetEqStats; |
| 221 | break; |
| 222 | case 10: |
| 223 | if (_network) |
| 224 | xsel = XSEL_Network; |
| 225 | break; |
| 226 | case 11: |
| 227 | if (_rtp_rtcp) |
| 228 | xsel = XSEL_RTP_RTCP; |
| 229 | break; |
| 230 | case 12: |
| 231 | if (_videoSync) |
| 232 | xsel = XSEL_VideoSync; |
| 233 | break; |
| 234 | case 13: |
| 235 | if (_volumeControl) |
| 236 | xsel = XSEL_VolumeControl; |
| 237 | break; |
| 238 | default: |
| 239 | xsel = XSEL_Invalid; |
| 240 | break; |
| 241 | } |
| 242 | if (xsel == XSEL_Invalid) |
| 243 | printf("Invalid selection!\n"); |
| 244 | |
| 245 | sel = xsel; |
| 246 | _xsel = xsel; |
| 247 | |
| 248 | return (xsel != XSEL_Invalid); |
| 249 | } |
| 250 | |
| 251 | VoETestManager::VoETestManager() |
| 252 | : initialized_(false), |
| 253 | voice_engine_(NULL), |
| 254 | voe_base_(0), |
| 255 | voe_call_report_(0), |
| 256 | voe_codec_(0), |
| 257 | voe_dtmf_(0), |
| 258 | voe_encrypt_(0), |
| 259 | voe_xmedia_(0), |
| 260 | voe_file_(0), |
| 261 | voe_hardware_(0), |
| 262 | voe_network_(0), |
pbos@webrtc.org | 8510750 | 2013-05-21 11:25:12 +0000 | [diff] [blame] | 263 | #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 264 | voe_neteq_stats_(NULL), |
| 265 | #endif |
| 266 | voe_rtp_rtcp_(0), |
| 267 | voe_vsync_(0), |
| 268 | voe_volume_control_(0), |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 269 | voe_apm_(0) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | VoETestManager::~VoETestManager() { |
| 273 | } |
| 274 | |
| 275 | bool VoETestManager::Init() { |
| 276 | if (initialized_) |
| 277 | return true; |
| 278 | |
| 279 | if (VoiceEngine::SetTraceFile(NULL) != -1) { |
| 280 | // should not be possible to call a Trace method before the VoE is |
| 281 | // created |
| 282 | TEST_LOG("\nError at line: %i (VoiceEngine::SetTraceFile()" |
| 283 | "should fail)!\n", __LINE__); |
| 284 | return false; |
| 285 | } |
| 286 | |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 287 | // TODO(minyue): Remove when the old ACM is removed (latest 2014-04-01). |
| 288 | config_.Set<AudioCodingModuleFactory>(FLAGS_use_acm_version_2 ? |
| 289 | new NewAudioCodingModuleFactory() : |
| 290 | new AudioCodingModuleFactory()); |
| 291 | voice_engine_ = VoiceEngine::Create(config_); |
| 292 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 293 | if (!voice_engine_) { |
| 294 | TEST_LOG("Failed to create VoiceEngine\n"); |
| 295 | return false; |
| 296 | } |
| 297 | |
| 298 | return true; |
| 299 | } |
| 300 | |
| 301 | void VoETestManager::GetInterfaces() { |
| 302 | if (voice_engine_) { |
| 303 | voe_base_ = VoEBase::GetInterface(voice_engine_); |
| 304 | voe_codec_ = VoECodec::GetInterface(voice_engine_); |
| 305 | voe_volume_control_ = VoEVolumeControl::GetInterface(voice_engine_); |
| 306 | voe_dtmf_ = VoEDtmf::GetInterface(voice_engine_); |
| 307 | voe_rtp_rtcp_ = VoERTP_RTCP::GetInterface(voice_engine_); |
| 308 | voe_apm_ = VoEAudioProcessing::GetInterface(voice_engine_); |
| 309 | voe_network_ = VoENetwork::GetInterface(voice_engine_); |
| 310 | voe_file_ = VoEFile::GetInterface(voice_engine_); |
| 311 | #ifdef _TEST_VIDEO_SYNC_ |
| 312 | voe_vsync_ = VoEVideoSync::GetInterface(voice_engine_); |
| 313 | #endif |
| 314 | voe_encrypt_ = VoEEncryption::GetInterface(voice_engine_); |
| 315 | voe_hardware_ = VoEHardware::GetInterface(voice_engine_); |
| 316 | // Set the audio layer to use in all tests |
| 317 | if (voe_hardware_) { |
| 318 | int res = voe_hardware_->SetAudioDeviceLayer(TESTED_AUDIO_LAYER); |
| 319 | if (res < 0) { |
| 320 | printf("\nERROR: failed to set audio layer to use in " |
| 321 | "testing\n"); |
| 322 | } else { |
| 323 | printf("\nAudio layer %d will be used in testing\n", |
| 324 | TESTED_AUDIO_LAYER); |
| 325 | } |
| 326 | } |
| 327 | #ifdef _TEST_XMEDIA_ |
| 328 | voe_xmedia_ = VoEExternalMedia::GetInterface(voice_engine_); |
| 329 | #endif |
| 330 | #ifdef _TEST_CALL_REPORT_ |
| 331 | voe_call_report_ = VoECallReport::GetInterface(voice_engine_); |
| 332 | #endif |
pbos@webrtc.org | 8510750 | 2013-05-21 11:25:12 +0000 | [diff] [blame] | 333 | #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 334 | voe_neteq_stats_ = VoENetEqStats::GetInterface(voice_engine_); |
| 335 | #endif |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | int VoETestManager::ReleaseInterfaces() { |
| 340 | bool releaseOK(true); |
| 341 | |
| 342 | if (voe_base_) { |
| 343 | voe_base_->Release(); |
| 344 | voe_base_ = NULL; |
| 345 | } |
| 346 | if (voe_codec_) { |
| 347 | voe_codec_->Release(); |
| 348 | voe_codec_ = NULL; |
| 349 | } |
| 350 | if (voe_volume_control_) { |
| 351 | voe_volume_control_->Release(); |
| 352 | voe_volume_control_ = NULL; |
| 353 | } |
| 354 | if (voe_dtmf_) { |
| 355 | voe_dtmf_->Release(); |
| 356 | voe_dtmf_ = NULL; |
| 357 | } |
| 358 | if (voe_rtp_rtcp_) { |
| 359 | voe_rtp_rtcp_->Release(); |
| 360 | voe_rtp_rtcp_ = NULL; |
| 361 | } |
| 362 | if (voe_apm_) { |
| 363 | voe_apm_->Release(); |
| 364 | voe_apm_ = NULL; |
| 365 | } |
| 366 | if (voe_network_) { |
| 367 | voe_network_->Release(); |
| 368 | voe_network_ = NULL; |
| 369 | } |
| 370 | if (voe_file_) { |
| 371 | voe_file_->Release(); |
| 372 | voe_file_ = NULL; |
| 373 | } |
| 374 | #ifdef _TEST_VIDEO_SYNC_ |
| 375 | if (voe_vsync_) { |
| 376 | voe_vsync_->Release(); |
| 377 | voe_vsync_ = NULL; |
| 378 | } |
| 379 | #endif |
| 380 | if (voe_encrypt_) { |
| 381 | voe_encrypt_->Release(); |
| 382 | voe_encrypt_ = NULL; |
| 383 | } |
| 384 | if (voe_hardware_) { |
| 385 | voe_hardware_->Release(); |
| 386 | voe_hardware_ = NULL; |
| 387 | } |
| 388 | #ifdef _TEST_XMEDIA_ |
| 389 | if (voe_xmedia_) { |
| 390 | voe_xmedia_->Release(); |
| 391 | voe_xmedia_ = NULL; |
| 392 | } |
| 393 | #endif |
| 394 | #ifdef _TEST_CALL_REPORT_ |
| 395 | if (voe_call_report_) { |
| 396 | voe_call_report_->Release(); |
| 397 | voe_call_report_ = NULL; |
| 398 | } |
| 399 | #endif |
pbos@webrtc.org | 8510750 | 2013-05-21 11:25:12 +0000 | [diff] [blame] | 400 | #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 401 | if (voe_neteq_stats_) { |
| 402 | voe_neteq_stats_->Release(); |
| 403 | voe_neteq_stats_ = NULL; |
| 404 | } |
| 405 | #endif |
| 406 | if (false == VoiceEngine::Delete(voice_engine_)) { |
| 407 | TEST_LOG("\n\nVoiceEngine::Delete() failed. \n"); |
| 408 | releaseOK = false; |
| 409 | } |
| 410 | |
| 411 | if (VoiceEngine::SetTraceFile(NULL) != -1) { |
| 412 | TEST_LOG("\nError at line: %i (VoiceEngine::SetTraceFile()" |
| 413 | "should fail)!\n", __LINE__); |
| 414 | } |
| 415 | |
| 416 | return (releaseOK == true) ? 0 : -1; |
| 417 | } |
| 418 | |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 419 | int run_auto_test(TestType test_type, |
| 420 | ExtendedSelection ext_selection) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 421 | assert(test_type != Standard); |
| 422 | |
| 423 | SubAPIManager api_manager; |
| 424 | api_manager.DisplayStatus(); |
| 425 | |
| 426 | //////////////////////////////////// |
| 427 | // Create VoiceEngine and sub API:s |
| 428 | |
| 429 | voetest::VoETestManager test_manager; |
| 430 | if (!test_manager.Init()) { |
| 431 | return -1; |
| 432 | } |
| 433 | test_manager.GetInterfaces(); |
| 434 | |
| 435 | int result(-1); |
| 436 | if (test_type == Extended) { |
| 437 | VoEExtendedTest xtend(test_manager); |
| 438 | |
| 439 | result = 0; |
| 440 | while (ext_selection != XSEL_None) { |
| 441 | if (ext_selection == XSEL_Base || ext_selection == XSEL_All) { |
| 442 | if ((result = xtend.TestBase()) == -1) |
| 443 | break; |
| 444 | xtend.TestPassed("Base"); |
| 445 | } |
| 446 | if (ext_selection == XSEL_CallReport || ext_selection == XSEL_All) { |
| 447 | if ((result = xtend.TestCallReport()) == -1) |
| 448 | break; |
| 449 | xtend.TestPassed("CallReport"); |
| 450 | } |
| 451 | if (ext_selection == XSEL_Codec || ext_selection == XSEL_All) { |
| 452 | if ((result = xtend.TestCodec()) == -1) |
| 453 | break; |
| 454 | xtend.TestPassed("Codec"); |
| 455 | } |
| 456 | if (ext_selection == XSEL_DTMF || ext_selection == XSEL_All) { |
| 457 | if ((result = xtend.TestDtmf()) == -1) |
| 458 | break; |
| 459 | xtend.TestPassed("Dtmf"); |
| 460 | } |
| 461 | if (ext_selection == XSEL_Encryption || ext_selection == XSEL_All) { |
| 462 | if ((result = xtend.TestEncryption()) == -1) |
| 463 | break; |
| 464 | xtend.TestPassed("Encryption"); |
| 465 | } |
| 466 | if (ext_selection == XSEL_ExternalMedia || ext_selection == XSEL_All) { |
| 467 | if ((result = xtend.TestExternalMedia()) == -1) |
| 468 | break; |
| 469 | xtend.TestPassed("ExternalMedia"); |
| 470 | } |
| 471 | if (ext_selection == XSEL_File || ext_selection == XSEL_All) { |
| 472 | if ((result = xtend.TestFile()) == -1) |
| 473 | break; |
| 474 | xtend.TestPassed("File"); |
| 475 | } |
| 476 | if (ext_selection == XSEL_Hardware || ext_selection == XSEL_All) { |
| 477 | if ((result = xtend.TestHardware()) == -1) |
| 478 | break; |
| 479 | xtend.TestPassed("Hardware"); |
| 480 | } |
| 481 | if (ext_selection == XSEL_NetEqStats || ext_selection == XSEL_All) { |
| 482 | if ((result = xtend.TestNetEqStats()) == -1) |
| 483 | break; |
| 484 | xtend.TestPassed("NetEqStats"); |
| 485 | } |
| 486 | if (ext_selection == XSEL_Network || ext_selection == XSEL_All) { |
| 487 | if ((result = xtend.TestNetwork()) == -1) |
| 488 | break; |
| 489 | xtend.TestPassed("Network"); |
| 490 | } |
| 491 | if (ext_selection == XSEL_RTP_RTCP || ext_selection == XSEL_All) { |
| 492 | if ((result = xtend.TestRTP_RTCP()) == -1) |
| 493 | break; |
| 494 | xtend.TestPassed("RTP_RTCP"); |
| 495 | } |
| 496 | if (ext_selection == XSEL_VideoSync || ext_selection == XSEL_All) { |
| 497 | if ((result = xtend.TestVideoSync()) == -1) |
| 498 | break; |
| 499 | xtend.TestPassed("VideoSync"); |
| 500 | } |
| 501 | if (ext_selection == XSEL_VolumeControl || ext_selection == XSEL_All) { |
| 502 | if ((result = xtend.TestVolumeControl()) == -1) |
| 503 | break; |
| 504 | xtend.TestPassed("VolumeControl"); |
| 505 | } |
| 506 | api_manager.GetExtendedMenuSelection(ext_selection); |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 507 | } // while (extendedSel != XSEL_None) |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 508 | } else if (test_type == Stress) { |
| 509 | VoEStressTest stressTest(test_manager); |
| 510 | result = stressTest.DoTest(); |
| 511 | } else if (test_type == Unit) { |
| 512 | VoEUnitTest unitTest(test_manager); |
| 513 | result = unitTest.DoTest(); |
| 514 | } else if (test_type == CPU) { |
| 515 | VoECpuTest cpuTest(test_manager); |
| 516 | result = cpuTest.DoTest(); |
| 517 | } else { |
| 518 | // Should never end up here |
| 519 | assert(false); |
| 520 | } |
| 521 | |
| 522 | ////////////////// |
| 523 | // Release/Delete |
| 524 | |
| 525 | int release_ok = test_manager.ReleaseInterfaces(); |
| 526 | |
| 527 | if ((0 == result) && (release_ok != -1)) { |
| 528 | TEST_LOG("\n\n*** All tests passed *** \n\n"); |
| 529 | } else { |
| 530 | TEST_LOG("\n\n*** Test failed! *** \n"); |
| 531 | } |
| 532 | |
| 533 | return 0; |
| 534 | } |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 535 | } // namespace voetest |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 536 | |
| 537 | int RunInManualMode() { |
| 538 | using namespace voetest; |
| 539 | |
| 540 | SubAPIManager api_manager; |
| 541 | api_manager.DisplayStatus(); |
| 542 | |
| 543 | printf("----------------------------\n"); |
| 544 | printf("Select type of test\n\n"); |
| 545 | printf(" (0) Quit\n"); |
| 546 | printf(" (1) Standard test\n"); |
| 547 | printf(" (2) Extended test(s)...\n"); |
| 548 | printf(" (3) Stress test(s)...\n"); |
| 549 | printf(" (4) Unit test(s)...\n"); |
| 550 | printf(" (5) CPU & memory reference test [Windows]...\n"); |
| 551 | printf("\n: "); |
| 552 | |
| 553 | int selection(0); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 554 | dummy = scanf("%d", &selection); |
| 555 | |
| 556 | ExtendedSelection ext_selection = XSEL_Invalid; |
| 557 | TestType test_type = Invalid; |
| 558 | |
| 559 | switch (selection) { |
| 560 | case 0: |
| 561 | return 0; |
| 562 | case 1: |
| 563 | test_type = Standard; |
| 564 | break; |
| 565 | case 2: |
| 566 | test_type = Extended; |
| 567 | while (!api_manager.GetExtendedMenuSelection(ext_selection)) |
| 568 | continue; |
| 569 | break; |
| 570 | case 3: |
| 571 | test_type = Stress; |
| 572 | break; |
| 573 | case 4: |
| 574 | test_type = Unit; |
| 575 | break; |
| 576 | case 5: |
| 577 | test_type = CPU; |
| 578 | break; |
| 579 | default: |
| 580 | TEST_LOG("Invalid selection!\n"); |
| 581 | return 0; |
| 582 | } |
| 583 | |
| 584 | if (test_type == Standard) { |
| 585 | TEST_LOG("\n\n+++ Running standard tests +++\n\n"); |
| 586 | |
| 587 | // Currently, all googletest-rewritten tests are in the "automated" suite. |
| 588 | return RunInAutomatedMode(); |
| 589 | } |
| 590 | |
| 591 | // Function that can be called from other entry functions. |
| 592 | return run_auto_test(test_type, ext_selection); |
| 593 | } |
| 594 | |
| 595 | // ---------------------------------------------------------------------------- |
| 596 | // main |
| 597 | // ---------------------------------------------------------------------------- |
| 598 | |
| 599 | #if !defined(WEBRTC_IOS) |
| 600 | int main(int argc, char** argv) { |
| 601 | // This function and RunInAutomatedMode is defined in automated_mode.cc |
| 602 | // to avoid macro clashes with googletest (for instance ASSERT_TRUE). |
| 603 | InitializeGoogleTest(&argc, argv); |
| 604 | google::ParseCommandLineFlags(&argc, &argv, true); |
| 605 | |
| 606 | if (FLAGS_automated) { |
| 607 | return RunInAutomatedMode(); |
| 608 | } |
| 609 | |
| 610 | return RunInManualMode(); |
| 611 | } |
| 612 | #endif //#if !defined(WEBRTC_IOS) |