blob: 0ddb948db41c709be8420bf5742c7253d1186746 [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
27_VIE_AUTO_TEST_CMD_LIST = [
28 'vie_auto_test',
29 '--automated',
30 '--gtest_filter=-ViERtpFuzzTest*',
31 '--capture_test_ensure_resolution_alignment_in_capture_device=false']
32_WIN_TESTS = {
33 'vie_auto_test': _VIE_AUTO_TEST_CMD_LIST,
34 'voe_auto_test': ['voe_auto_test',
35 '--automated'],
36}
37_MAC_TESTS = {
38 'vie_auto_test': _VIE_AUTO_TEST_CMD_LIST,
39 'voe_auto_test': ['voe_auto_test',
40 '--automated',
41 ('--gtest_filter='
42 '-VolumeTest.SetVolumeBeforePlayoutWorks' # bug 527
43 )],
44}
45_LINUX_TESTS = {
46 'vie_auto_test': _VIE_AUTO_TEST_CMD_LIST,
47 'voe_auto_test': ['voe_auto_test',
48 '--automated',
49 '--gtest_filter=-RtpFuzzTest.*'],
50 'audio_e2e_test': ['python',
51 'run_audio_test.py',
52 '--input=e2e_audio_in.pcm',
53 '--output=/tmp/e2e_audio_out.pcm',
54 '--codec=L16',
55 '--compare="~/bin/compare-audio +16000 +wb"',
56 r'--regexp="(\d\.\d{3})"'],
57 'audioproc_perf': ['audioproc',
58 '-aecm', '-ns', '-agc', '--fixed_digital', '--perf',
59 '-pb', '../../resources/audioproc.aecdump'],
60 'isac_fixed_perf': ['iSACFixtest',
61 '32000', '../../resources/speech_and_misc_wb.pcm',
62 'isac_speech_and_misc_wb.pcm'],
63}
64_CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
65
66
67def main():
68 parser = optparse.OptionParser('usage: %prog -t <test> [-t <test> ...]\n'
69 'If no test is specified, all tests are run.')
70 parser.add_option('-l', '--list', action='store_true', default=False,
71 help='Lists all currently supported tests.')
72 parser.add_option('-t', '--test', action='append', default=[],
73 help='Which test to run. May be specified multiple times.')
74 options, unused_args = parser.parse_args()
75
76 if sys.platform.startswith('win'):
77 test_dict = _WIN_TESTS
78 elif sys.platform.startswith('linux'):
79 test_dict = _LINUX_TESTS
80 elif sys.platform.startswith('darwin'):
81 test_dict = _MAC_TESTS
82 else:
83 parser.error('Unsupported platform: %s' % sys.platform)
84
85 if options.list:
86 print 'Available tests:'
87 print 'Test name Command line'
88 print '========= ============'
89 for test, cmd_line in test_dict.items():
90 print '%-20s %s' % (test, ' '.join(cmd_line))
91 return
92
93 if not options.test:
94 options.test = test_dict.keys()
95 for test in options.test:
96 if test not in test_dict:
97 parser.error('Test "%s" is not supported (use --list to view supported '
98 'tests).')
99
100 print 'Running WebRTC Buildbot tests: %s' % options.test
101 for test in options.test:
102 cmd_line = test_dict[test]
103
104 # Create absolute paths to test executables for non-Python tests.
105 if cmd_line[0] != 'python':
106 cmd_line[0] = os.path.join(_CURRENT_DIR, cmd_line[0])
107
108 print 'Running: %s' % ' '.join(cmd_line)
109 try:
110 subprocess.check_call(cmd_line)
111 except subprocess.CalledProcessError as e:
112 print >> sys.stderr, ('An error occurred during test execution: return '
113 'code: %d' % e.returncode)
114 return -1
115
116 print 'Testing completed successfully.'
117 return 0
118
119
120if __name__ == '__main__':
121 sys.exit(main())