blob: 59eb9eb5213ce5ff639cfbe755cc0962de7cba24 [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.
cmticed96e4572015-05-19 16:19:25 -07004"""Script to wrap test_that script.
asharifbb918502013-02-15 05:15:01 +00005
6This script can login to the chromeos machine using the test private key.
7"""
8
Luis Lozanof2a3ef42015-12-15 13:49:30 -08009__author__ = 'asharif@google.com (Ahmad Sharif)'
asharifbb918502013-02-15 05:15:01 +000010
11import optparse
12import os
13import re
14import sys
kbaclawski20082a02013-02-16 02:12:57 +000015
asharifbb918502013-02-15 05:15:01 +000016from utils import command_executer
kbaclawski20082a02013-02-16 02:12:57 +000017from utils import misc
asharifbb918502013-02-15 05:15:01 +000018
19
20def Usage(parser, message):
Luis Lozanof2a3ef42015-12-15 13:49:30 -080021 print 'ERROR: ' + message
asharifbb918502013-02-15 05:15:01 +000022 parser.print_help()
23 sys.exit(0)
24
Luis Lozanof2a3ef42015-12-15 13:49:30 -080025
asharifbb918502013-02-15 05:15:01 +000026def Main(argv):
27 parser = optparse.OptionParser()
Luis Lozanof2a3ef42015-12-15 13:49:30 -080028 parser.add_option('-c',
29 '--chromeos_root',
30 dest='chromeos_root',
31 help='ChromeOS root checkout directory')
32 parser.add_option('-r',
33 '--remote',
34 dest='remote',
35 help='Remote chromeos device.')
asharifbb918502013-02-15 05:15:01 +000036 options = parser.parse_args(argv)[0]
37 if options.chromeos_root is None:
Luis Lozanof2a3ef42015-12-15 13:49:30 -080038 Usage(parser, 'chromeos_root must be given')
asharifbb918502013-02-15 05:15:01 +000039
40 if options.remote is None:
Luis Lozanof2a3ef42015-12-15 13:49:30 -080041 Usage(parser, 'remote must be given')
asharifbb918502013-02-15 05:15:01 +000042
43 options.chromeos_root = os.path.expanduser(options.chromeos_root)
44
Luis Lozanof2a3ef42015-12-15 13:49:30 -080045 command = 'ls -lt /'
asharifbb918502013-02-15 05:15:01 +000046 ce = command_executer.GetCommandExecuter()
47 ce.CrosRunCommand(command,
48 chromeos_root=options.chromeos_root,
49 machine=options.remote)
50
kbaclawski20082a02013-02-16 02:12:57 +000051 version_dir_path, script_name = misc.GetRoot(sys.argv[0])
52 version_dir = misc.GetRoot(version_dir_path)[1]
asharif29775b22013-02-15 05:15:38 +000053
54 # Tests to copy directories and files to the chromeos box.
55 ce.CopyFiles(version_dir_path,
Luis Lozanof2a3ef42015-12-15 13:49:30 -080056 '/tmp/' + version_dir,
asharifbb918502013-02-15 05:15:01 +000057 dest_machine=options.remote,
58 dest_cros=True,
59 chromeos_root=options.chromeos_root)
asharif29775b22013-02-15 05:15:38 +000060 ce.CopyFiles(version_dir_path,
Luis Lozanof2a3ef42015-12-15 13:49:30 -080061 '/tmp/' + version_dir + '1',
asharif29775b22013-02-15 05:15:38 +000062 dest_machine=options.remote,
63 dest_cros=True,
64 chromeos_root=options.chromeos_root)
65 ce.CopyFiles(sys.argv[0],
Luis Lozanof2a3ef42015-12-15 13:49:30 -080066 '/tmp/' + script_name,
asharif29775b22013-02-15 05:15:38 +000067 recursive=False,
68 dest_machine=options.remote,
69 dest_cros=True,
70 chromeos_root=options.chromeos_root)
71 ce.CopyFiles(sys.argv[0],
Luis Lozanof2a3ef42015-12-15 13:49:30 -080072 '/tmp/' + script_name + '1',
asharif29775b22013-02-15 05:15:38 +000073 recursive=False,
74 dest_machine=options.remote,
75 dest_cros=True,
76 chromeos_root=options.chromeos_root)
77
78 # Test to copy directories and files from the chromeos box.
Luis Lozanof2a3ef42015-12-15 13:49:30 -080079 ce.CopyFiles('/tmp/' + script_name,
80 '/tmp/hello',
asharif29775b22013-02-15 05:15:38 +000081 recursive=False,
82 src_machine=options.remote,
83 src_cros=True,
84 chromeos_root=options.chromeos_root)
Luis Lozanof2a3ef42015-12-15 13:49:30 -080085 ce.CopyFiles('/tmp/' + script_name,
86 '/tmp/' + script_name,
asharif29775b22013-02-15 05:15:38 +000087 recursive=False,
88 src_machine=options.remote,
89 src_cros=True,
90 chromeos_root=options.chromeos_root)
asharif6f4065c2013-02-15 09:04:02 +000091 board = ce.CrosLearnBoard(options.chromeos_root, options.remote)
asharifbb918502013-02-15 05:15:01 +000092 print board
asharif29775b22013-02-15 05:15:38 +000093 return 0
asharifbb918502013-02-15 05:15:01 +000094
95
Luis Lozanof2a3ef42015-12-15 13:49:30 -080096if __name__ == '__main__':
asharifbb918502013-02-15 05:15:01 +000097 Main(sys.argv)