blob: 391920e16722ccf1519750c5e602d3494b9de01c [file] [log] [blame]
asharif8c227da2013-02-15 04:35:52 +00001#!/usr/bin/python2.6
2#
3# Copyright 2010 Google Inc. All Rights Reserved.
4
5"""Script to wrap run_remote_tests.sh script.
6
7This script calls run_remote_tests.sh with standard tests.
8"""
9
10__author__ = "asharif@google.com (Ahmad Sharif)"
11
12import optparse
13import os
asharif3c3c7ab2013-02-15 04:56:40 +000014import re
asharif8c227da2013-02-15 04:35:52 +000015import sys
raymes01959ae2013-02-15 04:50:07 +000016from utils import command_executer
asharifc20ed542013-02-15 10:22:19 +000017from utils import logger
asharif8c227da2013-02-15 04:35:52 +000018
asharif8c227da2013-02-15 04:35:52 +000019
asharif8697d4e2013-02-15 09:18:09 +000020def Main(argv):
asharif8c227da2013-02-15 04:35:52 +000021 """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
asharifea33a562013-02-15 04:56:09 +000030 tests = "bvt"
asharif8c227da2013-02-15 04:35:52 +000031
asharif8697d4e2013-02-15 09:18:09 +000032 (options, args) = parser.parse_args(argv)
asharif8c227da2013-02-15 04:35:52 +000033
34 if options.board is None or options.remote is None:
35 parser.print_help()
asharifc20ed542013-02-15 10:22:19 +000036 return -1
asharif8c227da2013-02-15 04:35:52 +000037
38 if options.chromeos_root is None:
asharifc20ed542013-02-15 10:22:19 +000039 m = "--chromeos_root not given. Setting ../../ as chromeos_root"
40 logger.GetLogger().LogWarning(m)
asharif8c227da2013-02-15 04:35:52 +000041 options.chromeos_root = "../.."
42
asharifc20ed542013-02-15 10:22:19 +000043 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
asharifea33a562013-02-15 04:56:09 +000049 if args:
asharifc20ed542013-02-15 10:22:19 +000050 tests = " " + " ".join(args[1:])
asharif3c3c7ab2013-02-15 04:56:40 +000051
52 case_insensitive_page = re.compile("page", re.IGNORECASE)
53 tests = case_insensitive_page.sub("Page", tests)
54
asharif8c227da2013-02-15 04:35:52 +000055 return RunRemoteTests(options.chromeos_root, options.remote,
56 options.board, tests)
57
58
59def 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
asharif967d7002013-02-15 04:51:00 +000066 retval = command_executer.GetCommandExecuter().RunCommand(command)
asharif8c227da2013-02-15 04:35:52 +000067 return retval
68
69if __name__ == "__main__":
asharif2198c512013-02-15 09:21:35 +000070 retval = Main(sys.argv)
71 sys.exit(retval)