Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Central list of tests to run (as appropriate for a given config). Add tests | 6 """Central list of tests to run (as appropriate for a given config). Add tests |
| 7 to run by modifying this file. | 7 to run by modifying this file. |
| 8 | 8 |
| 9 Note that this file is both imported (by mojob.py) and run directly (via a | 9 Note that this file is both imported (by mojob.py) and run directly (via a |
| 10 recipe).""" | 10 recipe).""" |
| 11 | 11 |
| 12 | 12 |
| 13 import argparse | 13 import argparse |
| 14 import json | 14 import json |
| 15 import os | 15 import os |
| 16 import subprocess | |
| 16 import sys | 17 import sys |
| 18 import urllib | |
| 17 | 19 |
| 18 from mopy.config import Config | 20 from mopy.config import Config |
| 19 from mopy.paths import Paths | 21 from mopy.paths import Paths |
| 20 | 22 |
| 21 | 23 |
| 22 def GetTestList(config): | 24 def GetTestList(config): |
| 23 """Gets the list of tests to run for the given config. The test list (which is | 25 """Gets the list of tests to run for the given config. The test list (which is |
| 24 returned) is just a list of dictionaries, each dictionary having two required | 26 returned) is just a list of dictionaries, each dictionary having the following |
| 25 fields: | 27 fields: |
| 26 { | 28 { |
| 29 # Required: | |
| 27 "name": "Short name", | 30 "name": "Short name", |
| 28 "command": ["python", "test_runner.py", "--some", "args"] | 31 "command": ["python", "test_runner.py", "--some", "args"] |
| 32 | |
| 33 # Optional: | |
| 34 "links": { | |
|
viettrungluu
2015/01/28 01:51:45
I'm dubious about this having a dictionary value.
| |
| 35 "Anchor text": "URL" | |
| 36 } | |
| 29 } | 37 } |
| 30 """ | 38 """ |
| 31 | 39 |
| 32 types_to_run = set(config.test_types) | 40 types_to_run = set(config.test_types) |
| 33 | 41 |
| 34 # See above for a description of the test list. | 42 # See above for a description of the test list. |
| 35 test_list = [] | 43 test_list = [] |
| 36 | 44 |
| 37 paths = Paths(config) | 45 paths = Paths(config) |
| 38 build_dir = paths.SrcRelPath(paths.build_dir) | 46 build_dir = paths.SrcRelPath(paths.build_dir) |
| 39 target_os = config.target_os | 47 target_os = config.target_os |
| 40 | 48 |
| 41 # Utility functions ---------------------------------------------------------- | 49 # Utility functions ---------------------------------------------------------- |
| 42 | 50 |
| 43 # Call this to determine if a test matching classes this_tests_types should | 51 # Call this to determine if a test matching classes this_tests_types should |
| 44 # run: e.g., ShouldRunTest(Config.TEST_TYPE_DEFAULT, "sky") returns true if | 52 # run: e.g., ShouldRunTest(Config.TEST_TYPE_DEFAULT, "sky") returns true if |
| 45 # the test list being requested specifies the default set or the "sky" set. | 53 # the test list being requested specifies the default set or the "sky" set. |
| 46 def ShouldRunTest(*this_tests_types): | 54 def ShouldRunTest(*this_tests_types): |
| 47 return not types_to_run.isdisjoint(this_tests_types) | 55 return not types_to_run.isdisjoint(this_tests_types) |
| 48 | 56 |
| 49 # Call this to add the given command to the test list. | 57 # Call this to add the given command to the test list. |
| 50 def AddEntry(name, command): | 58 def AddEntry(name, command, links=None): |
| 51 if config.sanitizer == Config.SANITIZER_ASAN: | 59 if config.sanitizer == Config.SANITIZER_ASAN: |
| 52 command = (['python', os.path.join("mojo", "tools", | 60 command = (['python', os.path.join("mojo", "tools", |
| 53 "run_command_through_symbolizer.py")] + | 61 "run_command_through_symbolizer.py")] + |
| 54 command) | 62 command) |
| 55 test_list.append({"name": name, "command": command}) | 63 entry = {"name": name, "command": command} |
| 64 if links is not None: | |
| 65 entry["links"] = links | |
| 66 test_list.append(entry) | |
| 56 | 67 |
| 57 # Call this to add the given command to the test list. If appropriate, the | 68 # Call this to add the given command to the test list. If appropriate, the |
| 58 # command will be run under xvfb. | 69 # command will be run under xvfb. |
| 59 def AddXvfbEntry(name, command): | 70 def AddXvfbEntry(name, command, links=None): |
|
viettrungluu
2015/01/28 01:51:45
Just do **kwargs here.
| |
| 60 real_command = ["python"] | 71 real_command = ["python"] |
| 61 if config.target_os == Config.OS_LINUX: | 72 if config.target_os == Config.OS_LINUX: |
| 62 real_command += ["./testing/xvfb.py", paths.SrcRelPath(paths.build_dir)] | 73 real_command += ["./testing/xvfb.py", paths.SrcRelPath(paths.build_dir)] |
| 63 real_command += command | 74 real_command += command |
| 64 AddEntry(name, real_command) | 75 AddEntry(name, real_command, links) |
|
viettrungluu
2015/01/28 01:51:45
And here.
| |
| 76 | |
| 77 def GetCurrentCommitCount(): | |
|
viettrungluu
2015/01/28 01:51:45
Please don't do this (actually run outside stuff,
| |
| 78 return subprocess.check_output( | |
| 79 ["git", "rev-list", "HEAD", "--count"]).strip() | |
| 80 | |
| 65 | 81 |
| 66 # ---------------------------------------------------------------------------- | 82 # ---------------------------------------------------------------------------- |
| 67 | 83 |
| 68 # TODO(vtl): Currently, we only know how to run tests for Android, Linux, or | 84 # TODO(vtl): Currently, we only know how to run tests for Android, Linux, or |
| 69 # Windows. | 85 # Windows. |
| 70 if target_os not in (Config.OS_ANDROID, Config.OS_LINUX, Config.OS_WINDOWS): | 86 if target_os not in (Config.OS_ANDROID, Config.OS_LINUX, Config.OS_WINDOWS): |
| 71 return test_list | 87 return test_list |
| 72 | 88 |
| 73 # Tests run by default ------------------------------------------------------- | 89 # Tests run by default ------------------------------------------------------- |
| 74 | 90 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 if config.values.get("test_results_server"): | 140 if config.values.get("test_results_server"): |
| 125 sky_command += ["--test-results-server", | 141 sky_command += ["--test-results-server", |
| 126 config.values["test_results_server"]] | 142 config.values["test_results_server"]] |
| 127 AddXvfbEntry("Sky tests", sky_command) | 143 AddXvfbEntry("Sky tests", sky_command) |
| 128 | 144 |
| 129 # Perf tests ----------------------------------------------------------------- | 145 # Perf tests ----------------------------------------------------------------- |
| 130 | 146 |
| 131 if target_os == Config.OS_LINUX and ShouldRunTest(Config.TEST_TYPE_PERF): | 147 if target_os == Config.OS_LINUX and ShouldRunTest(Config.TEST_TYPE_PERF): |
| 132 perf_id = "linux_%s" % ("debug" if config.is_debug else "release") | 148 perf_id = "linux_%s" % ("debug" if config.is_debug else "release") |
| 133 test_names = ["mojo_public_system_perftests"] | 149 test_names = ["mojo_public_system_perftests"] |
| 150 point_id = GetCurrentCommitCount() | |
| 134 | 151 |
| 135 for test_name in test_names: | 152 for test_name in test_names: |
| 136 command = ["python", | 153 command = ["python", |
| 137 os.path.join("mojo", "tools", "perf_test_runner.py"), | 154 os.path.join("mojo", "tools", "perf_test_runner.py"), |
| 138 "--perf-id", perf_id, | 155 "--perf-id", perf_id, |
| 139 "--test-name", test_name, | 156 "--test-name", test_name, |
| 140 "--perf-data-path", | 157 "--perf-data-path", |
| 141 os.path.join(build_dir, test_name + "_perf.log"), | 158 os.path.join(build_dir, test_name + "_perf.log"), |
| 159 "--point-id", point_id, | |
| 142 "--production-dashboard"] | 160 "--production-dashboard"] |
| 143 if config.values.get("builder_name"): | 161 if config.values.get("builder_name"): |
| 144 command += ["--builder-name", config.values["builder_name"]] | 162 command += ["--builder-name", config.values["builder_name"]] |
| 145 if config.values.get("build_number"): | 163 if config.values.get("build_number"): |
| 146 command += ["--build-number", config.values["build_number"]] | 164 command += ["--build-number", config.values["build_number"]] |
| 147 if config.values.get("master_name"): | 165 if config.values.get("master_name"): |
| 148 command += ["--master-name", config.values["master_name"]] | 166 command += ["--master-name", config.values["master_name"]] |
| 149 command += [os.path.join(build_dir, test_name)] | 167 command += [os.path.join(build_dir, test_name)] |
| 150 | 168 |
| 151 AddEntry(test_name, command) | 169 dashboard_params = urllib.urlencode({ |
| 170 "masters": config.values.get("master_name"), | |
| 171 "bots": perf_id, | |
| 172 "tests": test_name, | |
| 173 "rev": point_id, | |
| 174 }) | |
| 175 links = { | |
| 176 "Results Dashboard": ("https://chromeperf.appspot.com/report?%s" | |
| 177 % dashboard_params) | |
| 178 } | |
| 179 AddEntry(test_name, command, links) | |
|
viettrungluu
2015/01/28 01:51:45
You should use your kwarg as a kwarg, given that y
| |
| 152 | 180 |
| 153 # Integration tests ---------------------------------------------------------- | 181 # Integration tests ---------------------------------------------------------- |
| 154 | 182 |
| 155 if target_os == Config.OS_ANDROID and ShouldRunTest( | 183 if target_os == Config.OS_ANDROID and ShouldRunTest( |
| 156 Config.TEST_TYPE_DEFAULT, Config.TEST_TYPE_INTEGRATION): | 184 Config.TEST_TYPE_DEFAULT, Config.TEST_TYPE_INTEGRATION): |
| 157 AddEntry("Integration test (MojoTest)", | 185 AddEntry("Integration test (MojoTest)", |
| 158 ["python", | 186 ["python", |
| 159 os.path.join("build", "android", "test_runner.py"), | 187 os.path.join("build", "android", "test_runner.py"), |
| 160 "instrumentation", | 188 "instrumentation", |
| 161 "--test-apk=MojoTest", | 189 "--test-apk=MojoTest", |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 config = Config(**json.load(args.config_file)) | 231 config = Config(**json.load(args.config_file)) |
| 204 test_list = GetTestList(config) | 232 test_list = GetTestList(config) |
| 205 json.dump(test_list, args.test_list_file, indent=2) | 233 json.dump(test_list, args.test_list_file, indent=2) |
| 206 args.test_list_file.write("\n") | 234 args.test_list_file.write("\n") |
| 207 | 235 |
| 208 return 0 | 236 return 0 |
| 209 | 237 |
| 210 | 238 |
| 211 if __name__ == "__main__": | 239 if __name__ == "__main__": |
| 212 sys.exit(main()) | 240 sys.exit(main()) |
| OLD | NEW |