From 36cfb824a592c665dd2e97bdab33b369c58a81bf Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Wed, 26 Feb 2020 14:23:30 -0800 Subject: [PATCH] Some simplifications to ControllerTest Test: cert/run --host --test_filter=ControllerTest Change-Id: I75de2d62ebe38ebe5942d7ab3d430303f4da61b3 --- gd/cert/gd_device.py | 3 +++ gd/hci/cert/controller_test.py | 33 ++++++++++++++------------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/gd/cert/gd_device.py b/gd/cert/gd_device.py index cc0861f4a..50bb96f0f 100644 --- a/gd/cert/gd_device.py +++ b/gd/cert/gd_device.py @@ -28,6 +28,7 @@ from hci.facade import le_scanning_manager_facade_pb2_grpc from neighbor.facade import facade_pb2_grpc as neighbor_facade_pb2_grpc from l2cap.classic import facade_pb2_grpc as l2cap_facade_pb2_grpc from security import facade_pb2_grpc as security_facade_pb2_grpc +from google.protobuf import empty_pb2 as empty_proto ACTS_CONTROLLER_CONFIG_NAME = "GdDevice" ACTS_CONTROLLER_REFERENCE_NAME = "gd_devices" @@ -90,6 +91,8 @@ class GdDevice(GdDeviceBase): self.grpc_channel) self.hci_controller = controller_facade_pb2_grpc.ControllerFacadeStub( self.grpc_channel) + self.hci_controller.GetMacAddressSimple = lambda : self.hci_controller.GetMacAddress(empty_proto.Empty()).address + self.hci_controller.GetLocalNameSimple = lambda : self.hci_controller.GetLocalName(empty_proto.Empty()).name self.hci_le_advertising_manager = le_advertising_manager_facade_pb2_grpc.LeAdvertisingManagerFacadeStub( self.grpc_channel) self.hci_le_scanning_manager = le_scanning_manager_facade_pb2_grpc.LeScanningManagerFacadeStub( diff --git a/gd/hci/cert/controller_test.py b/gd/hci/cert/controller_test.py index 2ba93009c..9148d80bc 100644 --- a/gd/hci/cert/controller_test.py +++ b/gd/hci/cert/controller_test.py @@ -16,7 +16,7 @@ import time -from mobly import asserts +from mobly.asserts import assert_true from cert.gd_base_test_facade_only import GdFacadeOnlyBaseTestClass from google.protobuf import empty_pb2 as empty_proto from facade import rootservice_pb2 as facade_rootservice @@ -30,14 +30,12 @@ class ControllerTest(GdFacadeOnlyBaseTestClass): dut_module='HCI_INTERFACES', cert_module='HCI_INTERFACES') def test_get_addresses(self): - cert_address_response = self.cert.hci_controller.GetMacAddress( - empty_proto.Empty()) - dut_address_response = self.dut.hci_controller.GetMacAddress( - empty_proto.Empty()) - asserts.assert_true( - cert_address_response.address != dut_address_response.address, + cert_address = self.cert.hci_controller.GetMacAddressSimple() + dut_address = self.dut.hci_controller.GetMacAddressSimple() + assert_true( + cert_address != dut_address, msg="Expected cert and dut address to be different %s" % - cert_address_response.address) + cert_address) time.sleep(1) # This shouldn't be needed b/149120542 def test_get_local_extended_features(self): @@ -49,7 +47,7 @@ class ControllerTest(GdFacadeOnlyBaseTestClass): request0.page_number = 0 dut_feature_response0 = self.dut.hci_controller.GetLocalExtendedFeatures( request0) - asserts.assert_true( + assert_true( dut_feature_response1.page != dut_feature_response0.page, msg="Expected cert dut feature pages to be different %d" % dut_feature_response1.page) @@ -59,13 +57,10 @@ class ControllerTest(GdFacadeOnlyBaseTestClass): controller_facade.NameMsg(name=b'ImTheDUT')) self.cert.hci_controller.WriteLocalName( controller_facade.NameMsg(name=b'ImTheCert')) - cert_name_msg = self.cert.hci_controller.GetLocalName( - empty_proto.Empty()).name - dut_name_msg = self.dut.hci_controller.GetLocalName( - empty_proto.Empty()).name - asserts.assert_true( - dut_name_msg == b'ImTheDUT', - msg="unexpected dut name %s" % dut_name_msg) - asserts.assert_true( - cert_name_msg == b'ImTheCert', - msg="unexpected cert name %s" % cert_name_msg) + cert_name = self.cert.hci_controller.GetLocalNameSimple() + dut_name = self.dut.hci_controller.GetLocalNameSimple() + assert_true( + dut_name == b'ImTheDUT', msg="unexpected dut name %s" % dut_name) + assert_true( + cert_name == b'ImTheCert', + msg="unexpected cert name %s" % cert_name) -- 2.11.0