blob: a8d8e71cf49e0140826f7aec903b0fbd0b25386e [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',
kjellander@webrtc.orgacb75d62013-01-28 21:19:56 +000052 '--input=../../resources/e2e_audio_in.pcm',
kjellander@webrtc.org58598d62013-01-25 10:10:53 +000053 '--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
kjellander@webrtc.orgacb75d62013-01-28 21:19:56 +0000100 # Change current working directory to the script's dir to make the relative
101 # paths always work.
102 os.chdir(_CURRENT_DIR)
103 print 'Changed working directory to: %s' % _CURRENT_DIR
104
kjellander@webrtc.org58598d62013-01-25 10:10:53 +0000105 print 'Running WebRTC Buildbot tests: %s' % options.test
106 for test in options.test:
107 cmd_line = test_dict[test]
108
109 # Create absolute paths to test executables for non-Python tests.
110 if cmd_line[0] != 'python':
111 cmd_line[0] = os.path.join(_CURRENT_DIR, cmd_line[0])
112
113 print 'Running: %s' % ' '.join(cmd_line)
114 try:
115 subprocess.check_call(cmd_line)
116 except subprocess.CalledProcessError as e:
117 print >> sys.stderr, ('An error occurred during test execution: return '
118 'code: %d' % e.returncode)
119 return -1
120
121 print 'Testing completed successfully.'
122 return 0
123
124
125if __name__ == '__main__':
126 sys.exit(main())