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 |
raymes | 01959ae | 2013-02-15 04:50:07 +0000 | [diff] [blame] | 16 | from utils import command_executer |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame^] | 17 | from utils import logger |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 18 | |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 19 | |
asharif | 8697d4e | 2013-02-15 09:18:09 +0000 | [diff] [blame] | 20 | def Main(argv): |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 21 | """The main function.""" |
| 22 | parser = optparse.OptionParser() |
| 23 | parser.add_option("-c", "--chromeos_root", dest="chromeos_root", |
| 24 | help="ChromeOS root checkout directory.") |
| 25 | parser.add_option("-r", "--remote", dest="remote", |
| 26 | help="The IP address of the remote ChromeOS machine.") |
| 27 | parser.add_option("-b", "--board", dest="board", |
| 28 | help="The board of the target.") |
| 29 | |
asharif | ea33a56 | 2013-02-15 04:56:09 +0000 | [diff] [blame] | 30 | tests = "bvt" |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 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 | |
| 34 | if options.board is None or options.remote is None: |
| 35 | parser.print_help() |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame^] | 36 | return -1 |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 37 | |
| 38 | if options.chromeos_root is None: |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame^] | 39 | m = "--chromeos_root not given. Setting ../../ as chromeos_root" |
| 40 | logger.GetLogger().LogWarning(m) |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 41 | options.chromeos_root = "../.." |
| 42 | |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame^] | 43 | rrt_file = "%s/src/scripts/run_remote_tests.sh" % options.chromeos_root |
| 44 | if not os.path.isfile(rrt_file): |
| 45 | m = "File %s not found" % rrt_file |
| 46 | logger.GetLogger().LogError(m) |
| 47 | return -1 |
| 48 | |
asharif | ea33a56 | 2013-02-15 04:56:09 +0000 | [diff] [blame] | 49 | if args: |
asharif | c20ed54 | 2013-02-15 10:22:19 +0000 | [diff] [blame^] | 50 | tests = " " + " ".join(args[1:]) |
asharif | 3c3c7ab | 2013-02-15 04:56:40 +0000 | [diff] [blame] | 51 | |
| 52 | case_insensitive_page = re.compile("page", re.IGNORECASE) |
| 53 | tests = case_insensitive_page.sub("Page", tests) |
| 54 | |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 55 | return RunRemoteTests(options.chromeos_root, options.remote, |
| 56 | options.board, tests) |
| 57 | |
| 58 | |
| 59 | def RunRemoteTests(chromeos_root, remote, board, tests): |
| 60 | """Run the remote tests.""" |
| 61 | command = (chromeos_root + "/src/scripts/run_remote_tests.sh" + |
| 62 | " --remote=" + remote + |
| 63 | " --board=" + board + |
| 64 | " " + tests) |
| 65 | |
asharif | 967d700 | 2013-02-15 04:51:00 +0000 | [diff] [blame] | 66 | retval = command_executer.GetCommandExecuter().RunCommand(command) |
asharif | 8c227da | 2013-02-15 04:35:52 +0000 | [diff] [blame] | 67 | return retval |
| 68 | |
| 69 | if __name__ == "__main__": |
asharif | 2198c51 | 2013-02-15 09:21:35 +0000 | [diff] [blame] | 70 | retval = Main(sys.argv) |
| 71 | sys.exit(retval) |