kjellander@webrtc.org | b5b155b | 2011-12-20 08:53:41 +0000 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2011 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 | ''' Runs various WebRTC tests through valgrind_test.py. |
| 11 | |
| 12 | This script inherits the chrome_tests.py in Chrome, replacing its tests with |
| 13 | our own in WebRTC instead. |
| 14 | ''' |
| 15 | |
| 16 | import optparse |
| 17 | import sys |
| 18 | |
| 19 | import logging_utils |
| 20 | |
| 21 | import chrome_tests |
| 22 | |
| 23 | class WebRTCTests(chrome_tests.ChromeTests): |
| 24 | # WebRTC tests, similar functions for each tests as the Chrome tests in the |
| 25 | # parent class. |
| 26 | def TestSignalProcessing(self): |
| 27 | return self.SimpleTest("signal_processing", "signal_processing_unittests") |
| 28 | |
| 29 | def TestResampler(self): |
| 30 | return self.SimpleTest("resampler", "resampler_unittests") |
| 31 | |
| 32 | def TestVAD(self): |
| 33 | return self.SimpleTest("vad", "vad_unittests") |
| 34 | |
| 35 | def TestCNG(self): |
| 36 | return self.SimpleTest("cng", "cng_unittests") |
| 37 | |
| 38 | def TestG711(self): |
| 39 | return self.SimpleTest("g711", "g711_unittests") |
| 40 | |
| 41 | def TestG722(self): |
| 42 | return self.SimpleTest("g722", "g722_unittests") |
| 43 | |
| 44 | def TestPCM16B(self): |
| 45 | return self.SimpleTest("pcm16b", "pcm16b_unittests") |
| 46 | |
| 47 | def TestNetEQ(self): |
| 48 | return self.SimpleTest("neteq", "neteq_unittests") |
| 49 | |
| 50 | def TestAudioConferenceMixer(self): |
| 51 | return self.SimpleTest("audio_conference_mixer", "audio_conference_mixer_unittests") |
| 52 | |
| 53 | def TestMediaFile(self): |
| 54 | return self.SimpleTest("media_file", "media_file_unittests") |
| 55 | |
| 56 | def TestRTPRTCP(self): |
| 57 | return self.SimpleTest("rtp_rtcp", "rtp_rtcp_unittests") |
| 58 | |
| 59 | def TestBWE(self): |
| 60 | return self.SimpleTest("test_bwe", "test_bwe") |
| 61 | |
| 62 | def TestUDPTransport(self): |
| 63 | return self.SimpleTest("udp_transport", "udp_transport_unittests") |
| 64 | |
| 65 | def TestWebRTCUtility(self): |
| 66 | return self.SimpleTest("webrtc_utility", "webrtc_utility_unittests") |
| 67 | |
| 68 | def TestVP8(self): |
| 69 | return self.SimpleTest("vp8", "vp8_unittests") |
| 70 | |
| 71 | def TestVideoCoding(self): |
| 72 | return self.SimpleTest("video_coding", "video_coding_unittests") |
| 73 | |
| 74 | def TestVideoProcessing(self): |
| 75 | return self.SimpleTest("video_processing", "video_processing_unittests") |
| 76 | |
| 77 | def TestSystemWrappers(self): |
| 78 | return self.SimpleTest("system_wrappers", "system_wrappers_unittests") |
| 79 | |
| 80 | def TestTestSupport(self): |
| 81 | return self.SimpleTest("test_support", "test_support_unittests") |
| 82 | |
| 83 | def _main(_): |
| 84 | parser = optparse.OptionParser("usage: %prog -b <dir> -t <test> " |
| 85 | "[-t <test> ...]") |
| 86 | parser.disable_interspersed_args() |
| 87 | parser.add_option("-b", "--build_dir", |
| 88 | help="the location of the compiler output") |
| 89 | parser.add_option("-t", "--test", action="append", default=[], |
| 90 | help="which test to run, supports test:gtest_filter format " |
| 91 | "as well.") |
| 92 | parser.add_option("", "--baseline", action="store_true", default=False, |
| 93 | help="generate baseline data instead of validating") |
| 94 | parser.add_option("", "--gtest_filter", |
| 95 | help="additional arguments to --gtest_filter") |
| 96 | parser.add_option("", "--gtest_repeat", |
| 97 | help="argument for --gtest_repeat") |
| 98 | parser.add_option("-v", "--verbose", action="store_true", default=False, |
| 99 | help="verbose output - enable debug log messages") |
| 100 | parser.add_option("", "--tool", dest="valgrind_tool", default="memcheck", |
| 101 | help="specify a valgrind tool to run the tests under") |
| 102 | parser.add_option("", "--tool_flags", dest="valgrind_tool_flags", default="", |
| 103 | help="specify custom flags for the selected valgrind tool") |
| 104 | parser.add_option("", "--keep_logs", action="store_true", default=False, |
| 105 | help="store memory tool logs in the <tool>.logs directory " |
| 106 | "instead of /tmp.\nThis can be useful for tool " |
| 107 | "developers/maintainers.\nPlease note that the <tool>" |
| 108 | ".logs directory will be clobbered on tool startup.") |
| 109 | options, args = parser.parse_args() |
| 110 | |
| 111 | if options.verbose: |
| 112 | logging_utils.config_root(logging.DEBUG) |
| 113 | else: |
| 114 | logging_utils.config_root() |
| 115 | |
| 116 | if not options.test: |
| 117 | parser.error("--test not specified") |
| 118 | |
| 119 | if len(options.test) != 1 and options.gtest_filter: |
| 120 | parser.error("--gtest_filter and multiple tests don't make sense together") |
| 121 | |
| 122 | for t in options.test: |
| 123 | tests = WebRTCTests(options, args, t) |
| 124 | ret = tests.Run() |
| 125 | if ret: return ret |
| 126 | return 0 |
| 127 | |
| 128 | if __name__ == "__main__": |
| 129 | # Overwrite the ChromeTests tests dictionary with our WebRTC tests. |
| 130 | # The cmdline option allows the user to pass any executable as parameter to |
| 131 | # the test script, which is useful when developing new tests that are not yet |
| 132 | # present in this script. |
| 133 | chrome_tests.ChromeTests._test_list = { |
| 134 | "cmdline": chrome_tests.ChromeTests.RunCmdLine, |
| 135 | "signal_processing": WebRTCTests.TestSignalProcessing, |
| 136 | "resampler": WebRTCTests.TestResampler, |
| 137 | "vad": WebRTCTests.TestVAD, |
| 138 | "cng": WebRTCTests.TestCNG, |
| 139 | "g711": WebRTCTests.TestG711, |
| 140 | "g722": WebRTCTests.TestG722, |
| 141 | "pcm16b": WebRTCTests.TestPCM16B, |
| 142 | "neteq": WebRTCTests.TestNetEQ, |
| 143 | "audio_conference_mixer": WebRTCTests.TestAudioConferenceMixer, |
| 144 | "media_file": WebRTCTests.TestMediaFile, |
| 145 | "rtp_rtcp": WebRTCTests.TestRTPRTCP, |
| 146 | "test_bwe": WebRTCTests.TestBWE, |
| 147 | "udp_transport": WebRTCTests.TestUDPTransport, |
| 148 | "webrtc_utility": WebRTCTests.TestWebRTCUtility, |
| 149 | "vp8": WebRTCTests.TestVP8, |
| 150 | "video_coding": WebRTCTests.TestVideoCoding, |
| 151 | "video_processing": WebRTCTests.TestVideoProcessing, |
| 152 | "system_wrappers": WebRTCTests.TestSystemWrappers, |
| 153 | "test_support": WebRTCTests.TestTestSupport, |
| 154 | } |
| 155 | ret = _main(sys.argv) |
| 156 | sys.exit(ret) |