kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license |
| 6 | # that can be found in the LICENSE file in the root of the source |
| 7 | # tree. An additional intellectual property rights grant can be found |
| 8 | # in the file PATENTS. All contributing project authors may |
| 9 | # be found in the AUTHORS file in the root of the source tree. |
| 10 | |
| 11 | |
| 12 | """Script to run tests with pre-configured command line arguments. |
| 13 | |
| 14 | NOTICE: This test is designed to be run from the build output folder! It is |
| 15 | copied automatically during build. |
| 16 | |
| 17 | With this script, it's easier for anyone to enable/disable or extend a test that |
| 18 | runs on the buildbots. It is also easier for developers to run the tests in the |
| 19 | same way as they run on the bots. |
| 20 | """ |
| 21 | |
| 22 | import optparse |
| 23 | import os |
| 24 | import subprocess |
| 25 | import sys |
| 26 | |
kjellander@webrtc.org | 0fb937a | 2013-01-30 21:39:10 +0000 | [diff] [blame] | 27 | _CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) |
| 28 | _HOME = os.environ.get('HOME', '') |
| 29 | |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 30 | _VIE_AUTO_TEST_CMD_LIST = [ |
| 31 | 'vie_auto_test', |
| 32 | '--automated', |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 33 | '--capture_test_ensure_resolution_alignment_in_capture_device=false'] |
| 34 | _WIN_TESTS = { |
| 35 | 'vie_auto_test': _VIE_AUTO_TEST_CMD_LIST, |
| 36 | 'voe_auto_test': ['voe_auto_test', |
| 37 | '--automated'], |
| 38 | } |
| 39 | _MAC_TESTS = { |
kjellander@webrtc.org | 3bd659f | 2013-09-24 13:41:16 +0000 | [diff] [blame] | 40 | 'libjingle_peerconnection_objc_test': [ |
| 41 | ('libjingle_peerconnection_objc_test.app/Contents/MacOS/' |
| 42 | 'libjingle_peerconnection_objc_test')], |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 43 | 'vie_auto_test': _VIE_AUTO_TEST_CMD_LIST, |
| 44 | 'voe_auto_test': ['voe_auto_test', |
| 45 | '--automated', |
| 46 | ('--gtest_filter=' |
| 47 | '-VolumeTest.SetVolumeBeforePlayoutWorks' # bug 527 |
| 48 | )], |
| 49 | } |
| 50 | _LINUX_TESTS = { |
| 51 | 'vie_auto_test': _VIE_AUTO_TEST_CMD_LIST, |
| 52 | 'voe_auto_test': ['voe_auto_test', |
solenberg@webrtc.org | a56c5b4 | 2014-02-18 11:27:22 +0000 | [diff] [blame] | 53 | '--automated'], |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 54 | 'audio_e2e_test': ['python', |
| 55 | 'run_audio_test.py', |
kjellander@webrtc.org | acb75d6 | 2013-01-28 21:19:56 +0000 | [diff] [blame] | 56 | '--input=../../resources/e2e_audio_in.pcm', |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 57 | '--output=/tmp/e2e_audio_out.pcm', |
| 58 | '--codec=L16', |
kjellander@webrtc.org | 0fb937a | 2013-01-30 21:39:10 +0000 | [diff] [blame] | 59 | '--harness=%s/audio_e2e_harness' % _CURRENT_DIR, |
| 60 | '--compare=%s/bin/compare-audio +16000 +wb' % _HOME, |
| 61 | '--regexp=(\d\.\d{3})'], |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 62 | 'audioproc_perf': ['audioproc', |
| 63 | '-aecm', '-ns', '-agc', '--fixed_digital', '--perf', |
| 64 | '-pb', '../../resources/audioproc.aecdump'], |
| 65 | 'isac_fixed_perf': ['iSACFixtest', |
| 66 | '32000', '../../resources/speech_and_misc_wb.pcm', |
| 67 | 'isac_speech_and_misc_wb.pcm'], |
phoglund@webrtc.org | 87ae00a | 2013-07-31 10:50:30 +0000 | [diff] [blame] | 68 | 'libjingle_peerconnection_java_unittest': [ |
| 69 | 'libjingle_peerconnection_java_unittest'], |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 70 | } |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 71 | |
phoglund@webrtc.org | 87ae00a | 2013-07-31 10:50:30 +0000 | [diff] [blame] | 72 | _CUSTOM_ENV = { |
| 73 | 'libjingle_peerconnection_java_unittest': |
| 74 | {'LD_PRELOAD': '/usr/lib/x86_64-linux-gnu/libpulse.so.0'}, |
| 75 | } |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 76 | |
| 77 | def main(): |
| 78 | parser = optparse.OptionParser('usage: %prog -t <test> [-t <test> ...]\n' |
| 79 | 'If no test is specified, all tests are run.') |
| 80 | parser.add_option('-l', '--list', action='store_true', default=False, |
| 81 | help='Lists all currently supported tests.') |
| 82 | parser.add_option('-t', '--test', action='append', default=[], |
| 83 | help='Which test to run. May be specified multiple times.') |
phoglund@webrtc.org | 2ce235e | 2013-03-07 09:59:43 +0000 | [diff] [blame] | 84 | options, _ = parser.parse_args() |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 85 | |
| 86 | if sys.platform.startswith('win'): |
| 87 | test_dict = _WIN_TESTS |
| 88 | elif sys.platform.startswith('linux'): |
| 89 | test_dict = _LINUX_TESTS |
| 90 | elif sys.platform.startswith('darwin'): |
| 91 | test_dict = _MAC_TESTS |
| 92 | else: |
| 93 | parser.error('Unsupported platform: %s' % sys.platform) |
| 94 | |
| 95 | if options.list: |
| 96 | print 'Available tests:' |
| 97 | print 'Test name Command line' |
| 98 | print '========= ============' |
| 99 | for test, cmd_line in test_dict.items(): |
| 100 | print '%-20s %s' % (test, ' '.join(cmd_line)) |
| 101 | return |
| 102 | |
| 103 | if not options.test: |
| 104 | options.test = test_dict.keys() |
| 105 | for test in options.test: |
| 106 | if test not in test_dict: |
| 107 | parser.error('Test "%s" is not supported (use --list to view supported ' |
| 108 | 'tests).') |
| 109 | |
kjellander@webrtc.org | acb75d6 | 2013-01-28 21:19:56 +0000 | [diff] [blame] | 110 | # Change current working directory to the script's dir to make the relative |
| 111 | # paths always work. |
| 112 | os.chdir(_CURRENT_DIR) |
| 113 | print 'Changed working directory to: %s' % _CURRENT_DIR |
| 114 | |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 115 | print 'Running WebRTC Buildbot tests: %s' % options.test |
| 116 | for test in options.test: |
| 117 | cmd_line = test_dict[test] |
phoglund@webrtc.org | 87ae00a | 2013-07-31 10:50:30 +0000 | [diff] [blame] | 118 | env = os.environ.copy() |
| 119 | if test in _CUSTOM_ENV: |
| 120 | env.update(_CUSTOM_ENV[test]) |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 121 | |
| 122 | # Create absolute paths to test executables for non-Python tests. |
| 123 | if cmd_line[0] != 'python': |
| 124 | cmd_line[0] = os.path.join(_CURRENT_DIR, cmd_line[0]) |
| 125 | |
| 126 | print 'Running: %s' % ' '.join(cmd_line) |
| 127 | try: |
phoglund@webrtc.org | 87ae00a | 2013-07-31 10:50:30 +0000 | [diff] [blame] | 128 | subprocess.check_call(cmd_line, env=env) |
kjellander@webrtc.org | 58598d6 | 2013-01-25 10:10:53 +0000 | [diff] [blame] | 129 | except subprocess.CalledProcessError as e: |
| 130 | print >> sys.stderr, ('An error occurred during test execution: return ' |
| 131 | 'code: %d' % e.returncode) |
| 132 | return -1 |
| 133 | |
| 134 | print 'Testing completed successfully.' |
| 135 | return 0 |
| 136 | |
| 137 | |
| 138 | if __name__ == '__main__': |
| 139 | sys.exit(main()) |