From dc24d4e9aa2a2965fabbb4513c0633d308fd4fbc Mon Sep 17 00:00:00 2001 From: Lyle Zhu Date: Mon, 22 Jul 2024 20:21:48 +0800 Subject: [PATCH] zephyr: support BR/EDR L2CAP test cases Enable the BR/EDR L2CAP Test cases. Add `Initial Condition` for the cases. Add specific windows handler for the L2CAP cases. Signed-off-by: Lyle Zhu --- autopts/ptsprojects/zephyr/l2cap.py | 744 +++++++++++++++++++++++- autopts/ptsprojects/zephyr/l2cap_wid.py | 387 ++++++++++++ 2 files changed, 1129 insertions(+), 2 deletions(-) create mode 100644 autopts/ptsprojects/zephyr/l2cap_wid.py diff --git a/autopts/ptsprojects/zephyr/l2cap.py b/autopts/ptsprojects/zephyr/l2cap.py index 5ddae6bd70..edbdb97bee 100644 --- a/autopts/ptsprojects/zephyr/l2cap.py +++ b/autopts/ptsprojects/zephyr/l2cap.py @@ -16,12 +16,12 @@ """L2CAP test cases""" from autopts.pybtp import btp -from autopts.pybtp.types import Addr, L2CAPConnectionResponse +from autopts.pybtp.types import Addr, L2CAPConnectionResponse, defs from autopts.client import get_unique_name -from autopts.wid import l2cap_wid_hdl from autopts.ptsprojects.stack import get_stack from autopts.ptsprojects.testcase import TestFunc from autopts.ptsprojects.zephyr.ztestcase import ZTestCase +from autopts.ptsprojects.zephyr.l2cap_wid import l2cap_wid_hdl le_psm = 128 @@ -29,6 +29,9 @@ le_initial_mtu = 120 le_initial_mtu_equal_mps = 96 +br_psm = 0x1001 +br_spsm = 129 +br_initial_mtu = 120 def set_pixits(ptses): """Setup L2CAP profile PIXITS for workspace. Those values are used for test @@ -163,6 +166,63 @@ def test_cases(ptses): TestFunc(btp.l2cap_le_listen, le_psm, le_initial_mtu, L2CAPConnectionResponse.insufficient_authorization)] + br_common = [TestFunc(btp.core_reg_svc_gap), + TestFunc(btp.core_reg_svc_l2cap), + TestFunc(btp.gap_read_ctrl_info), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_bd_addr_iut", + stack.gap.iut_addr_get_str())), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_bd_addr_iut_le", + stack.gap.iut_addr_get_str())), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_psm", format(br_psm, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_spsm", format(br_spsm, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_psm_authentication_required", format(br_psm, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_psm_authorization_required", format(br_psm, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_psm_encryption_key_size_required", format(br_psm, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_psm_encryption_required", format(br_psm, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_psm_unsupported", format(psm_unsupported, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_iut_supported_max_channels", "2")), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_l2ca_num_concurrent_credit_based_connections", "2")), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_l2ca_cbmps_min", format(64, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_l2ca_cbmps_max", format(256, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_l2ca_cbmtu_min", format(64, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_l2ca_cbmtu_max", format(256, '04x'))), + TestFunc(lambda: pts.update_pixit_param( + "L2CAP", "TSPX_iut_address_type_random", + "TRUE" if stack.gap.iut_addr_is_random() + else "FALSE")), + TestFunc(btp.set_pts_addr, pts_bd_addr, Addr.le_public), + TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_iut_role_initiator", "False")), + ] + + br_pre_conditions = br_common + [TestFunc(stack.l2cap_init, br_psm, br_initial_mtu)] + br_pre_conditions_success = br_common + [TestFunc(stack.l2cap_init, br_psm, br_initial_mtu), + TestFunc(btp.l2cap_listen, br_psm, defs.L2CAP_TRANSPORT_BREDR, br_initial_mtu, + L2CAPConnectionResponse.success)] + br_pre_conditions_authen = br_common + [TestFunc(stack.l2cap_init, br_psm, br_initial_mtu), + TestFunc(btp.l2cap_listen, br_psm, defs.L2CAP_TRANSPORT_BREDR, br_initial_mtu, + L2CAPConnectionResponse.insufficient_authentication)] + br_pre_conditions_keysize = br_common + [TestFunc(stack.l2cap_init, br_psm, br_initial_mtu), + TestFunc(btp.l2cap_listen, br_psm, defs.L2CAP_TRANSPORT_BREDR, br_initial_mtu, + L2CAPConnectionResponse.insufficient_encryption_key_size)] + br_pre_conditions_author = br_common + [TestFunc(stack.l2cap_init, br_psm, br_initial_mtu), + TestFunc(btp.l2cap_listen, br_psm, defs.L2CAP_TRANSPORT_BREDR, br_initial_mtu, + L2CAPConnectionResponse.insufficient_authorization)] + custom_test_cases = [ ZTestCase("L2CAP", "L2CAP/LE/CFC/BV-04-C", pre_conditions + @@ -227,6 +287,686 @@ def test_cases(ptses): [TestFunc(lambda: pts.update_pixit_param("L2CAP", "TSPX_iut_role_initiator", "False")), TestFunc(btp.core_reg_svc_gatt)], generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-07-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-08-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-09-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BI-01-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-01-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-02-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-03-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-11-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-12-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-14-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-08-C", + br_pre_conditions_success + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_iut_role_initiator", "True"))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-03-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-13-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-04-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/ECH/BV-02-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/ECH/BV-01-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/IEX/BV-01-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/IEX/BV-02-C", + br_pre_conditions_success, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CLS/CLR/BV-01-C", + br_pre_conditions_success + + [TestFunc(lambda: btp.l2cap_cls_listen(br_psm))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-10-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_RET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/RTX/BV-01-C", + br_pre_conditions, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/RTX/BV-02-C", + br_pre_conditions, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/RTX/BV-03-C", + br_pre_conditions, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-10-C", + br_pre_conditions + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_rfc_mode_tx_window_size", "02"))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/FLC/BV-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_FC, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/FLC/BV-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_FC, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/FLC/BV-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_FC, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/FLC/BV-04-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_FC, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-13-C", + br_pre_conditions, + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-08-C", + br_pre_conditions + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_iut_role_initiator", "True"))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-09-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-10-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-11-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-12-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-18-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-19-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-20-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/EXF/BV-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-04-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-05-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/STM/BV-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/STM/BV-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/EXF/BV-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_RET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/FOC/BV-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_RET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/FOC/BV-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_RET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/FOC/BV-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_RET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/OFS/BV-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/OFS/BV-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/OFS/BV-05-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/OFS/BV-06-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/OFS/BV-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/OFS/BV-04-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/OFS/BV-07-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/OFS/BV-08-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-07-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)] + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_generate_local_busy", "False"))] + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_iut_role_initiator", "True"))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-22-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_HOLD_CREDIT, + br_initial_mtu, + L2CAPConnectionResponse.success)] + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_generate_local_busy", "False"))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-16-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BI-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BI-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BI-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-12-C", + br_pre_conditions + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_iut_role_initiator", "True"))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BI-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BI-04-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-13-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_MODE_OPTIONAL, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-07-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_MODE_OPTIONAL, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-10-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_MODE_OPTIONAL, + br_initial_mtu, + L2CAPConnectionResponse.success)] + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_iut_role_initiator", "True"))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-06-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM|defs.L2CAP_LISTEN_OPT_MODE_OPTIONAL, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-08-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM|defs.L2CAP_LISTEN_OPT_MODE_OPTIONAL, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-11-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM|defs.L2CAP_LISTEN_OPT_MODE_OPTIONAL, + br_initial_mtu, + L2CAPConnectionResponse.success)] + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_iut_role_initiator", "True"))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-23-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/STM/BV-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-09-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_NONE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BI-05-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_NONE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BI-06-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_NONE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-14-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM|defs.L2CAP_LISTEN_OPT_MODE_OPTIONAL, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CMC/BV-15-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_STREAM|defs.L2CAP_LISTEN_OPT_MODE_OPTIONAL, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-05-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-06-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-13-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BI-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BI-04-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BI-05-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-14-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ERM/BV-15-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/EWC/BV-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/EWC/BV-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)] + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_iut_role_initiator", "True"))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/EWC/BV-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/EXF/BV-06-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ECF/BV-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ECF/BV-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ECF/BV-03-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ECF/BV-04-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ECF/BV-05-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ECF/BV-06-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ECF/BV-07-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/ECF/BV-08-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_ERET|defs.L2CAP_LISTEN_OPT_EXT_WIN_SIZE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-09-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_NONE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CFD/BV-01-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_NONE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-05-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_NONE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-12-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_NONE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BI-02-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_NONE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/COS/CED/BV-11-C", + br_pre_conditions + + [TestFunc(btp.l2cap_listen_with_mode, br_psm, defs.L2CAP_TRANSPORT_BREDR, + defs.L2CAP_LISTEN_OPT_NONE, + br_initial_mtu, + L2CAPConnectionResponse.success)], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CLS/UCD/BV-01-C", + br_pre_conditions_success + + [TestFunc(lambda: btp.l2cap_cls_listen(br_psm))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CLS/CID/BV-01-C", + br_pre_conditions_success + + [TestFunc(lambda: btp.l2cap_cls_listen(0x0081))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CLS/UCD/BV-02-C", + br_pre_conditions_success + + [TestFunc(lambda: btp.l2cap_cls_listen(br_psm))], + generic_wid_hdl=l2cap_wid_hdl), + ZTestCase("L2CAP", "L2CAP/CLS/UCD/BV-03-C", + br_pre_conditions_success + + [TestFunc(lambda: btp.l2cap_cls_listen(br_psm))] + + [TestFunc(lambda: pts.set_pixit("L2CAP", "TSPX_iut_role_initiator", "True"))], + generic_wid_hdl=l2cap_wid_hdl), ] test_case_name_list = pts.get_test_case_list('L2CAP') diff --git a/autopts/ptsprojects/zephyr/l2cap_wid.py b/autopts/ptsprojects/zephyr/l2cap_wid.py new file mode 100644 index 0000000000..dcde572082 --- /dev/null +++ b/autopts/ptsprojects/zephyr/l2cap_wid.py @@ -0,0 +1,387 @@ +# +# auto-pts - The Bluetooth PTS Automation Framework +# +# Copyright (c) 2017, Intel Corporation. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms and conditions of the GNU General Public License, +# version 2, as published by the Free Software Foundation. +# +# This program is distributed in the hope it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# + +import logging + +from autopts.wid import generic_wid_hdl +from autopts.pybtp.types import WIDParams, gap_settings_btp2txt, IOCap + +from autopts.pybtp import btp, defs + +from autopts.ptsprojects.stack import get_stack + +from time import sleep + +from threading import Timer, Event + +import re +import binascii + +log = logging.debug + + +def l2cap_wid_hdl(wid, description, test_case_name): + log(f'{l2cap_wid_hdl.__name__}, {wid}, {description}, {test_case_name}') + return generic_wid_hdl(wid, description, test_case_name, [__name__, 'autopts.wid.l2cap']) + +send_times = 0 + +def hdl_wid_113(params: WIDParams): + global send_times + if (params.test_case_name.startswith("L2CAP/COS/CED/BV-10-C")): + if send_times == 0: + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + btp.l2cap_send_data(0, 'FF' * 256) + send_times += 1 + return True + +def hdl_wid_116(params: WIDParams): + if params.test_case_name.startswith("L2CAP/EWC/BV-02-C"): + stack = get_stack() + l2cap = stack.l2cap + btp.gap_wait_for_connection() + sleep(2) + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_ERET) + return True + +def hdl_wid_118(_: WIDParams): + return True + +def hdl_wid_49(params: WIDParams): + btp.gap_conn_br() + btp.gap_wait_for_connection() + if not get_stack().gap.is_connected(): + return False + if (params.test_case_name.startswith("L2CAP/CLS/CLR/BV-01-C") or + params.test_case_name.startswith("L2CAP/CLS/UCD/BV-02-C") or + params.test_case_name.startswith("L2CAP/CLS/UCD/BV-03-C")): + return True + stack = get_stack() + l2cap = stack.l2cap + if (params.test_case_name.startswith("L2CAP/COS/CFD/BV-10-C") + or params.test_case_name.startswith("L2CAP/COS/RTX/BV-01-C") + or params.test_case_name.startswith("L2CAP/COS/RTX/BV-02-C") + or params.test_case_name.startswith("L2CAP/COS/RTX/BV-03-C") + ): + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_RET) + elif (params.test_case_name.startswith("L2CAP/COS/CED/BV-10-C") + # or params.test_case_name.startswith("L2CAP/COS/FLC/BV-01-C") + or params.test_case_name.startswith("L2CAP/COS/FLC/BV-02-C") + or params.test_case_name.startswith("L2CAP/COS/FLC/BV-03-C") + or params.test_case_name.startswith("L2CAP/COS/FLC/BV-04-C") + or params.test_case_name.startswith("L2CAP/COS/CFD/BV-13-C") + ): + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_FC) + pass + else: + btp.l2cap_conn(bd_addr=None, bd_addr_type=None, psm=0x1001,mtu=l2cap.initial_mtu) + return True + +def hdl_wid_23(_: WIDParams): + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + + btp.l2cap_send_data(0, 'FF' * channel.peer_mtu) + return True + +def hdl_wid_26(_: WIDParams): + btp.l2cap_echo(bd_addr=None, bd_addr_type=None) + return True + +def hdl_wid_50(_: WIDParams): + btp.l2cap_cls_send(bd_addr=None, bd_addr_type=None, psm=0x1001, val='FF', val_mtp=10) + return True + +def hdl_wid_1(params: WIDParams): + if (params.test_case_name.startswith("L2CAP/ERM/BV-13-C") or + params.test_case_name.startswith("L2CAP/ECF/BV-05-C")): + return True + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + if (params.test_case_name.startswith("L2CAP/ERM/BV-23-C") or + params.test_case_name.startswith("L2CAP/STM/BV-03-C")): + btp.l2cap_send_data(0, 'FF' * l2cap.initial_mtu) + else: + btp.l2cap_send_data(0, 'FF') + return True + +def hdl_wid_134(_: WIDParams): + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + btp.l2cap_send_data(0, 'FF' * 256) + return True + +def hdl_wid_114(_: WIDParams): + return True + +def hdl_wid_7(_: WIDParams): + return True + +def hdl_wid_35(params: WIDParams): + stack = get_stack() + l2cap = stack.l2cap + + pattern = r' [\d]+ ' + length = re.search(pattern, params.description)[0] + + data = l2cap.rx_data_get(0, 10) + if length and data[0]: + if int(length) == len(data[0]): + return True + + return False + +def hdl_wid_128(_: WIDParams): + return True + +def hdl_wid_15(params: WIDParams): + """ + Implements: TSC_MMI_tester_enable_connection + description: Action: Place the IUT in connectable mode. + """ + stack = btp.get_stack() + btp.gap_set_conn() + btp.gap_set_gendiscov() + btp.gap_adv_ind_on(ad=stack.gap.ad) + + if params.test_case_name.startswith("L2CAP/ERM/BV-08-C"): + stack = get_stack() + l2cap = stack.l2cap + btp.gap_wait_for_connection() + sleep(2) + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_ERET) + elif params.test_case_name.startswith("L2CAP/ERM/BV-07-C"): + stack = get_stack() + l2cap = stack.l2cap + btp.gap_wait_for_connection() + sleep(2) + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_ERET|defs.L2CAP_CONNECT_OPT_HOLD_CREDIT) + return True + +def hdl_wid_9(_: WIDParams): + return True + +def hdl_wid_130(_: WIDParams): + return True + +def hdl_wid_129(_: WIDParams): + return True + +def hdl_wid_32(_: WIDParams): + return True + +def hdl_wid_34(params: WIDParams): + stack = get_stack() + l2cap = stack.l2cap + + pattern = r' [\d]+ ' + length = re.search(pattern, params.description)[0] + + data = l2cap.rx_data_get(0, 10) + if length and data[0]: + if int(length) == len(data[0]): + l2cap.clear_data() + return True + + return False + +def hdl_wid_17(_: WIDParams): + return True + +def hdl_wid_8(_: WIDParams): + return True + +def hdl_wid_19(_: WIDParams): + return True + +def hdl_wid_18(_: WIDParams): + btp.l2cap_credits(0) + return True + +def hdl_wid_10(_: WIDParams): + return True + +def hdl_wid_131(_: WIDParams): + return True + +def hdl_wid_121(params: WIDParams): + if params.test_case_name.startswith("L2CAP/CMC/BV-12-C"): + stack = get_stack() + l2cap = stack.l2cap + btp.gap_wait_for_connection() + sleep(2) + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_ERET) + if params.test_case_name.startswith("L2CAP/CMC/BI-03-C"): + stack = get_stack() + l2cap = stack.l2cap + btp.gap_wait_for_connection() + sleep(2) + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_STREAM) + return True + +def hdl_wid_6(params: WIDParams): + if (params.test_case_name.startswith("L2CAP/CMC/BV-12-C") or + params.test_case_name.startswith("L2CAP/CMC/BI-03-C")): + stack = get_stack() + l2cap = stack.l2cap + if l2cap.wait_for_connection(10): + return False + return True + +def hdl_wid_115(_: WIDParams): + return True + +def hdl_wid_119(params: WIDParams): + if params.test_case_name.startswith("L2CAP/CMC/BV-10-C"): + stack = get_stack() + l2cap = stack.l2cap + btp.gap_wait_for_connection() + sleep(2) + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_ERET|defs.L2CAP_CONNECT_OPT_MODE_OPTIONAL) + if params.test_case_name.startswith("L2CAP/CMC/BV-11-C"): + stack = get_stack() + l2cap = stack.l2cap + btp.gap_wait_for_connection() + sleep(2) + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_STREAM|defs.L2CAP_CONNECT_OPT_MODE_OPTIONAL) + if params.test_case_name.startswith("L2CAP/EWC/BV-03-C"): + stack = get_stack() + l2cap = stack.l2cap + btp.gap_wait_for_connection() + sleep(2) + btp.l2cap_conn_with_mode(bd_addr=None, bd_addr_type=None, psm=0x1001, mtu=l2cap.initial_mtu, mode=defs.L2CAP_CONNECT_OPT_ERET) + return True + +def hdl_wid_20(_: WIDParams): + return True + + +def hdl_wid_2(_: WIDParams): + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + + btp.l2cap_send_data(0, 'FF' * channel.peer_mtu) + return True + +def hdl_wid_3(params: WIDParams): + if (params.test_case_name.startswith("L2CAP/ERM/BV-14-C")): + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + + pattern = r'[\d]+' + length = re.search(pattern, params.description)[0] + for i in range(0, int(length)): + btp.l2cap_send_data(0, 'FF') + return True + +def hdl_wid_124(_: WIDParams): + return True + +def hdl_wid_125(_: WIDParams): + return True + +def hdl_wid_4(params: WIDParams): + if (params.test_case_name.startswith("L2CAP/ECF/BV-02-C") or + params.test_case_name.startswith("L2CAP/ECF/BV-04-C")): + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + btp.l2cap_send_data(0, 'FF') + if (params.test_case_name.startswith("L2CAP/ECF/BV-08-C")): + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + btp.l2cap_send_data(0, 'FF' * l2cap.initial_mtu) + return True + + +def hdl_wid_24(params: WIDParams): + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + + pattern = r'[\d]+' + length = re.search(pattern, params.description)[0] + for i in range(0, int(length)): + btp.l2cap_send_data(0, 'FF') + return True + +def hdl_wid_25(params: WIDParams): + stack = get_stack() + l2cap = stack.l2cap + l2cap.wait_for_connection(0) + channel = l2cap.chan_lookup_id(0) + if not channel: + return False + + pattern = r'[\d]+' + length = re.search(pattern, params.description)[0] + for i in range(0, int(length)): + btp.l2cap_send_data(0, 'FF') + return True + +def hdl_wid_263(_: WIDParams): + stack = get_stack() + l2cap = stack.l2cap + btp.l2cap_conn(bd_addr=None, bd_addr_type=None, psm=0x1001,mtu=l2cap.initial_mtu) + return True + +def hdl_wid_265(_: WIDParams): + return True + +def hdl_wid_62(_: WIDParams): + btp.l2cap_cls_send(bd_addr=None, bd_addr_type=None, psm=0x1001, val='FF', val_mtp=10) + return True + +def hdl_wid_33(_: WIDParams): + btp.gap_wait_for_sec_lvl_change(level=2, timeout=10) + btp.gap_pair() + btp.gap_wait_for_sec_lvl_change(level=2, timeout=10) + btp.l2cap_cls_send(bd_addr=None, bd_addr_type=None, psm=0x1001, val='FF', val_mtp=10) + return True