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

Commit a217a398 authored by Jack He's avatar Jack He Committed by Chris Manton
Browse files

Cert: make sure we unregister controllers during teardown

* Controller unregisteration should be in a "finally" block to make sure
  it runs even when there is an exception or test failure

Bug: 197893665
Test: gd/cert/run
Tag: #gd-refactor
Change-Id: Ia038b461f373f1d774f0fa9307a793e546ebe001
parent 59e4d461
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -126,14 +126,15 @@ class GdBaseTestClass(base_test.BaseTestClass):
        self.cert.wait_channel_ready()

    def teardown_test(self):
        stack = ""
        try:
            stack = "CERT"
            self.cert.rootservice.StopStack(facade_rootservice.StopStackRequest())
        except RpcError as rpc_error:
            asserts.fail("Failed to stop CERT stack, RpcError={!r}".format(rpc_error))
        try:
            stack = "DUT"
            self.dut.rootservice.StopStack(facade_rootservice.StopStackRequest())
        except RpcError as rpc_error:
            asserts.fail("Failed to stop DUT stack, RpcError={!r}".format(rpc_error))
            asserts.fail("Failed to stop {} stack, RpcError={!r}".format(stack, rpc_error))
        finally:
            # Destroy GD device objects
            self._controller_manager.unregister_controllers()
            teardown_rootcanal(
+12 −11
Original line number Diff line number Diff line
@@ -132,14 +132,15 @@ class GdBaseTestClass(BaseTestClass):
        self.cert.wait_channel_ready()

    def teardown_test(self):
        stack = ""
        try:
            stack = "CERT"
            self.cert.rootservice.StopStack(facade_rootservice.StopStackRequest())
        except RpcError as rpc_error:
            asserts.fail("Failed to stop CERT stack, RpcError={!r}".format(rpc_error))
        try:
            stack = "DUT"
            self.dut.rootservice.StopStack(facade_rootservice.StopStackRequest())
        except RpcError as rpc_error:
            asserts.fail("Failed to stop DUT stack, RpcError={!r}".format(rpc_error))
            asserts.fail("Failed to stop {} stack, RpcError={!r}".format(stack, rpc_error))
        finally:
            # Destroy GD device objects
            self._controller_manager.unregister_controllers()
            teardown_rootcanal(