blob: 82f54ed53c504356a6e45cfa819723b7de512b73 [file] [log] [blame]
Caroline Tice88272d42016-01-13 09:48:29 -08001#!/usr/bin/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()
29 parser.add_argument('-c',
30 '--chromeos_root',
31 dest='chromeos_root',
32 help='ChromeOS root checkout directory')
33 parser.add_argument('-r',
34 '--remote',
35 dest='remote',
36 help='Remote chromeos device.')
37 options = parser.parse_args(argv)
asharifbb918502013-02-15 05:15:01 +000038 if options.chromeos_root is None:
Luis Lozanof2a3ef42015-12-15 13:49:30 -080039 Usage(parser, 'chromeos_root must be given')
asharifbb918502013-02-15 05:15:01 +000040
41 if options.remote is None:
Luis Lozanof2a3ef42015-12-15 13:49:30 -080042 Usage(parser, 'remote must be given')
asharifbb918502013-02-15 05:15:01 +000043
44 options.chromeos_root = os.path.expanduser(options.chromeos_root)
45
Luis Lozanof2a3ef42015-12-15 13:49:30 -080046 command = 'ls -lt /'
asharifbb918502013-02-15 05:15:01 +000047 ce = command_executer.GetCommandExecuter()
48 ce.CrosRunCommand(command,
49 chromeos_root=options.chromeos_root,
50 machine=options.remote)
51
kbaclawski20082a02013-02-16 02:12:57 +000052 version_dir_path, script_name = misc.GetRoot(sys.argv[0])
53 version_dir = misc.GetRoot(version_dir_path)[1]
asharif29775b22013-02-15 05:15:38 +000054
55 # Tests to copy directories and files to the chromeos box.
56 ce.CopyFiles(version_dir_path,
Luis Lozanof2a3ef42015-12-15 13:49:30 -080057 '/tmp/' + version_dir,
asharifbb918502013-02-15 05:15:01 +000058 dest_machine=options.remote,
59 dest_cros=True,
60 chromeos_root=options.chromeos_root)
asharif29775b22013-02-15 05:15:38 +000061 ce.CopyFiles(version_dir_path,
Luis Lozanof2a3ef42015-12-15 13:49:30 -080062 '/tmp/' + version_dir + '1',
asharif29775b22013-02-15 05:15:38 +000063 dest_machine=options.remote,
64 dest_cros=True,
65 chromeos_root=options.chromeos_root)
66 ce.CopyFiles(sys.argv[0],
Luis Lozanof2a3ef42015-12-15 13:49:30 -080067 '/tmp/' + script_name,
asharif29775b22013-02-15 05:15:38 +000068 recursive=False,
69 dest_machine=options.remote,
70 dest_cros=True,
71 chromeos_root=options.chromeos_root)
72 ce.CopyFiles(sys.argv[0],
Luis Lozanof2a3ef42015-12-15 13:49:30 -080073 '/tmp/' + script_name + '1',
asharif29775b22013-02-15 05:15:38 +000074 recursive=False,
75 dest_machine=options.remote,
76 dest_cros=True,
77 chromeos_root=options.chromeos_root)
78
79 # Test to copy directories and files from the chromeos box.
Luis Lozanof2a3ef42015-12-15 13:49:30 -080080 ce.CopyFiles('/tmp/' + script_name,
81 '/tmp/hello',
asharif29775b22013-02-15 05:15:38 +000082 recursive=False,
83 src_machine=options.remote,
84 src_cros=True,
85 chromeos_root=options.chromeos_root)
Luis Lozanof2a3ef42015-12-15 13:49:30 -080086 ce.CopyFiles('/tmp/' + script_name,
87 '/tmp/' + script_name,
asharif29775b22013-02-15 05:15:38 +000088 recursive=False,
89 src_machine=options.remote,
90 src_cros=True,
91 chromeos_root=options.chromeos_root)
asharif6f4065c2013-02-15 09:04:02 +000092 board = ce.CrosLearnBoard(options.chromeos_root, options.remote)
Caroline Tice88272d42016-01-13 09:48:29 -080093 print(board)
asharif29775b22013-02-15 05:15:38 +000094 return 0
asharifbb918502013-02-15 05:15:01 +000095
96
Luis Lozanof2a3ef42015-12-15 13:49:30 -080097if __name__ == '__main__':
Caroline Tice88272d42016-01-13 09:48:29 -080098 Main(sys.argv[1:])