blob: 574d6762370e2325427ad295bd3e6808a6a9bb8f [file] [log] [blame]
Zhizhou Yang81d651f2020-02-10 16:51:20 -08001#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
asharifbb918502013-02-15 05:15:01 +00003#
George Burgess IV2124be52022-04-21 10:27:37 -07004# Copyright 2020 The ChromiumOS Authors. All rights reserved.
Zhizhou Yang81d651f2020-02-10 16:51:20 -08005# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
cmticed96e4572015-05-19 16:19:25 -07008"""Script to wrap test_that script.
asharifbb918502013-02-15 05:15:01 +00009
10This script can login to the chromeos machine using the test private key.
11"""
12
Caroline Tice88272d42016-01-13 09:48:29 -080013from __future__ import print_function
14
George Burgess IV74bd3802022-09-02 16:59:27 -070015
16__author__ = "asharif@google.com (Ahmad Sharif)"
asharifbb918502013-02-15 05:15:01 +000017
Caroline Tice88272d42016-01-13 09:48:29 -080018import argparse
asharifbb918502013-02-15 05:15:01 +000019import os
asharifbb918502013-02-15 05:15:01 +000020import sys
kbaclawski20082a02013-02-16 02:12:57 +000021
Caroline Tice88272d42016-01-13 09:48:29 -080022from cros_utils import command_executer
23from cros_utils import misc
asharifbb918502013-02-15 05:15:01 +000024
25
26def Usage(parser, message):
George Burgess IV74bd3802022-09-02 16:59:27 -070027 print("ERROR: %s" % message)
28 parser.print_help()
29 sys.exit(0)
asharifbb918502013-02-15 05:15:01 +000030
Luis Lozanof2a3ef42015-12-15 13:49:30 -080031
asharifbb918502013-02-15 05:15:01 +000032def Main(argv):
George Burgess IV74bd3802022-09-02 16:59:27 -070033 parser = argparse.ArgumentParser()
34 parser.add_argument(
35 "-c",
36 "--chromeos_root",
37 dest="chromeos_root",
38 help="ChromeOS root checkout directory",
39 )
40 parser.add_argument(
41 "-r", "--remote", dest="remote", help="Remote chromeos device."
42 )
43 options = parser.parse_args(argv)
44 if options.chromeos_root is None:
45 Usage(parser, "chromeos_root must be given")
asharifbb918502013-02-15 05:15:01 +000046
George Burgess IV74bd3802022-09-02 16:59:27 -070047 if options.remote is None:
48 Usage(parser, "remote must be given")
asharifbb918502013-02-15 05:15:01 +000049
George Burgess IV74bd3802022-09-02 16:59:27 -070050 options.chromeos_root = os.path.expanduser(options.chromeos_root)
asharifbb918502013-02-15 05:15:01 +000051
George Burgess IV74bd3802022-09-02 16:59:27 -070052 command = "ls -lt /"
53 ce = command_executer.GetCommandExecuter()
54 ce.CrosRunCommand(
55 command, chromeos_root=options.chromeos_root, machine=options.remote
56 )
asharifbb918502013-02-15 05:15:01 +000057
George Burgess IV74bd3802022-09-02 16:59:27 -070058 version_dir_path, script_name = misc.GetRoot(sys.argv[0])
59 version_dir = misc.GetRoot(version_dir_path)[1]
asharif29775b22013-02-15 05:15:38 +000060
George Burgess IV74bd3802022-09-02 16:59:27 -070061 # Tests to copy directories and files to the chromeos box.
62 ce.CopyFiles(
63 version_dir_path,
64 "/tmp/" + version_dir,
65 dest_machine=options.remote,
66 dest_cros=True,
67 chromeos_root=options.chromeos_root,
68 )
69 ce.CopyFiles(
70 version_dir_path,
71 "/tmp/" + version_dir + "1",
72 dest_machine=options.remote,
73 dest_cros=True,
74 chromeos_root=options.chromeos_root,
75 )
76 ce.CopyFiles(
77 sys.argv[0],
78 "/tmp/" + script_name,
79 recursive=False,
80 dest_machine=options.remote,
81 dest_cros=True,
82 chromeos_root=options.chromeos_root,
83 )
84 ce.CopyFiles(
85 sys.argv[0],
86 "/tmp/" + script_name + "1",
87 recursive=False,
88 dest_machine=options.remote,
89 dest_cros=True,
90 chromeos_root=options.chromeos_root,
91 )
asharif29775b22013-02-15 05:15:38 +000092
George Burgess IV74bd3802022-09-02 16:59:27 -070093 # Test to copy directories and files from the chromeos box.
94 ce.CopyFiles(
95 "/tmp/" + script_name,
96 "/tmp/hello",
97 recursive=False,
98 src_machine=options.remote,
99 src_cros=True,
100 chromeos_root=options.chromeos_root,
101 )
102 ce.CopyFiles(
103 "/tmp/" + script_name,
104 "/tmp/" + script_name,
105 recursive=False,
106 src_machine=options.remote,
107 src_cros=True,
108 chromeos_root=options.chromeos_root,
109 )
110 board = ce.CrosLearnBoard(options.chromeos_root, options.remote)
111 print(board)
112 return 0
asharifbb918502013-02-15 05:15:01 +0000113
114
George Burgess IV74bd3802022-09-02 16:59:27 -0700115if __name__ == "__main__":
116 Main(sys.argv[1:])