blob: 37ac2b7fdf321b2a83359abe118a91cc3524f0c7 [file] [log] [blame]
Mike Frysingerc7f15932013-03-20 13:43:35 -04001#!/usr/bin/python
asharifbb918502013-02-15 05:15:01 +00002#
3# Copyright 2010 Google Inc. All Rights Reserved.
4
5"""Script to wrap run_remote_tests.sh script.
6
7This script can login to the chromeos machine using the test private key.
8"""
9
10__author__ = "asharif@google.com (Ahmad Sharif)"
11
12import optparse
13import os
14import re
15import sys
kbaclawski20082a02013-02-16 02:12:57 +000016
asharifbb918502013-02-15 05:15:01 +000017from utils import command_executer
kbaclawski20082a02013-02-16 02:12:57 +000018from utils import misc
asharifbb918502013-02-15 05:15:01 +000019
20
21def Usage(parser, message):
22 print "ERROR: " + message
23 parser.print_help()
24 sys.exit(0)
25
26def Main(argv):
27 parser = optparse.OptionParser()
28 parser.add_option("-c", "--chromeos_root", dest="chromeos_root",
29 help="ChromeOS root checkout directory")
30 parser.add_option("-r", "--remote", dest="remote",
31 help="Remote chromeos device.")
32 options = parser.parse_args(argv)[0]
33 if options.chromeos_root is None:
34 Usage(parser, "chromeos_root must be given")
35
36 if options.remote is None:
37 Usage(parser, "remote must be given")
38
39 options.chromeos_root = os.path.expanduser(options.chromeos_root)
40
41 command = "ls -lt /"
42 ce = command_executer.GetCommandExecuter()
43 ce.CrosRunCommand(command,
44 chromeos_root=options.chromeos_root,
45 machine=options.remote)
46
kbaclawski20082a02013-02-16 02:12:57 +000047 version_dir_path, script_name = misc.GetRoot(sys.argv[0])
48 version_dir = misc.GetRoot(version_dir_path)[1]
asharif29775b22013-02-15 05:15:38 +000049
50 # Tests to copy directories and files to the chromeos box.
51 ce.CopyFiles(version_dir_path,
52 "/tmp/" + version_dir,
asharifbb918502013-02-15 05:15:01 +000053 dest_machine=options.remote,
54 dest_cros=True,
55 chromeos_root=options.chromeos_root)
asharif29775b22013-02-15 05:15:38 +000056 ce.CopyFiles(version_dir_path,
57 "/tmp/" + version_dir + "1",
58 dest_machine=options.remote,
59 dest_cros=True,
60 chromeos_root=options.chromeos_root)
61 ce.CopyFiles(sys.argv[0],
62 "/tmp/" + script_name,
63 recursive=False,
64 dest_machine=options.remote,
65 dest_cros=True,
66 chromeos_root=options.chromeos_root)
67 ce.CopyFiles(sys.argv[0],
68 "/tmp/" + script_name + "1",
69 recursive=False,
70 dest_machine=options.remote,
71 dest_cros=True,
72 chromeos_root=options.chromeos_root)
73
74 # Test to copy directories and files from the chromeos box.
75 ce.CopyFiles("/tmp/" + script_name,
76 "/tmp/hello",
77 recursive=False,
78 src_machine=options.remote,
79 src_cros=True,
80 chromeos_root=options.chromeos_root)
81 ce.CopyFiles("/tmp/" + script_name,
82 "/tmp/" + script_name,
83 recursive=False,
84 src_machine=options.remote,
85 src_cros=True,
86 chromeos_root=options.chromeos_root)
asharif6f4065c2013-02-15 09:04:02 +000087 board = ce.CrosLearnBoard(options.chromeos_root, options.remote)
asharifbb918502013-02-15 05:15:01 +000088 print board
asharif29775b22013-02-15 05:15:38 +000089 return 0
asharifbb918502013-02-15 05:15:01 +000090
91
92if __name__ == "__main__":
93 Main(sys.argv)