blob: 62598d5ae549146e2459680850aa3fef9f2e4814 [file] [log] [blame]
Caroline Ticef6ef4392017-04-06 17:16:05 -07001#!/usr/bin/env python2
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
Caroline Tice88272d42016-01-13 09:48:29 -08009from __future__ import print_function
10
Luis Lozanof2a3ef42015-12-15 13:49:30 -080011__author__ = 'asharif@google.com (Ahmad Sharif)'
asharifbb918502013-02-15 05:15:01 +000012
Caroline Tice88272d42016-01-13 09:48:29 -080013import argparse
asharifbb918502013-02-15 05:15:01 +000014import os
asharifbb918502013-02-15 05:15:01 +000015import sys
kbaclawski20082a02013-02-16 02:12:57 +000016
Caroline Tice88272d42016-01-13 09:48:29 -080017from cros_utils import command_executer
18from cros_utils import misc
asharifbb918502013-02-15 05:15:01 +000019
20
21def Usage(parser, message):
Caroline Tice88272d42016-01-13 09:48:29 -080022 print('ERROR: %s' % message)
asharifbb918502013-02-15 05:15:01 +000023 parser.print_help()
24 sys.exit(0)
25
Luis Lozanof2a3ef42015-12-15 13:49:30 -080026
asharifbb918502013-02-15 05:15:01 +000027def Main(argv):
Caroline Tice88272d42016-01-13 09:48:29 -080028 parser = argparse.ArgumentParser()
Caroline Ticef6ef4392017-04-06 17:16:05 -070029 parser.add_argument(
30 '-c',
31 '--chromeos_root',
32 dest='chromeos_root',
33 help='ChromeOS root checkout directory')
34 parser.add_argument(
35 '-r', '--remote', dest='remote', help='Remote chromeos device.')
Caroline Tice88272d42016-01-13 09:48:29 -080036 options = parser.parse_args(argv)
asharifbb918502013-02-15 05:15:01 +000037 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()
Caroline Ticef6ef4392017-04-06 17:16:05 -070047 ce.CrosRunCommand(
48 command, chromeos_root=options.chromeos_root, machine=options.remote)
asharifbb918502013-02-15 05:15:01 +000049
kbaclawski20082a02013-02-16 02:12:57 +000050 version_dir_path, script_name = misc.GetRoot(sys.argv[0])
51 version_dir = misc.GetRoot(version_dir_path)[1]
asharif29775b22013-02-15 05:15:38 +000052
53 # Tests to copy directories and files to the chromeos box.
Caroline Ticef6ef4392017-04-06 17:16:05 -070054 ce.CopyFiles(
55 version_dir_path,
56 '/tmp/' + version_dir,
57 dest_machine=options.remote,
58 dest_cros=True,
59 chromeos_root=options.chromeos_root)
60 ce.CopyFiles(
61 version_dir_path,
62 '/tmp/' + version_dir + '1',
63 dest_machine=options.remote,
64 dest_cros=True,
65 chromeos_root=options.chromeos_root)
66 ce.CopyFiles(
67 sys.argv[0],
68 '/tmp/' + script_name,
69 recursive=False,
70 dest_machine=options.remote,
71 dest_cros=True,
72 chromeos_root=options.chromeos_root)
73 ce.CopyFiles(
74 sys.argv[0],
75 '/tmp/' + script_name + '1',
76 recursive=False,
77 dest_machine=options.remote,
78 dest_cros=True,
79 chromeos_root=options.chromeos_root)
asharif29775b22013-02-15 05:15:38 +000080
81 # Test to copy directories and files from the chromeos box.
Caroline Ticef6ef4392017-04-06 17:16:05 -070082 ce.CopyFiles(
83 '/tmp/' + script_name,
84 '/tmp/hello',
85 recursive=False,
86 src_machine=options.remote,
87 src_cros=True,
88 chromeos_root=options.chromeos_root)
89 ce.CopyFiles(
90 '/tmp/' + script_name,
91 '/tmp/' + script_name,
92 recursive=False,
93 src_machine=options.remote,
94 src_cros=True,
95 chromeos_root=options.chromeos_root)
asharif6f4065c2013-02-15 09:04:02 +000096 board = ce.CrosLearnBoard(options.chromeos_root, options.remote)
Caroline Tice88272d42016-01-13 09:48:29 -080097 print(board)
asharif29775b22013-02-15 05:15:38 +000098 return 0
asharifbb918502013-02-15 05:15:01 +000099
100
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800101if __name__ == '__main__':
Caroline Tice88272d42016-01-13 09:48:29 -0800102 Main(sys.argv[1:])