Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7638adea authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Device cert: set up device in test script

Currently users have to set up the device with adb shell commands
manually. Move it to test script instead.

Test: cert/run_cert_facade_only.sh and run_device_cert.sh
Bug: 148147248
Change-Id: Id475bd550a46e8cd11ade0b72a5cb4032f55980e
parent 48268a8c
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -63,16 +63,17 @@ def get_instances_with_configs(configs):
            resolved_cmd.append(replace_vars(entry, config))
        devices.append(
            GdDevice(config["grpc_port"], config["grpc_root_server_port"],
                     config["signal_port"], resolved_cmd, config["label"]))
                     config["signal_port"], resolved_cmd, config["label"],
                     config.get("serial_number", "")))
    return devices


class GdDevice(GdDeviceBase):

    def __init__(self, grpc_port, grpc_root_server_port, signal_port, cmd,
                 label):
                 label, serial_number):
        super().__init__(grpc_port, grpc_root_server_port, signal_port, cmd,
                         label, ACTS_CONTROLLER_CONFIG_NAME)
                         label, ACTS_CONTROLLER_CONFIG_NAME, serial_number)

        # Facade stubs
        self.rootservice = facade_rootservice_pb2_grpc.RootFacadeStub(
+21 −1
Original line number Diff line number Diff line
@@ -25,11 +25,13 @@ import time

from acts import error
from acts import tracelogger
from acts.controllers.adb import AdbProxy

import grpc

ANDROID_BUILD_TOP = os.environ.get('ANDROID_BUILD_TOP')
ANDROID_HOST_OUT = os.environ.get('ANDROID_HOST_OUT')
ANDROID_PRODUCT_OUT = os.environ.get('ANDROID_PRODUCT_OUT')
WAIT_CHANNEL_READY_TIMEOUT = 10


@@ -54,7 +56,7 @@ def replace_vars(string, config):
class GdDeviceBase:

    def __init__(self, grpc_port, grpc_root_server_port, signal_port, cmd,
                 label, type_identifier):
                 label, type_identifier, serial_number):
        self.label = label if label is not None else grpc_port
        # logging.log_path only exists when this is used in an ACTS test run.
        log_path_base = getattr(logging, 'log_path', '/tmp/logs')
@@ -74,6 +76,24 @@ class GdDeviceBase:
                                        '%s_btsnoop_hci.log' % label)
            cmd.append("--btsnoop=" + btsnoop_path)

        if serial_number:
            ad = AdbProxy(serial_number)
            ad.tcp_forward(int(grpc_port), int(grpc_port))
            ad.tcp_forward(
                int(grpc_root_server_port), int(grpc_root_server_port))
            ad.reverse("tcp:%s tcp:%s" % (signal_port, signal_port))
            ad.push(
                os.path.join(ANDROID_PRODUCT_OUT,
                             "system/bin/bluetooth_stack_with_facade"),
                "system/bin")
            ad.push(
                os.path.join(ANDROID_PRODUCT_OUT,
                             "system/lib64/libbluetooth_gd.so"), "system/lib64")
            ad.push(
                os.path.join(ANDROID_PRODUCT_OUT,
                             "system/lib64/libgrpc++_unsecure.so"),
                "system/lib64")

        tester_signal_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        tester_signal_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
                                        1)
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@
unzip -u $ANDROID_BUILD_TOP/out/dist/bluetooth_cert_generated_py.zip -d $ANDROID_BUILD_TOP/out/dist/bluetooth_cert_generated_py

# For bluetooth_packets_python3
PYTHONPATH=$PYTHONPATH:$ANDROID_BUILD_TOP/out/host/linux-x86/lib64:$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_generated_py python3.8 `which act.py` -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/android_devices_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases_facade_only -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd
PYTHONPATH=$PYTHONPATH:$ANDROID_BUILD_TOP/out/host/linux-x86/lib64:$ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd:$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_generated_py python3.8 `which act.py` -c $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/android_devices_config.json -tf $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd/cert/cert_testcases_facade_only -tp $ANDROID_BUILD_TOP/packages/modules/Bluetooth/system/gd