blob: 01f3fe89f6d96a59675c97bef02c7bd69eaa6860 [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#
Mike Frysingerfdcd39d2022-09-13 14:19:58 -04004# Copyright 2020 The ChromiumOS Authors
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
George Burgess IV74bd3802022-09-02 16:59:27 -070013
14__author__ = "asharif@google.com (Ahmad Sharif)"
asharifbb918502013-02-15 05:15:01 +000015
Caroline Tice88272d42016-01-13 09:48:29 -080016import argparse
asharifbb918502013-02-15 05:15:01 +000017import os
asharifbb918502013-02-15 05:15:01 +000018import sys
kbaclawski20082a02013-02-16 02:12:57 +000019
Caroline Tice88272d42016-01-13 09:48:29 -080020from cros_utils import command_executer
21from cros_utils import misc
asharifbb918502013-02-15 05:15:01 +000022
23
24def Usage(parser, message):
George Burgess IV74bd3802022-09-02 16:59:27 -070025 print("ERROR: %s" % message)
26 parser.print_help()
27 sys.exit(0)
asharifbb918502013-02-15 05:15:01 +000028
Luis Lozanof2a3ef42015-12-15 13:49:30 -080029
asharifbb918502013-02-15 05:15:01 +000030def Main(argv):
George Burgess IV74bd3802022-09-02 16:59:27 -070031 parser = argparse.ArgumentParser()
32 parser.add_argument(
33 "-c",
34 "--chromeos_root",
35 dest="chromeos_root",
36 help="ChromeOS root checkout directory",
37 )
38 parser.add_argument(
39 "-r", "--remote", dest="remote", help="Remote chromeos device."
40 )
41 options = parser.parse_args(argv)
42 if options.chromeos_root is None:
43 Usage(parser, "chromeos_root must be given")
asharifbb918502013-02-15 05:15:01 +000044
George Burgess IV74bd3802022-09-02 16:59:27 -070045 if options.remote is None:
46 Usage(parser, "remote must be given")
asharifbb918502013-02-15 05:15:01 +000047
George Burgess IV74bd3802022-09-02 16:59:27 -070048 options.chromeos_root = os.path.expanduser(options.chromeos_root)
asharifbb918502013-02-15 05:15:01 +000049
George Burgess IV74bd3802022-09-02 16:59:27 -070050 command = "ls -lt /"
51 ce = command_executer.GetCommandExecuter()
52 ce.CrosRunCommand(
53 command, chromeos_root=options.chromeos_root, machine=options.remote
54 )
asharifbb918502013-02-15 05:15:01 +000055
George Burgess IV74bd3802022-09-02 16:59:27 -070056 version_dir_path, script_name = misc.GetRoot(sys.argv[0])
57 version_dir = misc.GetRoot(version_dir_path)[1]
asharif29775b22013-02-15 05:15:38 +000058
George Burgess IV74bd3802022-09-02 16:59:27 -070059 # Tests to copy directories and files to the chromeos box.
60 ce.CopyFiles(
61 version_dir_path,
62 "/tmp/" + version_dir,
63 dest_machine=options.remote,
64 dest_cros=True,
65 chromeos_root=options.chromeos_root,
66 )
67 ce.CopyFiles(
68 version_dir_path,
69 "/tmp/" + version_dir + "1",
70 dest_machine=options.remote,
71 dest_cros=True,
72 chromeos_root=options.chromeos_root,
73 )
74 ce.CopyFiles(
75 sys.argv[0],
76 "/tmp/" + script_name,
77 recursive=False,
78 dest_machine=options.remote,
79 dest_cros=True,
80 chromeos_root=options.chromeos_root,
81 )
82 ce.CopyFiles(
83 sys.argv[0],
84 "/tmp/" + script_name + "1",
85 recursive=False,
86 dest_machine=options.remote,
87 dest_cros=True,
88 chromeos_root=options.chromeos_root,
89 )
asharif29775b22013-02-15 05:15:38 +000090
George Burgess IV74bd3802022-09-02 16:59:27 -070091 # Test to copy directories and files from the chromeos box.
92 ce.CopyFiles(
93 "/tmp/" + script_name,
94 "/tmp/hello",
95 recursive=False,
96 src_machine=options.remote,
97 src_cros=True,
98 chromeos_root=options.chromeos_root,
99 )
100 ce.CopyFiles(
101 "/tmp/" + script_name,
102 "/tmp/" + script_name,
103 recursive=False,
104 src_machine=options.remote,
105 src_cros=True,
106 chromeos_root=options.chromeos_root,
107 )
108 board = ce.CrosLearnBoard(options.chromeos_root, options.remote)
109 print(board)
110 return 0
asharifbb918502013-02-15 05:15:01 +0000111
112
George Burgess IV74bd3802022-09-02 16:59:27 -0700113if __name__ == "__main__":
114 Main(sys.argv[1:])