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

Commit d4770583 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Cert Test: Stop using cert API protos and user layer N-1 to test layer N"

parents 8bf96901 9d4bd17a
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -177,7 +177,6 @@ cc_binary {
        "cert/grpc_root_server.cc",
        "cert/read_only_property_server.cc",
        "grpc/grpc_module.cc",
        ":BluetoothCertSource_hci_hal",
        ":BluetoothCertSource_hci_layer",
        ":BluetoothCertSource_l2cap_layer",
    ],
@@ -470,7 +469,6 @@ genrule {
    cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system/gd -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) $(in) --grpc_out=$(genDir) --python_out=$(genDir); " +
        "touch $(genDir)/facade/__init__.py; " +
        "touch $(genDir)/hal/__init__.py; " +
        "touch $(genDir)/hal/cert/__init__.py; " +
        "touch $(genDir)/hci/__init__.py; " +
        "touch $(genDir)/hci/facade/__init__.py; " +
        "touch $(genDir)/hci/cert/__init__.py; " +
@@ -500,9 +498,6 @@ genrule {
        "l2cap/classic/__init__.py",
        "l2cap/classic/facade_pb2_grpc.py",
        "l2cap/classic/facade_pb2.py",
        "hal/cert/__init__.py",
        "hal/cert/api_pb2_grpc.py",
        "hal/cert/api_pb2.py",
        "hci/cert/__init__.py",
        "hci/cert/api_pb2_grpc.py",
        "hci/cert/api_pb2.py",
@@ -516,7 +511,6 @@ filegroup {
    name: "BluetoothCertStackProto",
    srcs: [
        "cert/rootservice.proto",
        "hal/cert/api.proto",
        "hci/cert/api.proto",
        "l2cap/classic/cert/api.proto",
    ],
@@ -538,8 +532,6 @@ genrule {
        "cert/rootservice.pb.h",
        "facade/common.grpc.pb.h",
        "facade/common.pb.h",
        "hal/cert/api.grpc.pb.h",
        "hal/cert/api.pb.h",
        "hci/cert/api.grpc.pb.h",
        "hci/cert/api.pb.h",
        "l2cap/classic/cert/api.grpc.pb.h",
@@ -563,8 +555,6 @@ genrule {
        "cert/rootservice.pb.cc",
        "facade/common.grpc.pb.cc",
        "facade/common.pb.cc",
        "hal/cert/api.grpc.pb.cc",
        "hal/cert/api.pb.cc",
        "hci/cert/api.grpc.pb.cc",
        "hci/cert/api.pb.cc",
        "l2cap/classic/cert/api.grpc.pb.cc",
+0 −4
Original line number Diff line number Diff line
@@ -26,16 +26,12 @@
#include <thread>

#include "cert/grpc_root_server.h"
#include "grpc/grpc_module.h"
#include "hal/cert/cert.h"
#include "hal/hci_hal.h"
#include "hal/hci_hal_host_rootcanal.h"
#include "hal/snoop_logger.h"

using ::bluetooth::Module;
using ::bluetooth::ModuleList;
using ::bluetooth::StackManager;
using ::bluetooth::grpc::GrpcModule;
using ::bluetooth::os::Thread;

namespace {
+0 −1
Original line number Diff line number Diff line
SimpleHalTest
SimpleHciTest
SimpleL2capTest
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
SimpleHalTest
 No newline at end of file
+79 −0
Original line number 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 sys
import subprocess

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

sys.path.append(
    ANDROID_BUILD_TOP +
    '/out/soong/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothFacadeAndCertGeneratedStub_py/gen'
)

ANDROID_HOST_OUT = os.environ.get('ANDROID_HOST_OUT')
ROOTCANAL = ANDROID_HOST_OUT + "/nativetest64/root-canal/root-canal"


class GdFacadeOnlyBaseTestClass(BaseTestClass):

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

        log_path_base = configs.log_path
        gd_devices = self.controller_configs.get("GdDevice")

        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"))
            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

        self.register_controller(
            importlib.import_module('cert.gd_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
Loading