blob: 280bb533c94542a1f44eca6c4bb4da7ac6decd4e [file] [log] [blame]
kjellander@webrtc.org58598d62013-01-25 10:10:53 +00001#!/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
14NOTICE: This test is designed to be run from the build output folder! It is
15copied automatically during build.
16
17With this script, it's easier for anyone to enable/disable or extend a test that
18runs on the buildbots. It is also easier for developers to run the tests in the
19same way as they run on the bots.
20"""
21
22import optparse
23import os
24import subprocess
25import sys
26
kjellander@webrtc.org0fb937a2013-01-30 21:39:10 +000027_CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
28_HOME = os.environ.get('HOME', '')
29
kjellander@webrtc.org58598d62013-01-25 10:10:53 +000030_VIE_AUTO_TEST_CMD_LIST = [
31 'vie_auto_test',
32 '--automated',
33 '--gtest_filter=-ViERtpFuzzTest*',
34 '--capture_test_ensure_resolution_alignment_in_capture_device=false']
35_WIN_TESTS = {
36 'vie_auto_test': _VIE_AUTO_TEST_CMD_LIST,
37 'voe_auto_test': ['voe_auto_test',
38 '--automated'],
39}
40_MAC_TESTS = {
41 'vie_auto_test': _VIE_AUTO_TEST_CMD_LIST,
42 'voe_auto_test': ['voe_auto_test',
43 '--automated',
44 ('--gtest_filter='
45 '-VolumeTest.SetVolumeBeforePlayoutWorks' # bug 527
46 )],
47}
48_LINUX_TESTS = {
49 'vie_auto_test': _VIE_AUTO_TEST_CMD_LIST,
50 'voe_auto_test': ['voe_auto_test',
51 '--automated',
52 '--gtest_filter=-RtpFuzzTest.*'],
53 'audio_e2e_test': ['python',
54 'run_audio_test.py',
kjellander@webrtc.orgacb75d62013-01-28 21:19:56 +000055 '--input=../../resources/e2e_audio_in.pcm',
kjellander@webrtc.org58598d62013-01-25 10:10:53 +000056 '--output=/tmp/e2e_audio_out.pcm',
57 '--codec=L16',
kjellander@webrtc.org0fb937a2013-01-30 21:39:10 +000058 '--harness=%s/audio_e2e_harness' % _CURRENT_DIR,
59 '--compare=%s/bin/compare-audio +16000 +wb' % _HOME,
60 '--regexp=(\d\.\d{3})'],
kjellander@webrtc.org58598d62013-01-25 10:10:53 +000061 'audioproc_perf': ['audioproc',
62 '-aecm', '-ns', '-agc', '--fixed_digital', '--perf',
63 '-pb', '../../resources/audioproc.aecdump'],
64 'isac_fixed_perf': ['iSACFixtest',
65 '32000', '../../resources/speech_and_misc_wb.pcm',
66 'isac_speech_and_misc_wb.pcm'],
phoglund@webrtc.org87ae00a2013-07-31 10:50:30 +000067 'libjingle_peerconnection_java_unittest': [
68 'libjingle_peerconnection_java_unittest'],
kjellander@webrtc.org58598d62013-01-25 10:10:53 +000069}
kjellander@webrtc.org58598d62013-01-25 10:10:53 +000070
phoglund@webrtc.org87ae00a2013-07-31 10:50:30 +000071_CUSTOM_ENV = {
72 'libjingle_peerconnection_java_unittest':
73 {'LD_PRELOAD': '/usr/lib/x86_64-linux-gnu/libpulse.so.0'},
74}
kjellander@webrtc.org58598d62013-01-25 10:10:53 +000075
76def main():
77 parser = optparse.OptionParser('usage: %prog -t <test> [-t <test> ...]\n'
78 'If no test is specified, all tests are run.')
79 parser.add_option('-l', '--list', action='store_true', default=False,
80 help='Lists all currently supported tests.')
81 parser.add_option('-t', '--test', action='append', default=[],
82 help='Which test to run. May be specified multiple times.')
phoglund@webrtc.org2ce235e2013-03-07 09:59:43 +000083 options, _ = parser.parse_args()
kjellander@webrtc.org58598d62013-01-25 10:10:53 +000084
85 if sys.platform.startswith('win'):
86 test_dict = _WIN_TESTS
87 elif sys.platform.startswith('linux'):
88 test_dict = _LINUX_TESTS
89 elif sys.platform.startswith('darwin'):
90 test_dict = _MAC_TESTS
91 else:
92 parser.error('Unsupported platform: %s' % sys.platform)
93
94 if options.list:
95 print 'Available tests:'
96 print 'Test name Command line'
97 print '========= ============'
98 for test, cmd_line in test_dict.items():
99 print '%-20s %s' % (test, ' '.join(cmd_line))
100 return
101
102 if not options.test:
103 options.test = test_dict.keys()
104 for test in options.test:
105 if test not in test_dict:
106 parser.error('Test "%s" is not supported (use --list to view supported '
107 'tests).')
108
kjellander@webrtc.orgacb75d62013-01-28 21:19:56 +0000109 # Change current working directory to the script's dir to make the relative
110 # paths always work.
111 os.chdir(_CURRENT_DIR)
112 print 'Changed working directory to: %s' % _CURRENT_DIR
113
kjellander@webrtc.org58598d62013-01-25 10:10:53 +0000114 print 'Running WebRTC Buildbot tests: %s' % options.test
115 for test in options.test:
116 cmd_line = test_dict[test]
phoglund@webrtc.org87ae00a2013-07-31 10:50:30 +0000117 env = os.environ.copy()
118 if test in _CUSTOM_ENV:
119 env.update(_CUSTOM_ENV[test])
kjellander@webrtc.org58598d62013-01-25 10:10:53 +0000120
121 # Create absolute paths to test executables for non-Python tests.
122 if cmd_line[0] != 'python':
123 cmd_line[0] = os.path.join(_CURRENT_DIR, cmd_line[0])
124
125 print 'Running: %s' % ' '.join(cmd_line)
126 try:
phoglund@webrtc.org87ae00a2013-07-31 10:50:30 +0000127 subprocess.check_call(cmd_line, env=env)
kjellander@webrtc.org58598d62013-01-25 10:10:53 +0000128 except subprocess.CalledProcessError as e:
129 print >> sys.stderr, ('An error occurred during test execution: return '
130 'code: %d' % e.returncode)
131 return -1
132
133 print 'Testing completed successfully.'
134 return 0
135
136
137if __name__ == '__main__':
138 sys.exit(main())