1# Copyright 2022 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5AUTHOR = 'ChromeOS SW Engprod Team ([email protected])' 6NAME = 'tast.nearby-share.local' 7TIME = 'MEDIUM' 8TEST_TYPE = 'Server' 9MAX_RESULT_SIZE_KB = 1024 * 1024 10PY_VERSION = 3 11 12# tast.py uses binaries installed from autotest_server_package.tar.bz2. 13REQUIRE_SSP = True 14 15DOC = '''Run the Tast Nearby Share test suites locally. 16 17This control file will setup the chromebook and android phone for you if you want to run locally. 18Locally means kicking off via test_that to run against either: 191. One of the scheduling units / RF boxes in the lab. 202. At your desk when using the chromebook as a fake labstation. 21You can use #2 to test the e2e adb-over-wifi flow without having a labstation at home. 22NOTE: Labstations store their adb keys at /var/lib/android_keys (and this gets wiped during login) so you need to click accept manually for the setups adb connection. 23 24You need to specify the wifi network details below that the chromebook and phone should be on together. 25Set <SET NETWORK NAME> to your SSID and <SET PASSWORD> to your network password. 26You also need to set the nearby share suite NAME 27Set <NEARBY SUITE NAME> to the suite you want to run. e.g nearby-share, nearby-share-arc, nearby-share-dev, nearby-share-prod 28 29These args are expected to be passed to test_that: 30--args="phone_station=$PHONE_HOST android_serial=$ANDROID_SERIAL_NUMBER" 31 32When using port forwarding to locahost, the expected args are: 33--args="phone_station=locahost android_station_ssh_port=$FORWARDED_PORT android_serial=$ANDROID_SERIAL_NUMBER" 34$FORWARDED_PORT is the port of the labstation that you port forwarded to localhost 35 36''' 37 38from autotest_lib.server import utils 39from autotest_lib.server.cros.crossdevice import cross_device_util 40 41def run(machine): 42 # Wifi details that chromebook will connect to. 43 ssid = '<SET NETWORK NAME>' 44 password = '<SET PASSWORD>' 45 46 # Get host objects for each device. 47 host = hosts.create_host(machine) 48 args_dict = utils.args_to_dict(args) 49 android_args = hosts.AndroidHost.get_android_arguments(args_dict) 50 phone = hosts.AndroidHost('local_phone', android_args=android_args) 51 52 # Configure devices for crossdevice tests. 53 cross_device_util.connect_to_wifi(host, ssid, password) 54 ip_address = phone.setup_for_cross_device_tests(adb_persist_reboot=True) 55 56 # Pass the phones adb-over-tcp "serial" (e.g 192.168.0.30:5555) to Tast as a global var. 57 ip_address_arg = 'crossdevice.PhoneIP=%s:5555' % ip_address 58 59 job.run_test('tast', 60 host=host, 61 test_exprs=['("group:<NEARBY SUITE NAME>")'], 62 ignore_test_failures=True, max_run_sec=10800, 63 command_args=args, 64 varslist=[ip_address_arg]) 65parallel_simple(run, machines) 66