remote_test.py revision d96e457132abf36c05936121e59acbab819ecd8e
1#!/usr/bin/python 2# 3# Copyright 2010 Google Inc. All Rights Reserved. 4 5"""Script to wrap test_that 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 16 17from utils import command_executer 18from utils import misc 19 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 47 version_dir_path, script_name = misc.GetRoot(sys.argv[0]) 48 version_dir = misc.GetRoot(version_dir_path)[1] 49 50 # Tests to copy directories and files to the chromeos box. 51 ce.CopyFiles(version_dir_path, 52 "/tmp/" + version_dir, 53 dest_machine=options.remote, 54 dest_cros=True, 55 chromeos_root=options.chromeos_root) 56 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) 87 board = ce.CrosLearnBoard(options.chromeos_root, options.remote) 88 print board 89 return 0 90 91 92if __name__ == "__main__": 93 Main(sys.argv) 94