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

Commit 72314034 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge changes Idbae0672,I3b4e9294 am: f16846d0

Change-Id: Ia3398d683cc70276c8ffbb70678609ff98f6e98c
parents 1d3e9e6b f16846d0
Loading
Loading
Loading
Loading

system/gd/cert/gd_base_test.py

deleted100644 → 0
+0 −77
Original line number Original line Diff line number Diff line
#!/usr/bin/env python3
#
#   Copyright 2019 - The Android Open Source Project
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

from acts.base_test import BaseTestClass

import importlib
import logging
import os
import signal
import subprocess

ANDROID_BUILD_TOP = os.environ.get('ANDROID_BUILD_TOP')


class GdBaseTestClass(BaseTestClass):

    def __init__(self, configs):
        BaseTestClass.__init__(self, configs)

        log_path_base = getattr(configs, "log_path", "/tmp/logs")
        gd_devices = self.controller_configs.get("GdDevice")
        gd_cert_devices = self.controller_configs.get("GdCertDevice")

        self.rootcanal_running = False
        if 'rootcanal' in self.controller_configs:
            self.rootcanal_running = True
            rootcanal_logpath = os.path.join(log_path_base,
                                             'rootcanal_logs.txt')
            self.rootcanal_logs = open(rootcanal_logpath, 'w')
            rootcanal_config = self.controller_configs['rootcanal']
            rootcanal_hci_port = str(rootcanal_config.get("hci_port", "6402"))
            android_host_out = os.environ.get('ANDROID_HOST_OUT')
            rootcanal = android_host_out + "/nativetest64/root-canal/root-canal"
            self.rootcanal_process = subprocess.Popen(
                [
                    rootcanal,
                    str(rootcanal_config.get("test_port", "6401")),
                    rootcanal_hci_port,
                    str(rootcanal_config.get("link_layer_port", "6403"))
                ],
                cwd=ANDROID_BUILD_TOP,
                env=os.environ.copy(),
                stdout=self.rootcanal_logs,
                stderr=self.rootcanal_logs)
            for gd_device in gd_devices:
                gd_device["rootcanal_port"] = rootcanal_hci_port
            for gd_cert_device in gd_cert_devices:
                gd_cert_device["rootcanal_port"] = rootcanal_hci_port

        self.register_controller(
            importlib.import_module('cert.gd_device'), builtin=True)
        self.register_controller(
            importlib.import_module('cert.gd_cert_device'), builtin=True)

    def teardown_class(self):
        if self.rootcanal_running:
            self.rootcanal_process.send_signal(signal.SIGINT)
            rootcanal_return_code = self.rootcanal_process.wait()
            self.rootcanal_logs.close()
            if rootcanal_return_code != 0 and\
                rootcanal_return_code != -signal.SIGINT:
                logging.error(
                    "rootcanal stopped with code: %d" % rootcanal_return_code)
                return False
+1 −3
Original line number Original line Diff line number Diff line
@@ -15,7 +15,6 @@
#   limitations under the License.
#   limitations under the License.


from acts.base_test import BaseTestClass
from acts.base_test import BaseTestClass
from acts import context


import importlib
import importlib
import logging
import logging
@@ -30,13 +29,12 @@ class GdFacadeOnlyBaseTestClass(BaseTestClass):


    def setup_class(self):
    def setup_class(self):


        log_path_base = context.get_current_context().get_full_output_path()
        gd_devices = self.controller_configs.get("GdDevice")
        gd_devices = self.controller_configs.get("GdDevice")


        self.rootcanal_running = False
        self.rootcanal_running = False
        if 'rootcanal' in self.controller_configs:
        if 'rootcanal' in self.controller_configs:
            self.rootcanal_running = True
            self.rootcanal_running = True
            rootcanal_logpath = os.path.join(log_path_base,
            rootcanal_logpath = os.path.join(self.log_path,
                                             'rootcanal_logs.txt')
                                             'rootcanal_logs.txt')
            self.rootcanal_logs = open(rootcanal_logpath, 'w')
            self.rootcanal_logs = open(rootcanal_logpath, 'w')
            rootcanal_config = self.controller_configs['rootcanal']
            rootcanal_config = self.controller_configs['rootcanal']
+3 −3
Original line number Original line Diff line number Diff line
@@ -17,7 +17,7 @@
import logging
import logging


from facade import rootservice_pb2_grpc as facade_rootservice_pb2_grpc
from facade import rootservice_pb2_grpc as facade_rootservice_pb2_grpc
from cert.gd_device_base import GdDeviceBase, GdDeviceConfigError, replace_vars
from cert.gd_device_base import GdDeviceBase, replace_vars
from hal import facade_pb2_grpc as hal_facade_pb2_grpc
from hal import facade_pb2_grpc as hal_facade_pb2_grpc
from hci.facade import facade_pb2_grpc as hci_facade_pb2_grpc
from hci.facade import facade_pb2_grpc as hci_facade_pb2_grpc
from hci.facade import acl_manager_facade_pb2_grpc
from hci.facade import acl_manager_facade_pb2_grpc
@@ -35,9 +35,9 @@ ACTS_CONTROLLER_REFERENCE_NAME = "gd_devices"


def create(configs):
def create(configs):
    if not configs:
    if not configs:
        raise GdDeviceConfigError("Configuration is empty")
        raise Exception("Configuration is empty")
    elif not isinstance(configs, list):
    elif not isinstance(configs, list):
        raise GdDeviceConfigError("Configuration should be a list")
        raise Exception("Configuration should be a list")
    return get_instances_with_configs(configs)
    return get_instances_with_configs(configs)




+1 −22
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@ import socket
import subprocess
import subprocess
import time
import time


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


import grpc
import grpc
@@ -59,11 +59,6 @@ class GdDeviceBase:
        # logging.log_path only exists when this is used in an ACTS test run.
        # logging.log_path only exists when this is used in an ACTS test run.
        self.log_path_base = context.get_current_context().get_full_output_path(
        self.log_path_base = context.get_current_context().get_full_output_path(
        )
        )
        self.log = tracelogger.TraceLogger(
            GdDeviceBaseLoggerAdapter(logging.getLogger(), {
                'device': label,
                'type_identifier': type_identifier
            }))


        backing_process_logpath = os.path.join(
        backing_process_logpath = os.path.join(
            self.log_path_base,
            self.log_path_base,
@@ -146,19 +141,3 @@ class GdDeviceBase:
            future.result(timeout=WAIT_CHANNEL_READY_TIMEOUT)
            future.result(timeout=WAIT_CHANNEL_READY_TIMEOUT)
        except grpc.FutureTimeoutError:
        except grpc.FutureTimeoutError:
            logging.error("wait channel ready timeout")
            logging.error("wait channel ready timeout")


class GdDeviceBaseLoggerAdapter(logging.LoggerAdapter):

    def process(self, msg, kwargs):
        msg = "[%s|%s] %s" % (self.extra["type_identifier"],
                              self.extra["device"], msg)
        return (msg, kwargs)


class GdDeviceConfigError(Exception):
    """Raised when GdDevice configs are malformatted."""


class GdDeviceError(error.ActsError):
    """Raised when there is an error in GdDevice."""
+1 −0
Original line number Original line Diff line number Diff line
@@ -225,6 +225,7 @@ struct AclManager::impl {
    hci_layer_->UnregisterEventHandler(EventCode::READ_REMOTE_EXTENDED_FEATURES_COMPLETE);
    hci_layer_->UnregisterEventHandler(EventCode::READ_REMOTE_EXTENDED_FEATURES_COMPLETE);
    hci_queue_end_->UnregisterDequeue();
    hci_queue_end_->UnregisterDequeue();
    unregister_all_connections();
    unregister_all_connections();
    controller_->UnregisterCompletedAclPacketsCallback();
    acl_connections_.clear();
    acl_connections_.clear();
    hci_queue_end_ = nullptr;
    hci_queue_end_ = nullptr;
    handler_ = nullptr;
    handler_ = nullptr;
Loading