asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 1 | #!/usr/bin/python2.6 |
| 2 | # |
| 3 | # Copyright 2010 Google Inc. All Rights Reserved. |
| 4 | |
| 5 | """Script to wrap run_remote_tests.sh script. |
| 6 | |
| 7 | This script calls run_remote_tests.sh with standard tests. |
| 8 | """ |
| 9 | |
| 10 | __author__ = "asharif@google.com (Ahmad Sharif)" |
| 11 | |
| 12 | import optparse |
| 13 | import os |
asharif | 3c3c7ab | 2013-02-15 04:56:40 +0000 | [diff] [blame] | 14 | import re |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 15 | import sys |
kbaclawski | 20082a0 | 2013-02-16 02:12:57 +0000 | [diff] [blame^] | 16 | |
raymes | 01959ae | 2013-02-15 04:50:07 +0000 | [diff] [blame] | 17 | from utils import command_executer |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame] | 18 | from utils import logger |
asharif | c72bccd | 2013-02-15 10:24:18 +0000 | [diff] [blame] | 19 | import build_chromeos |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 20 | |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 21 | |
asharif | 8697d4e | 2013-02-15 09:18:09 +0000 | [diff] [blame] | 22 | def Main(argv): |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 23 | """The main function.""" |
| 24 | parser = optparse.OptionParser() |
| 25 | parser.add_option("-c", "--chromeos_root", dest="chromeos_root", |
| 26 | help="ChromeOS root checkout directory.") |
| 27 | parser.add_option("-r", "--remote", dest="remote", |
| 28 | help="The IP address of the remote ChromeOS machine.") |
| 29 | parser.add_option("-b", "--board", dest="board", |
| 30 | help="The board of the target.") |
| 31 | |
asharif | 8697d4e | 2013-02-15 09:18:09 +0000 | [diff] [blame] | 32 | (options, args) = parser.parse_args(argv) |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 33 | |
asharif | c72bccd | 2013-02-15 10:24:18 +0000 | [diff] [blame] | 34 | tests = "" |
| 35 | |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 36 | if options.board is None or options.remote is None: |
| 37 | parser.print_help() |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame] | 38 | return -1 |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 39 | |
| 40 | if options.chromeos_root is None: |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame] | 41 | m = "--chromeos_root not given. Setting ../../ as chromeos_root" |
| 42 | logger.GetLogger().LogWarning(m) |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 43 | options.chromeos_root = "../.." |
| 44 | |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame] | 45 | rrt_file = "%s/src/scripts/run_remote_tests.sh" % options.chromeos_root |
| 46 | if not os.path.isfile(rrt_file): |
| 47 | m = "File %s not found" % rrt_file |
| 48 | logger.GetLogger().LogError(m) |
| 49 | return -1 |
| 50 | |
asharif | ea33a56 | 2013-02-15 04:56:09 +0000 | [diff] [blame] | 51 | if args: |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame] | 52 | tests = " " + " ".join(args[1:]) |
asharif | 3c3c7ab | 2013-02-15 04:56:40 +0000 | [diff] [blame] | 53 | |
| 54 | case_insensitive_page = re.compile("page", re.IGNORECASE) |
| 55 | tests = case_insensitive_page.sub("Page", tests) |
| 56 | |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 57 | return RunRemoteTests(options.chromeos_root, options.remote, |
| 58 | options.board, tests) |
| 59 | |
| 60 | |
| 61 | def RunRemoteTests(chromeos_root, remote, board, tests): |
| 62 | """Run the remote tests.""" |
asharif | ca3c6c1 | 2013-02-15 23:17:54 +0000 | [diff] [blame] | 63 | ce = command_executer.GetCommandExecuter() |
asharif | c72bccd | 2013-02-15 10:24:18 +0000 | [diff] [blame] | 64 | command = ("./run_remote_tests.sh" |
| 65 | " --remote=%s" |
| 66 | " --board=%s" |
| 67 | " %s" % |
| 68 | (remote, |
| 69 | board, |
| 70 | tests)) |
asharif | ca3c6c1 | 2013-02-15 23:17:54 +0000 | [diff] [blame] | 71 | retval = ce.ChrootRunCommand(chromeos_root, command) |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 72 | return retval |
| 73 | |
| 74 | if __name__ == "__main__": |
kbaclawski | 5fec550 | 2013-02-15 19:55:56 +0000 | [diff] [blame] | 75 | sys.exit(Main(sys.argv)) |