aboutsummaryrefslogtreecommitdiff
path: root/remote_test.py
blob: 82f54ed53c504356a6e45cfa819723b7de512b73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/python2
#
# Copyright 2010 Google Inc. All Rights Reserved.
"""Script to wrap test_that script.

This script can login to the chromeos machine using the test private key.
"""

from __future__ import print_function

__author__ = 'asharif@google.com (Ahmad Sharif)'

import argparse
import os
import sys

from cros_utils import command_executer
from cros_utils import misc


def Usage(parser, message):
  print('ERROR: %s' % message)
  parser.print_help()
  sys.exit(0)


def Main(argv):
  parser = argparse.ArgumentParser()
  parser.add_argument('-c',
                      '--chromeos_root',
                      dest='chromeos_root',
                      help='ChromeOS root checkout directory')
  parser.add_argument('-r',
                      '--remote',
                      dest='remote',
                      help='Remote chromeos device.')
  options = parser.parse_args(argv)
  if options.chromeos_root is None:
    Usage(parser, 'chromeos_root must be given')

  if options.remote is None:
    Usage(parser, 'remote must be given')

  options.chromeos_root = os.path.expanduser(options.chromeos_root)

  command = 'ls -lt /'
  ce = command_executer.GetCommandExecuter()
  ce.CrosRunCommand(command,
                    chromeos_root=options.chromeos_root,
                    machine=options.remote)

  version_dir_path, script_name = misc.GetRoot(sys.argv[0])
  version_dir = misc.GetRoot(version_dir_path)[1]

  # Tests to copy directories and files to the chromeos box.
  ce.CopyFiles(version_dir_path,
               '/tmp/' + version_dir,
               dest_machine=options.remote,
               dest_cros=True,
               chromeos_root=options.chromeos_root)
  ce.CopyFiles(version_dir_path,
               '/tmp/' + version_dir + '1',
               dest_machine=options.remote,
               dest_cros=True,
               chromeos_root=options.chromeos_root)
  ce.CopyFiles(sys.argv[0],
               '/tmp/' + script_name,
               recursive=False,
               dest_machine=options.remote,
               dest_cros=True,
               chromeos_root=options.chromeos_root)
  ce.CopyFiles(sys.argv[0],
               '/tmp/' + script_name + '1',
               recursive=False,
               dest_machine=options.remote,
               dest_cros=True,
               chromeos_root=options.chromeos_root)

  # Test to copy directories and files from the chromeos box.
  ce.CopyFiles('/tmp/' + script_name,
               '/tmp/hello',
               recursive=False,
               src_machine=options.remote,
               src_cros=True,
               chromeos_root=options.chromeos_root)
  ce.CopyFiles('/tmp/' + script_name,
               '/tmp/' + script_name,
               recursive=False,
               src_machine=options.remote,
               src_cros=True,
               chromeos_root=options.chromeos_root)
  board = ce.CrosLearnBoard(options.chromeos_root, options.remote)
  print(board)
  return 0


if __name__ == '__main__':
  Main(sys.argv[1:])