blob: 98ff62a57c54efa5b0af92748b79ac49dc3818d7 [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#
Zhizhou Yang81d651f2020-02-10 16:51:20 -08004# Copyright 2020 The Chromium OS Authors. All rights reserved.
5# 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
Luis Lozanof2a3ef42015-12-15 13:49:30 -080015__author__ = 'asharif@google.com (Ahmad Sharif)'
asharifbb918502013-02-15 05:15:01 +000016
Caroline Tice88272d42016-01-13 09:48:29 -080017import argparse
asharifbb918502013-02-15 05:15:01 +000018import os
asharifbb918502013-02-15 05:15:01 +000019import sys
kbaclawski20082a02013-02-16 02:12:57 +000020
Caroline Tice88272d42016-01-13 09:48:29 -080021from cros_utils import command_executer
22from cros_utils import misc
asharifbb918502013-02-15 05:15:01 +000023
24
25def Usage(parser, message):
Caroline Tice88272d42016-01-13 09:48:29 -080026 print('ERROR: %s' % message)
asharifbb918502013-02-15 05:15:01 +000027 parser.print_help()
28 sys.exit(0)
29
Luis Lozanof2a3ef42015-12-15 13:49:30 -080030
asharifbb918502013-02-15 05:15:01 +000031def Main(argv):
Caroline Tice88272d42016-01-13 09:48:29 -080032 parser = argparse.ArgumentParser()
Caroline Ticef6ef4392017-04-06 17:16:05 -070033 parser.add_argument(
34 '-c',
35 '--chromeos_root',
36 dest='chromeos_root',
37 help='ChromeOS root checkout directory')
38 parser.add_argument(
39 '-r', '--remote', dest='remote', help='Remote chromeos device.')
Caroline Tice88272d42016-01-13 09:48:29 -080040 options = parser.parse_args(argv)
asharifbb918502013-02-15 05:15:01 +000041 if options.chromeos_root is None:
Luis Lozanof2a3ef42015-12-15 13:49:30 -080042 Usage(parser, 'chromeos_root must be given')
asharifbb918502013-02-15 05:15:01 +000043
44 if options.remote is None:
Luis Lozanof2a3ef42015-12-15 13:49:30 -080045 Usage(parser, 'remote must be given')
asharifbb918502013-02-15 05:15:01 +000046
47 options.chromeos_root = os.path.expanduser(options.chromeos_root)
48
Luis Lozanof2a3ef42015-12-15 13:49:30 -080049 command = 'ls -lt /'
asharifbb918502013-02-15 05:15:01 +000050 ce = command_executer.GetCommandExecuter()
Caroline Ticef6ef4392017-04-06 17:16:05 -070051 ce.CrosRunCommand(
52 command, chromeos_root=options.chromeos_root, machine=options.remote)
asharifbb918502013-02-15 05:15:01 +000053
kbaclawski20082a02013-02-16 02:12:57 +000054 version_dir_path, script_name = misc.GetRoot(sys.argv[0])
55 version_dir = misc.GetRoot(version_dir_path)[1]
asharif29775b22013-02-15 05:15:38 +000056
57 # Tests to copy directories and files to the chromeos box.
Caroline Ticef6ef4392017-04-06 17:16:05 -070058 ce.CopyFiles(
59 version_dir_path,
60 '/tmp/' + version_dir,
61 dest_machine=options.remote,
62 dest_cros=True,
63 chromeos_root=options.chromeos_root)
64 ce.CopyFiles(
65 version_dir_path,
66 '/tmp/' + version_dir + '1',
67 dest_machine=options.remote,
68 dest_cros=True,
69 chromeos_root=options.chromeos_root)
70 ce.CopyFiles(
71 sys.argv[0],
72 '/tmp/' + script_name,
73 recursive=False,
74 dest_machine=options.remote,
75 dest_cros=True,
76 chromeos_root=options.chromeos_root)
77 ce.CopyFiles(
78 sys.argv[0],
79 '/tmp/' + script_name + '1',
80 recursive=False,
81 dest_machine=options.remote,
82 dest_cros=True,
83 chromeos_root=options.chromeos_root)
asharif29775b22013-02-15 05:15:38 +000084
85 # Test to copy directories and files from the chromeos box.
Caroline Ticef6ef4392017-04-06 17:16:05 -070086 ce.CopyFiles(
87 '/tmp/' + script_name,
88 '/tmp/hello',
89 recursive=False,
90 src_machine=options.remote,
91 src_cros=True,
92 chromeos_root=options.chromeos_root)
93 ce.CopyFiles(
94 '/tmp/' + script_name,
95 '/tmp/' + script_name,
96 recursive=False,
97 src_machine=options.remote,
98 src_cros=True,
99 chromeos_root=options.chromeos_root)
asharif6f4065c2013-02-15 09:04:02 +0000100 board = ce.CrosLearnBoard(options.chromeos_root, options.remote)
Caroline Tice88272d42016-01-13 09:48:29 -0800101 print(board)
asharif29775b22013-02-15 05:15:38 +0000102 return 0
asharifbb918502013-02-15 05:15:01 +0000103
104
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800105if __name__ == '__main__':
Caroline Tice88272d42016-01-13 09:48:29 -0800106 Main(sys.argv[1:])