blob: 075f29b1393560234342ffd44451b624c39797c9 [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
kbaclawski20082a02013-02-16 02:12:57 +000016
raymes01959ae2013-02-15 04:50:07 +000017from utils import command_executer
asharifc20ed542013-02-15 10:22:19 +000018from utils import logger
asharifc72bccd2013-02-15 10:24:18 +000019import build_chromeos
asharif8c227da2013-02-15 04:35:52 +000020
asharif8c227da2013-02-15 04:35:52 +000021
asharif8697d4e2013-02-15 09:18:09 +000022def Main(argv):
asharif8c227da2013-02-15 04:35:52 +000023 """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
asharif8697d4e2013-02-15 09:18:09 +000032 (options, args) = parser.parse_args(argv)
asharif8c227da2013-02-15 04:35:52 +000033
asharifc72bccd2013-02-15 10:24:18 +000034 tests = ""
35
asharif8c227da2013-02-15 04:35:52 +000036 if options.board is None or options.remote is None:
37 parser.print_help()
asharifc20ed542013-02-15 10:22:19 +000038 return -1
asharif8c227da2013-02-15 04:35:52 +000039
40 if options.chromeos_root is None:
asharifc20ed542013-02-15 10:22:19 +000041 m = "--chromeos_root not given. Setting ../../ as chromeos_root"
42 logger.GetLogger().LogWarning(m)
asharif8c227da2013-02-15 04:35:52 +000043 options.chromeos_root = "../.."
44
asharifc20ed542013-02-15 10:22:19 +000045 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
asharifea33a562013-02-15 04:56:09 +000051 if args:
asharifc20ed542013-02-15 10:22:19 +000052 tests = " " + " ".join(args[1:])
asharif3c3c7ab2013-02-15 04:56:40 +000053
54 case_insensitive_page = re.compile("page", re.IGNORECASE)
55 tests = case_insensitive_page.sub("Page", tests)
56
asharif8c227da2013-02-15 04:35:52 +000057 return RunRemoteTests(options.chromeos_root, options.remote,
58 options.board, tests)
59
60
61def RunRemoteTests(chromeos_root, remote, board, tests):
62 """Run the remote tests."""
asharifca3c6c12013-02-15 23:17:54 +000063 ce = command_executer.GetCommandExecuter()
asharifc72bccd2013-02-15 10:24:18 +000064 command = ("./run_remote_tests.sh"
65 " --remote=%s"
66 " --board=%s"
67 " %s" %
68 (remote,
69 board,
70 tests))
asharifca3c6c12013-02-15 23:17:54 +000071 retval = ce.ChrootRunCommand(chromeos_root, command)
asharif8c227da2013-02-15 04:35:52 +000072 return retval
73
74if __name__ == "__main__":
kbaclawski5fec5502013-02-15 19:55:56 +000075 sys.exit(Main(sys.argv))