michael@0: #!/usr/bin/env python michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: import argparse michael@0: import os michael@0: import sys michael@0: import tempfile michael@0: michael@0: from smoketest import * michael@0: michael@0: def main(): michael@0: parser = argparse.ArgumentParser(prog="run-smoketests.py") michael@0: parser.add_argument("--build-dir", required=True, michael@0: help="directory that contains builds with build ID subdirectories") michael@0: parser.add_argument("--run-dir", default=None, michael@0: help="directory where partials and testvars are generated. default: " michael@0: "create a temp directory") michael@0: parser.add_argument("--tests", action='append', michael@0: help="which smoketest(s) to run. by default all tests are run") michael@0: parser.add_argument("build_ids", nargs="+", metavar="BUILD_ID", michael@0: help="a list of build IDs to run smoketests against. the IDs will be " michael@0: "sorted numerically, and partials will be generated from each to " michael@0: "the last update. this list of partials will be tested along with " michael@0: "a full update from each build to the last") michael@0: args = parser.parse_args() michael@0: michael@0: try: michael@0: b2g = find_b2g() michael@0: except EnvironmentError, e: michael@0: parser.exit(1, "This tool must be run while inside the B2G directory, " michael@0: "or B2G_HOME must be set in the environment.") michael@0: michael@0: if not os.path.exists(args.build_dir): michael@0: parser.exit(1, "Build dir doesn't exist: %s" % args.build_dir) michael@0: michael@0: if len(args.build_ids) < 2: michael@0: parser.exit(1, "This script requires at least two build IDs") michael@0: michael@0: for test in args.tests: michael@0: if not os.path.exists(test): michael@0: parser.exit(1, "Smoketest does not exist: %s" % test) michael@0: michael@0: try: michael@0: config = SmokeTestConfig(args.build_dir) michael@0: runner = SmokeTestRunner(config, b2g, run_dir=args.run_dir) michael@0: runner.run_smoketests(args.build_ids, args.tests) michael@0: except KeyError, e: michael@0: parser.exit(1, "Error: %s" % e) michael@0: except SmokeTestError, e: michael@0: parser.exit(1, "Error: %s" % e) michael@0: michael@0: if __name__ == "__main__": michael@0: main()