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

Commit 662dbf45 authored by Jizheng Chu's avatar Jizheng Chu Committed by Jack He
Browse files

Construct and destroy rootcanal and gd device objects per test

Modify test setup and teardown such that, rootcanal process and gd device objects are constructed and destroyed for each test case instead of test class. And rootcanal logs and btsnoop logs will be captured for each test case.

Test: gd/cert/run
Bug: 194826691
Change-Id: If3aef425c0f3aa26fe37130406f9925e60ea85c0
parent 308e3545
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@ import traceback
from functools import wraps
from grpc import RpcError

from cert.gd_base_test_lib import setup_class_core
from cert.gd_base_test_lib import teardown_class_core
from cert.gd_base_test_lib import setup_rootcanal
from cert.gd_base_test_lib import teardown_rootcanal
from cert.gd_base_test_lib import setup_test_core
from cert.gd_base_test_lib import teardown_test_core
from cert.gd_base_test_lib import dump_crashes_core
@@ -40,20 +40,25 @@ class GdBaseTestClass(base_test.BaseTestClass):
    SUBPROCESS_WAIT_TIMEOUT_SECONDS = 10

    def setup_class(self, dut_module, cert_module):
        self.dut_module = dut_module
        self.cert_module = cert_module
        self.log = TraceLogger(logging.getLogger())

    def teardown_class(self):
        pass

    def setup_test(self):
        self.log_path_base = get_current_context().get_full_output_path()
        self.verbose_mode = bool(self.user_params.get('verbose_mode', False))
        for config in self.controller_configs[CONTROLLER_CONFIG_NAME]:
            config['verbose_mode'] = self.verbose_mode

        self.info = setup_class_core(
            dut_module=dut_module,
            cert_module=cert_module,
        self.info = setup_rootcanal(
            dut_module=self.dut_module,
            cert_module=self.cert_module,
            verbose_mode=self.verbose_mode,
            log_path_base=self.log_path_base,
            controller_configs=self.controller_configs)
        self.dut_module = self.info['dut_module']
        self.cert_module = self.info['cert_module']
        self.rootcanal_running = self.info['rootcanal_running']
        self.rootcanal_logpath = self.info['rootcanal_logpath']
        self.rootcanal_process = self.info['rootcanal_process']
@@ -78,18 +83,17 @@ class GdBaseTestClass(base_test.BaseTestClass):
        self.dut = self.gd_device[1]
        self.cert = self.gd_device[0]

    def teardown_class(self):
        teardown_class_core(
            rootcanal_running=self.rootcanal_running,
            rootcanal_process=self.rootcanal_process,
            rootcanal_logger=self.rootcanal_logger,
            subprocess_wait_timeout_seconds=self.SUBPROCESS_WAIT_TIMEOUT_SECONDS)

    def setup_test(self):
        setup_test_core(dut=self.dut, cert=self.cert, dut_module=self.dut_module, cert_module=self.cert_module)

    def teardown_test(self):
        teardown_test_core(cert=self.cert, dut=self.dut)
        # Destroy GD device objects
        self._controller_manager.unregister_controllers()
        teardown_rootcanal(
            rootcanal_running=self.rootcanal_running,
            rootcanal_process=self.rootcanal_process,
            rootcanal_logger=self.rootcanal_logger,
            subprocess_wait_timeout_seconds=self.SUBPROCESS_WAIT_TIMEOUT_SECONDS)

    @staticmethod
    def get_module_reference_name(a_module):
+19 −15
Original line number Diff line number Diff line
@@ -36,8 +36,8 @@ from cert.os_utils import make_ports_available
from cert.os_utils import TerminalColor
from cert.gd_device import MOBLY_CONTROLLER_CONFIG_NAME as CONTROLLER_CONFIG_NAME
from facade import rootservice_pb2 as facade_rootservice
from cert.gd_base_test_lib import setup_class_core
from cert.gd_base_test_lib import teardown_class_core
from cert.gd_base_test_lib import setup_rootcanal
from cert.gd_base_test_lib import teardown_rootcanal
from cert.gd_base_test_lib import setup_test_core
from cert.gd_base_test_lib import teardown_test_core
from cert.gd_base_test_lib import dump_crashes_core
@@ -48,19 +48,24 @@ class GdBaseTestClass(BaseTestClass):
    SUBPROCESS_WAIT_TIMEOUT_SECONDS = 10

    def setup_class(self, dut_module, cert_module):
        self.dut_module = dut_module
        self.cert_module = cert_module

    def teardown_class(self):
        pass

    def setup_test(self):
        self.log_path_base = get_current_context().get_full_output_path()
        self.verbose_mode = bool(self.user_params.get('verbose_mode', False))
        for config in self.controller_configs[CONTROLLER_CONFIG_NAME]:
            config['verbose_mode'] = self.verbose_mode

        self.info = setup_class_core(
            dut_module=dut_module,
            cert_module=cert_module,
        self.info = setup_rootcanal(
            dut_module=self.dut_module,
            cert_module=self.cert_module,
            verbose_mode=self.verbose_mode,
            log_path_base=self.log_path_base,
            controller_configs=self.controller_configs)
        self.dut_module = self.info['dut_module']
        self.cert_module = self.info['cert_module']
        self.rootcanal_running = self.info['rootcanal_running']
        self.rootcanal_logpath = self.info['rootcanal_logpath']
        self.rootcanal_process = self.info['rootcanal_process']
@@ -85,18 +90,17 @@ class GdBaseTestClass(BaseTestClass):
        self.dut = self.gd_devices[1]
        self.cert = self.gd_devices[0]

    def teardown_class(self):
        teardown_class_core(
            rootcanal_running=self.rootcanal_running,
            rootcanal_process=self.rootcanal_process,
            rootcanal_logger=self.rootcanal_logger,
            subprocess_wait_timeout_seconds=self.SUBPROCESS_WAIT_TIMEOUT_SECONDS)

    def setup_test(self):
        setup_test_core(dut=self.dut, cert=self.cert, dut_module=self.dut_module, cert_module=self.cert_module)

    def teardown_test(self):
        teardown_test_core(cert=self.cert, dut=self.dut)
        # Destroy GD device objects
        self._controller_manager.unregister_controllers()
        teardown_rootcanal(
            rootcanal_running=self.rootcanal_running,
            rootcanal_process=self.rootcanal_process,
            rootcanal_logger=self.rootcanal_logger,
            subprocess_wait_timeout_seconds=self.SUBPROCESS_WAIT_TIMEOUT_SECONDS)

    def __getattribute__(self, name):
        attr = super().__getattribute__(name)
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ from cert.gd_device import MOBLY_CONTROLLER_CONFIG_NAME as CONTROLLER_CONFIG_NAM
from facade import rootservice_pb2 as facade_rootservice


def setup_class_core(dut_module, cert_module, verbose_mode, log_path_base, controller_configs):
def setup_rootcanal(dut_module, cert_module, verbose_mode, log_path_base, controller_configs):
    info = {}
    info['dut_module'] = dut_module
    info['cert_module'] = cert_module
@@ -104,7 +104,7 @@ def setup_class_core(dut_module, cert_module, verbose_mode, log_path_base, contr
    return info


def teardown_class_core(rootcanal_running, rootcanal_process, rootcanal_logger, subprocess_wait_timeout_seconds):
def teardown_rootcanal(rootcanal_running, rootcanal_process, rootcanal_logger, subprocess_wait_timeout_seconds):
    if rootcanal_running:
        stop_signal = signal.SIGINT
        rootcanal_process.send_signal(stop_signal)