xref: /aosp_15_r20/external/autotest/server/site_tests/tast/control.nearby-share.local (revision 9c5db1993ded3edbeafc8092d69fe5de2ee02df7)
1*9c5db199SXin Li# Copyright 2022 The Chromium OS Authors. All rights reserved.
2*9c5db199SXin Li# Use of this source code is governed by a BSD-style license that can be
3*9c5db199SXin Li# found in the LICENSE file.
4*9c5db199SXin Li
5*9c5db199SXin LiAUTHOR = 'ChromeOS SW Engprod Team ([email protected])'
6*9c5db199SXin LiNAME = 'tast.nearby-share.local'
7*9c5db199SXin LiTIME = 'MEDIUM'
8*9c5db199SXin LiTEST_TYPE = 'Server'
9*9c5db199SXin LiMAX_RESULT_SIZE_KB = 1024 * 1024
10*9c5db199SXin LiPY_VERSION = 3
11*9c5db199SXin Li
12*9c5db199SXin Li# tast.py uses binaries installed from autotest_server_package.tar.bz2.
13*9c5db199SXin LiREQUIRE_SSP = True
14*9c5db199SXin Li
15*9c5db199SXin LiDOC = '''Run the Tast Nearby Share test suites locally.
16*9c5db199SXin Li
17*9c5db199SXin LiThis control file will setup the chromebook and android phone for you if you want to run locally.
18*9c5db199SXin LiLocally means kicking off via test_that to run against either:
19*9c5db199SXin Li1. One of the scheduling units / RF boxes in the lab.
20*9c5db199SXin Li2. At your desk when using the chromebook as a fake labstation.
21*9c5db199SXin LiYou can use #2 to test the e2e adb-over-wifi flow without having a labstation at home.
22*9c5db199SXin LiNOTE: 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*9c5db199SXin Li
24*9c5db199SXin LiYou need to specify the wifi network details below that the chromebook and phone should be on together.
25*9c5db199SXin LiSet <SET NETWORK NAME> to your SSID and <SET PASSWORD> to your network password.
26*9c5db199SXin LiYou also need to set the nearby share suite NAME
27*9c5db199SXin LiSet <NEARBY SUITE NAME> to the suite you want to run. e.g nearby-share, nearby-share-arc, nearby-share-dev, nearby-share-prod
28*9c5db199SXin Li
29*9c5db199SXin LiThese args are expected to be passed to test_that:
30*9c5db199SXin Li--args="phone_station=$PHONE_HOST android_serial=$ANDROID_SERIAL_NUMBER"
31*9c5db199SXin Li
32*9c5db199SXin LiWhen using port forwarding to locahost, the expected args are:
33*9c5db199SXin Li--args="phone_station=locahost android_station_ssh_port=$FORWARDED_PORT android_serial=$ANDROID_SERIAL_NUMBER"
34*9c5db199SXin Li$FORWARDED_PORT is the port of the labstation that you port forwarded to localhost
35*9c5db199SXin Li
36*9c5db199SXin Li'''
37*9c5db199SXin Li
38*9c5db199SXin Lifrom autotest_lib.server import utils
39*9c5db199SXin Lifrom autotest_lib.server.cros.crossdevice import cross_device_util
40*9c5db199SXin Li
41*9c5db199SXin Lidef run(machine):
42*9c5db199SXin Li    # Wifi details that chromebook will connect to.
43*9c5db199SXin Li    ssid = '<SET NETWORK NAME>'
44*9c5db199SXin Li    password = '<SET PASSWORD>'
45*9c5db199SXin Li
46*9c5db199SXin Li    # Get host objects for each device.
47*9c5db199SXin Li    host = hosts.create_host(machine)
48*9c5db199SXin Li    args_dict = utils.args_to_dict(args)
49*9c5db199SXin Li    android_args = hosts.AndroidHost.get_android_arguments(args_dict)
50*9c5db199SXin Li    phone = hosts.AndroidHost('local_phone', android_args=android_args)
51*9c5db199SXin Li
52*9c5db199SXin Li    # Configure devices for crossdevice tests.
53*9c5db199SXin Li    cross_device_util.connect_to_wifi(host, ssid, password)
54*9c5db199SXin Li    ip_address = phone.setup_for_cross_device_tests(adb_persist_reboot=True)
55*9c5db199SXin Li
56*9c5db199SXin Li    # Pass the phones adb-over-tcp "serial" (e.g 192.168.0.30:5555) to Tast as a global var.
57*9c5db199SXin Li    ip_address_arg = 'crossdevice.PhoneIP=%s:5555' % ip_address
58*9c5db199SXin Li
59*9c5db199SXin Li    job.run_test('tast',
60*9c5db199SXin Li                 host=host,
61*9c5db199SXin Li                 test_exprs=['("group:<NEARBY SUITE NAME>")'],
62*9c5db199SXin Li                 ignore_test_failures=True, max_run_sec=10800,
63*9c5db199SXin Li                 command_args=args,
64*9c5db199SXin Li                 varslist=[ip_address_arg])
65*9c5db199SXin Liparallel_simple(run, machines)
66