|
1 #!/usr/bin/env python |
|
2 # |
|
3 # This Source Code Form is subject to the terms of the Mozilla Public |
|
4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
6 |
|
7 import argparse |
|
8 import os |
|
9 import sys |
|
10 import tempfile |
|
11 |
|
12 from smoketest import * |
|
13 |
|
14 def main(): |
|
15 parser = argparse.ArgumentParser(prog="run-smoketests.py") |
|
16 parser.add_argument("--build-dir", required=True, |
|
17 help="directory that contains builds with build ID subdirectories") |
|
18 parser.add_argument("--run-dir", default=None, |
|
19 help="directory where partials and testvars are generated. default: " |
|
20 "create a temp directory") |
|
21 parser.add_argument("--tests", action='append', |
|
22 help="which smoketest(s) to run. by default all tests are run") |
|
23 parser.add_argument("build_ids", nargs="+", metavar="BUILD_ID", |
|
24 help="a list of build IDs to run smoketests against. the IDs will be " |
|
25 "sorted numerically, and partials will be generated from each to " |
|
26 "the last update. this list of partials will be tested along with " |
|
27 "a full update from each build to the last") |
|
28 args = parser.parse_args() |
|
29 |
|
30 try: |
|
31 b2g = find_b2g() |
|
32 except EnvironmentError, e: |
|
33 parser.exit(1, "This tool must be run while inside the B2G directory, " |
|
34 "or B2G_HOME must be set in the environment.") |
|
35 |
|
36 if not os.path.exists(args.build_dir): |
|
37 parser.exit(1, "Build dir doesn't exist: %s" % args.build_dir) |
|
38 |
|
39 if len(args.build_ids) < 2: |
|
40 parser.exit(1, "This script requires at least two build IDs") |
|
41 |
|
42 for test in args.tests: |
|
43 if not os.path.exists(test): |
|
44 parser.exit(1, "Smoketest does not exist: %s" % test) |
|
45 |
|
46 try: |
|
47 config = SmokeTestConfig(args.build_dir) |
|
48 runner = SmokeTestRunner(config, b2g, run_dir=args.run_dir) |
|
49 runner.run_smoketests(args.build_ids, args.tests) |
|
50 except KeyError, e: |
|
51 parser.exit(1, "Error: %s" % e) |
|
52 except SmokeTestError, e: |
|
53 parser.exit(1, "Error: %s" % e) |
|
54 |
|
55 if __name__ == "__main__": |
|
56 main() |