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