Beispiel #1
0
def hdl_wid_130(desc):
    if 'invalid MAC' in desc:
        return btp.gatts_verify_write_fail(desc)
    # GAP/SEC/CSIGN/BI-02-C expects two successes and fail
    # during first success check might occur second gatts_attr_value_changed_ev,
    # which will not be checked. Check up to three times if write fail occured
    for i in range(3):
        if not btp.gatts_verify_write_success(desc):
            return True
    return False
Beispiel #2
0
def hdl_wid_137(desc):
    return btp.gatts_verify_write_fail(desc)
Beispiel #3
0
def test_cases(pts):
    """Returns a list of GAP test cases
    pts -- Instance of PyPTS"""

    pts_bd_addr = pts.q_bd_addr

    stack = get_stack()

    stack.gap_init()

    # Set GAP common PIXIT values
    pts.update_pixit_param("GAP", "TSPX_delete_link_key", "TRUE")
    pts.update_pixit_param("GAP", "TSPX_using_public_device_address", "TRUE")
    pts.update_pixit_param("GAP", "TSPX_using_private_device_address", "FALSE")
    pts.update_pixit_param("GAP", "TSPX_iut_privacy_enabled", "FALSE")
    pts.update_pixit_param("GAP", "TSPX_using_random_device_address", "FALSE")

    pre_conditions = [
        TestFunc(btp.gap_read_ctrl_info),
        TestFunc(lambda: pts.update_pixit_param("GAP", "TSPX_bd_addr_iut",
                                                stack.gap.iut_addr_get_str())),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_iut_privacy_enabled", "TRUE"
            if stack.gap.iut_has_privacy() else "FALSE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_public_device_address", "FALSE"
            if stack.gap.iut_addr_is_random() else "TRUE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_private_device_address", "TRUE"
            if stack.gap.iut_addr_is_random() else "FALSE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_random_device_address", "TRUE"
            if stack.gap.iut_addr_is_random() else "FALSE")),

        # We do this on test case, because previous one could
        # update this if RPA was used by PTS
        # TODO: Get PTS address type
        TestFunc(btp.set_pts_addr, pts_bd_addr, Addr.le_public)
    ]

    test_cases = [
        BTestCase(
            "GAP", "GAP/BROB/BCST/BV-01-C", pre_conditions + [
                TestFunc(btp.gap_set_nonconn, start_wid=47),
                TestFunc(
                    btp.gap_adv_ind_on, start_wid=47, ad=[AdData.ad_manuf])
            ]),
        BTestCase(
            "GAP", "GAP/BROB/BCST/BV-02-C", pre_conditions + [
                TestFunc(btp.gap_set_nonconn),
                TestFunc(btp.gap_set_nondiscov),
                TestFunc(btp.gap_adv_ind_on, ad=[AdData.ad_manuf])
            ]),
        BTestCase(
            "GAP",
            "GAP/BROB/BCST/BV-03-C",
            edit1_wids={1002: btp.var_store_get_passkey},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),

                # Enter general discoverable mode and send connectable
                # event so that PTS could connect and get IRK
                TestFunc(btp.gap_set_nonconn),
                TestFunc(btp.gap_adv_ind_on, ad=[AdData.ad_manuf]),
                TestFunc(
                    pts.update_pixit_param, "GAP",
                    "TSPX_iut_device_name_in_adv_packet_for_random_address",
                    iut_device_name),
                TestFunc(btp.gap_wait_for_connection, post_wid=91),
                TestFunc(btp.gap_adv_off, post_wid=91),
                TestFunc(btp.gap_disconn, start_wid=77),

                # Enter broadcast mode
                TestFunc(btp.gap_set_nonconn, start_wid=80),
                TestFunc(btp.gap_set_nondiscov, start_wid=80),
                TestFunc(btp.gap_adv_ind_on,
                         sd=[AdData.ad_manuf, AdData.ad_name_sh],
                         start_wid=80)
            ]),
        # sleep to discover requested device
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-01-C",
                  ok_cancel_wids={4: (handle_wid_4)},
                  cmds=pre_conditions + [
                      TestFunc(sleep, 10, start_wid=4),
                      TestFunc(btp.gap_stop_discov, start_wid=4),
                      TestFunc(btp.gap_start_discov,
                               type='active',
                               mode='observe',
                               start_wid=12)
                  ]),
        # sleep to discover requested device
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-02-C",
                  ok_cancel_wids={4: (handle_wid_4)},
                  cmds=pre_conditions + [
                      TestFunc(sleep, 10, start_wid=4),
                      TestFunc(btp.gap_stop_discov, start_wid=4),
                      TestFunc(btp.gap_start_discov,
                               type='active',
                               mode='observe',
                               post_wid=169)
                  ]),
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-05-C",
                  verify_wids={157: (handle_wid_157)},
                  cmds=pre_conditions + [
                      TestFunc(btp.gap_start_discov,
                               'le',
                               'active',
                               'observe',
                               start_wid=157),
                      TestFunc(sleep, 10, start_wid=157),
                      TestFunc(btp.gap_stop_discov, start_wid=157)
                  ]),
        BTestCase(
            "GAP",
            "GAP/BROB/OBSV/BV-06-C",
            edit1_wids={1002: btp.var_store_get_passkey},
            verify_wids={138: (handle_wid_138)},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),

                # Set RPA update to 1 minute (60*1000=60000 ms)
                TestFunc(pts.update_pixit_param, "GAP",
                         "TSPX_iut_private_address_interval", '60000'),

                # Connect and pair to get IRK
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gap_pair, start_wid=108),
                TestFunc(btp.gap_start_discov,
                         'le',
                         'active',
                         'observe',
                         start_wid=138),
                TestFunc(sleep, 10, start_wid=138),
                TestFunc(btp.gap_stop_discov, start_wid=138)
            ]),
        BTestCase(
            "GAP", "GAP/DISC/NONM/BV-01-C", pre_conditions + [
                TestFunc(btp.gap_set_nonconn, start_wid=5),
                TestFunc(btp.gap_set_nondiscov, start_wid=5),
                TestFunc(btp.gap_adv_ind_on, start_wid=5)
            ]),
        BTestCase(
            "GAP", "GAP/DISC/NONM/BV-02-C", pre_conditions + [
                TestFunc(btp.gap_set_nondiscov, start_wid=72),
                TestFunc(btp.gap_adv_ind_on, start_wid=72)
            ]),
        BTestCase(
            "GAP", "GAP/DISC/GENM/BV-03-C", pre_conditions + [
                TestFunc(btp.gap_set_gendiscov),
                TestFunc(btp.gap_set_nonconn),
                TestFunc(btp.gap_adv_ind_on, start_wid=51)
            ]),
        BTestCase(
            "GAP", "GAP/DISC/GENM/BV-04-C", pre_conditions + [
                TestFunc(btp.gap_set_conn),
                TestFunc(btp.gap_set_gendiscov),
                TestFunc(btp.gap_adv_ind_on, start_wid=52)
            ]),
        BTestCase(
            "GAP",
            "GAP/DISC/LIMP/BV-01-C",
            ok_cancel_wids={10: (btp.check_discov_results)},
            cmds=pre_conditions +
            [TestFunc(btp.gap_start_discov, mode='limited', post_wid=13)]),
        BTestCase(
            "GAP",
            "GAP/DISC/LIMP/BV-02-C",
            ok_cancel_wids={11: (btp.check_discov_results, None, None, False)},
            cmds=pre_conditions +
            [TestFunc(btp.gap_start_discov, mode='limited', post_wid=13)]),
        BTestCase(
            "GAP",
            "GAP/DISC/LIMP/BV-03-C",
            ok_cancel_wids={11: (btp.check_discov_results, None, None, False)},
            cmds=pre_conditions +
            [TestFunc(btp.gap_start_discov, mode='limited', post_wid=13)]),
        BTestCase(
            "GAP",
            "GAP/DISC/LIMP/BV-04-C",
            ok_cancel_wids={11: (btp.check_discov_results, None, None, False)},
            cmds=pre_conditions +
            [TestFunc(btp.gap_start_discov, mode='limited', post_wid=13)]),
        BTestCase(
            "GAP",
            "GAP/DISC/LIMP/BV-05-C",
            ok_cancel_wids={11: (btp.check_discov_results, None, None, False)},
            cmds=pre_conditions +
            [TestFunc(btp.gap_start_discov, mode='limited', post_wid=13)]),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-01-C",
                  ok_cancel_wids={14: (handle_wid_14)},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_start_discov, post_wid=23)]),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-02-C",
                  ok_cancel_wids={14: (handle_wid_14)},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_start_discov, post_wid=23)]),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-03-C",
                  ok_cancel_wids={11: (handle_wid_11)},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_start_discov, post_wid=23)]),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-04-C",
                  ok_cancel_wids={11: (handle_wid_11)},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_start_discov, post_wid=23)]),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-05-C",
                  ok_cancel_wids={11: (handle_wid_11)},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_start_discov, post_wid=23)]),
        BTestCase(
            "GAP",
            "GAP/DISC/RPA/BV-01-C",
            edit1_wids={1002: btp.var_store_get_passkey},
            verify_wids={138: (handle_wid_138)},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),

                # Set RPA update to 1 minute (60*1000=60000 ms)
                TestFunc(pts.update_pixit_param, "GAP",
                         "TSPX_iut_private_address_interval", '60000'),

                # Connect and pair to get IRK
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gap_pair, start_wid=108),
                TestFunc(btp.gap_start_discov,
                         'le',
                         'active',
                         'general',
                         start_wid=138),
                TestFunc(sleep, 10, start_wid=138),
                TestFunc(btp.gap_stop_discov, start_wid=138)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/NCON/BV-01-C", pre_conditions +
            [TestFunc(btp.gap_set_nonconn),
             TestFunc(btp.gap_adv_ind_on)]),
        BTestCase(
            "GAP", "GAP/CONN/NCON/BV-02-C", pre_conditions + [
                TestFunc(btp.gap_set_nonconn, start_wid=122),
                TestFunc(
                    btp.gap_adv_ind_on, ad=[AdData.ad_name_sh], start_wid=54)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/UCON/BV-01-C", pre_conditions + [
                TestFunc(btp.gap_set_nondiscov, start_wid=74),
                TestFunc(btp.gap_adv_ind_on, start_wid=74)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/UCON/BV-02-C", pre_conditions + [
                TestFunc(btp.gap_set_gendiscov, start_wid=75),
                TestFunc(btp.gap_adv_ind_on, start_wid=75)
            ]),
        BTestCase(
            "GAP",
            "GAP/CONN/UCON/BV-06-C",
            edit1_wids={1002: btp.var_store_get_passkey},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_set_gendiscov, start_wid=91),
                TestFunc(btp.gap_adv_ind_on, start_wid=91),
                TestFunc(btp.gap_adv_off, start_wid=77),
                TestFunc(btp.gap_disconn, start_wid=77),

                # Apparently PTS don't take into account value of
                # TSPX_iut_private_address_interval, so let's simulate
                # change of RPA
                TestFunc(btp.gap_adv_off, start_wid=90),
                TestFunc(btp.gap_read_ctrl_info, start_wid=90),
                TestFunc(btp.gap_set_gendiscov, start_wid=90),
                TestFunc(btp.gap_adv_ind_on, start_wid=90)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/ACEP/BV-01-C", pre_conditions + [
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, post_wid=82),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/GCEP/BV-01-C", pre_conditions + [
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gap_disconn, start_wid=77)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/GCEP/BV-02-C", pre_conditions + [
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/DCEP/BV-01-C", pre_conditions + [
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/DCEP/BV-03-C", pre_conditions + [
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gap_disconn, start_wid=77)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/CPUP/BV-01-C",
            pre_conditions + [TestFunc(btp.gap_adv_ind_on, start_wid=21)]),
        BTestCase("GAP", "GAP/CONN/CPUP/BV-02-C",
                  pre_conditions + [TestFunc(btp.gap_adv_ind_on)]),
        BTestCase("GAP", "GAP/CONN/CPUP/BV-03-C",
                  pre_conditions + [TestFunc(btp.gap_adv_ind_on)]),
        BTestCase(
            "GAP", "GAP/CONN/CPUP/BV-04-C", pre_conditions + [
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=40),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/CPUP/BV-05-C", pre_conditions + [
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=40),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/CPUP/BV-06-C", pre_conditions + [
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=40),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/CPUP/BV-08-C", pre_conditions + [
                TestFunc(btp.gap_set_conn, start_wid=21),
                TestFunc(btp.gap_adv_ind_on, start_wid=21)
            ]),
        BTestCase(
            "GAP", "GAP/CONN/TERM/BV-01-C", pre_conditions + [
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP",
            "GAP/CONN/PRDA/BV-01-C",
            edit1_wids={1002:
                        (btp.var_store_get_passkey)},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_set_gendiscov, start_wid=91),
                TestFunc(
                    btp.gap_adv_ind_on, ad=[AdData.ad_name_sh], start_wid=91),
                TestFunc(btp.gap_identity_resolved_ev, post_wid=1002),
                TestFunc(btp.gap_adv_off, start_wid=77),
                TestFunc(btp.gap_disconn, start_wid=77)
            ]),
        BTestCase("GAP",
                  "GAP/CONN/PRDA/BV-02-C",
                  edit1_wids={1002: (btp.var_store_get_passkey)},
                  ok_cancel_wids={78: (btp.gap_rpa_conn)},
                  cmds=pre_conditions + [
                      TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                      TestFunc(btp.gap_pair, start_wid=108),
                      TestFunc(btp.gap_identity_resolved_ev, post_wid=1002),
                      TestFunc(btp.gap_conn, start_wid=142)
                  ]),
        BTestCase(
            "GAP", "GAP/BOND/NBON/BV-01-C", pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78)
            ]),
        BTestCase(
            "GAP", "GAP/BOND/NBON/BV-02-C", pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(
                    btp.gap_pair, pts_bd_addr, Addr.le_public, start_wid=100)
            ]),
        BTestCase(
            "GAP", "GAP/BOND/NBON/BV-03-C", pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_set_conn, start_wid=91),
                TestFunc(btp.gap_adv_ind_on, start_wid=91)
            ]),
        BTestCase(
            "GAP",
            "GAP/BOND/BON/BV-01-C",
            edit1_wids={1002:
                        btp.var_store_get_passkey},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_set_conn),
                TestFunc(btp.gap_adv_ind_on, start_wid=91),
                TestFunc(
                    btp.gap_pair, pts_bd_addr, Addr.le_public, start_wid=108)
            ]),
        BTestCase(
            "GAP",
            "GAP/BOND/BON/BV-02-C",
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(
                    btp.gap_pair, pts_bd_addr, Addr.le_public, start_wid=108)
            ]),
        BTestCase("GAP",
                  "GAP/BOND/BON/BV-03-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions + [
                      TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                      TestFunc(btp.gap_set_conn),
                      TestFunc(btp.gap_adv_ind_on, start_wid=91)
                  ]),
        BTestCase(
            "GAP",
            "GAP/BOND/BON/BV-04-C",
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(
                    btp.gap_pair, pts_bd_addr, Addr.le_public, start_wid=108),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-11-C",
                  edit1_wids={
                      139: "000C",
                      1002: btp.var_store_get_passkey
                  },
                  cmds=pre_conditions + init_gatt_db + [
                      TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                      TestFunc(btp.gap_set_conn, start_wid=91),
                      TestFunc(btp.gap_adv_ind_on, start_wid=91)
                  ]),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-12-C",
                  edit1_wids={
                      139: "000C",
                      1002: btp.var_store_get_passkey
                  },
                  cmds=pre_conditions + init_gatt_db + [
                      TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                      TestFunc(btp.gap_conn, start_wid=78)
                  ]),
        BTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-13-C",
            edit1_wids={
                139: "000C",
                1002:
                btp.var_store_get_passkey
            },
            cmds=pre_conditions + init_gatt_db + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78)
            ]),
        BTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-14-C",
            edit1_wids={
                139: "000C",
                1002:
                btp.var_store_get_passkey
            },
            cmds=pre_conditions + init_gatt_db + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_set_conn, start_wid=91),
                TestFunc(btp.gap_adv_ind_on, start_wid=91),
                TestFunc(btp.gap_set_io_cap, IOCap.display_only, start_wid=139)
            ]),
        BTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-17-C",
            cmds=pre_conditions + [
                TestFunc(btp.core_reg_svc_gatt),
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gattc_read,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         start_wid=112),
                # Bonding shall start automatically, so ignore wid: 108
                # "Please start the Bonding Procedure..."

                # Await read response after bonding
                TestFunc(btp.gattc_read_rsp, store_val=False, post_wid=108),
                TestFunc(btp.gap_disconn, start_wid=44)
            ]),
        BTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-19-C",
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gap_pair, start_wid=108, skip_call=(2, )),
                TestFunc(btp.gattc_read,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         start_wid=112),
                TestFunc(btp.gattc_read_rsp, store_val=False, post_wid=112),
                TestFunc(btp.gap_disconn, start_wid=44)
            ]),
        # TODO: Inform about lost bond
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-21-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions + [
                      TestFunc(btp.core_reg_svc_gatt),
                      TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                      TestFunc(btp.gap_conn, start_wid=78),
                      TestFunc(btp.gap_pair, start_wid=108),
                      TestFunc(btp.gap_disconn, start_wid=44)
                  ]),
        # TODO: Inform about lost bond
        BTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-22-C",
            edit1_wids={1002:
                        btp.var_store_get_passkey},
            cmds=pre_conditions + [
                TestFunc(btp.core_reg_svc_gatt),
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_set_conn, start_wid=91),
                TestFunc(btp.gap_adv_ind_on, start_wid=91),
                TestFunc(btp.gattc_read,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         start_wid=112),
                TestFunc(btp.gattc_read_rsp, store_val=False, start_wid=112),
                TestFunc(
                    btp.gap_pair, pts_bd_addr, Addr.le_public, start_wid=108)
            ]),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-23-C",
                  edit1_wids={
                      1002: btp.var_store_get_passkey,
                      144: "000C"
                  },
                  cmds=pre_conditions + init_gatt_db + [
                      TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                      TestFunc(btp.gap_set_conn),
                      TestFunc(btp.gap_adv_ind_on)
                  ]),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-24-C",
                  edit1_wids={
                      1002: btp.var_store_get_passkey,
                      144: "000C"
                  },
                  cmds=pre_conditions + init_gatt_db + [
                      TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                      TestFunc(btp.gap_conn, start_wid=78),
                      TestFunc(btp.gap_disconn, start_wid=44)
                  ]),
        BTestCase(
            "GAP", "GAP/SEC/CSIGN/BV-01-C", pre_conditions + [
                TestFunc(btp.core_reg_svc_gatt),
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(
                    btp.gap_pair, pts_bd_addr, Addr.le_public, start_wid=108),
                TestFunc(btp.gattc_signed_write,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         "01",
                         start_wid=125),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP",
            "GAP/SEC/CSIGN/BV-02-C",
            edit1_wids={161: handle_wid_161},
            verify_wids={141: btp.gatts_verify_write_success},
            cmds=init_gatt_db + pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_set_conn),
                TestFunc(btp.gap_adv_ind_on),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP",
            "GAP/SEC/CSIGN/BI-01-C",
            edit1_wids={161: handle_wid_161},
            verify_wids={130: btp.gatts_verify_write_fail},
            cmds=init_gatt_db + pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_set_conn),
                TestFunc(btp.gap_adv_ind_on),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase(
            "GAP",
            "GAP/SEC/CSIGN/BI-02-C",
            edit1_wids={161: handle_wid_161},
            verify_wids={
                130:
                lambda x: (btp.gatts_verify_write_success(x) and btp
                           .gatts_verify_write_success(
                               x) and btp.gatts_verify_write_fail(x))
            },
            cmds=init_gatt_db + pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_set_conn),
                TestFunc(btp.gap_adv_ind_on),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-03-C",
                  edit1_wids={161: handle_wid_161},
                  verify_wids={130: btp.gatts_verify_write_fail},
                  cmds=init_gatt_db + pre_conditions + [
                      TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                      TestFunc(btp.gap_set_gendiscov, start_wid=91),
                      TestFunc(btp.gap_set_conn, start_wid=91),
                      TestFunc(btp.gap_adv_ind_on, start_wid=91),
                      TestFunc(btp.gap_adv_off, post_wid=91),
                      TestFunc(btp.gap_disconn, start_wid=77),
                      TestFunc(btp.gap_unpair, start_wid=135)
                  ]),
        BTestCase(
            "GAP",
            "GAP/SEC/CSIGN/BI-04-C",
            edit1_wids={161: handle_wid_161},
            verify_wids={137: btp.gatts_verify_write_fail},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_set_conn),
                TestFunc(btp.gap_adv_ind_on),
                TestFunc(handle_wid_136_sec_csign_bi_04, start_wid=136),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        # BTestCase("GAP", "GAP/PRIV/CONN/BV-10-C",
        #           edit1_wids={1002: (btp.var_store_get_passkey, pts_bd_addr,
        #                              Addr.le_public)},
        #           cmds=pre_conditions +
        #                [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
        #                 TestFunc(
        #                     pts.update_pixit_param, "GAP",
        #                     "TSPX_iut_device_name_in_adv_packet_for_random_address",
        #                     iut_device_name),
        #
        #                 # Set RPA update to 15 minutes (15*60*1000=900000 ms)
        #                 TestFunc(pts.update_pixit_param, "GAP",
        #                          "TSPX_iut_private_address_interval",
        #                          '900000'),
        #                 TestFunc(btp.gap_set_conn),
        #                 TestFunc(btp.gap_set_gendiscov),
        #                 TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh]),
        #                 # Don't disable advertising here
        #                 TestFunc(btp.gap_disconn, start_wid=77)]),
        # Workaround BZ-197 and PTS issue #15170
        BTestCase(
            "GAP",
            "GAP/PRIV/CONN/BV-10-C",
            edit1_wids={1002: btp.var_store_get_passkey},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(
                    pts.update_pixit_param, "GAP",
                    "TSPX_iut_device_name_in_adv_packet_for_random_address",
                    iut_device_name),

                # Simulate RPA update every 10 seconds (10*1000=10000 ms)
                TestFunc(pts.update_pixit_param, "GAP",
                         "TSPX_iut_private_address_interval", '10000'),
                TestFunc(btp.gap_set_conn),
                TestFunc(btp.gap_set_gendiscov),

                # This step is used to speed up test execution, so
                # that RPA is updated every 10 seconds. This shall
                # be skipped on first wid: 91 requesting to send
                # advertising report. Here, we are disabling
                # previously started advertising, to generate new
                # RPA to be used when advertising is started again.
                TestFunc(btp.gap_adv_off, start_wid=91, skip_call=(1, )),
                TestFunc(sleep, 10, start_wid=91, skip_call=(1, )),
                TestFunc(btp.gap_read_ctrl_info, start_wid=91,
                         skip_call=(1, )),
                TestFunc(
                    btp.gap_adv_ind_on, ad=[AdData.ad_name_sh], start_wid=91),
                # Don't disable advertising here
                TestFunc(btp.gap_disconn, start_wid=77)
            ]),
        BTestCase(
            "GAP",
            "GAP/PRIV/CONN/BV-11-C",
            edit1_wids={1002: btp.var_store_get_passkey},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_conn, post_wid=78),
                TestFunc(btp.gap_pair, start_wid=108),
                TestFunc(btp.gap_conn, start_wid=2142),
                TestFunc(btp.gap_conn, start_wid=148)
            ],
            # Please confirm IUT does not perform the Connection
            # Establishment procedure since the resolvable private
            # address is incorrect.
            verify_wids={148: btp.verify_not_connected}),
        BTestCase(
            "GAP",
            "GAP/ADV/BV-01-C",
            cmds=pre_conditions +
            [TestFunc(btp.gap_set_conn),
             TestFunc(btp.gap_adv_ind_on, ad)]),
        BTestCase("GAP",
                  "GAP/ADV/BV-03-C",
                  cmds=pre_conditions + [
                      TestFunc(btp.gap_set_conn),
                      TestFunc(btp.gap_set_gendiscov),
                      TestFunc(btp.gap_adv_ind_on)
                  ]),
        BTestCase(
            "GAP",
            "GAP/ADV/BV-04-C",
            cmds=pre_conditions +
            [TestFunc(btp.gap_set_conn),
             TestFunc(btp.gap_adv_ind_on, ad)]),
        BTestCase(
            "GAP",
            "GAP/ADV/BV-05-C",
            cmds=pre_conditions +
            [TestFunc(btp.gap_set_conn),
             TestFunc(btp.gap_adv_ind_on, ad)]),
        BTestCase(
            "GAP",
            "GAP/ADV/BV-09-C",
            cmds=pre_conditions +
            [TestFunc(btp.gap_set_conn),
             TestFunc(btp.gap_adv_ind_on, ad)]),
        BTestCase(
            "GAP",
            "GAP/ADV/BV-10-C",
            cmds=pre_conditions +
            [TestFunc(btp.gap_set_conn),
             TestFunc(btp.gap_adv_ind_on, ad)]),
        BTestCase(
            "GAP",
            "GAP/ADV/BV-11-C",
            cmds=pre_conditions +
            [TestFunc(btp.gap_set_conn),
             TestFunc(btp.gap_adv_ind_on, ad)]),
        # GAP/GAT/BV-01-C
        # wid: 158 description: IUT support both Central and Peripheral roles.
        # Click Yes if IUT act as Central role to execute this test otherwise
        # click No to act as Peripheral role.
        #
        # Testing central role.
        BTestCase(
            "GAP",
            "GAP/GAT/BV-01-C",
            cmds=init_gatt_db + pre_conditions + [
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78)
            ]),
        # Testing peripheral role.
        BTestCase("GAP",
                  "GAP/GAT/BV-01-C",
                  no_wid=158,
                  cmds=init_gatt_db + pre_conditions + [
                      TestFunc(btp.gap_set_conn, start_wid=9),
                      TestFunc(btp.gap_adv_ind_on, start_wid=9)
                  ]),
    ]

    return test_cases
Beispiel #4
0
def test_cases(pts):
    """Returns a list of GAP test cases
    pts -- Instance of PyPTS"""

    pts_bd_addr = pts.q_bd_addr

    stack = get_stack()

    ad_str_flags = str(AdType.flags).zfill(2) + \
        str(AdFlags.br_edr_not_supp).zfill(2)
    ad_str_flags_len = str(len(ad_str_flags) / 2).zfill(2)
    ad_str_name_short = str(AdType.name_short).zfill(2) + \
        binascii.hexlify(iut_device_name)
    ad_str_name_short_len = str(len(ad_str_name_short) / 2).zfill(2)
    ad_pixit = ad_str_flags_len + ad_str_flags + ad_str_name_short_len + \
        ad_str_name_short

    # Set GAP common PIXIT values
    pts.update_pixit_param("GAP", "TSPX_delete_link_key", "TRUE")
    pts.update_pixit_param("GAP", "TSPX_advertising_data", ad_pixit)

    pre_conditions = [
        TestFunc(btp.core_reg_svc_gap),
        TestFunc(stack.gap_init, iut_device_name,
                 iut_manufacturer_data),
        TestFunc(btp.gap_read_ctrl_info),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_bd_addr_iut",
            stack.gap.iut_addr_get_str())),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_iut_privacy_enabled",
            "TRUE" if stack.gap.iut_has_privacy() else "FALSE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_public_device_address",
            "FALSE" if stack.gap.iut_addr_is_random() else "TRUE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_private_device_address",
            "TRUE" if stack.gap.iut_addr_is_random() else "FALSE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_random_device_address",
            "TRUE" if stack.gap.iut_addr_is_random() else "FALSE")),

        # We do this on test case, because previous one could update
        # this if RPA was used by PTS
        # TODO: Get PTS address type
        TestFunc(btp.set_pts_addr, pts_bd_addr, Addr.le_public)]

    test_cases = [
        ZTestCase("GAP", "GAP/BROB/BCST/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/BROB/BCST/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/BROB/BCST/BV-03-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(
                       pts.update_pixit_param, "GAP",
                       "TSPX_iut_device_name_in_adv_packet_for_random_address",
                       iut_device_name)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/BROB/OBSV/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/BROB/OBSV/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/BROB/OBSV/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/BROB/OBSV/BV-06-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   # Set RPA update to 1 minute (60*1000=60000 ms)
                   TestFunc(pts.update_pixit_param, "GAP",
                            "TSPX_iut_private_address_interval", '60000'),
                   TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78),
                   TestFunc(btp.gap_pair, start_wid=108),
                   TestFunc(btp.gap_start_discov, type='passive',
                            mode='observe', start_wid=204),
                   TestFunc(sleep, 10, start_wid=204),
                   TestFunc(btp.gap_stop_discov, start_wid=204),
                   TestFunc(btp.check_discov_results, discovered=True,
                            start_wid=204),
                   ],
                  ),
        ZTestCase("GAP", "GAP/DISC/NONM/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_nonconn, start_wid=5),
                   TestFunc(btp.gap_set_nondiscov, start_wid=5),
                   TestFunc(btp.gap_adv_ind_on, start_wid=5)]),
        ZTestCase("GAP", "GAP/DISC/NONM/BV-02-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_nondiscov, start_wid=72),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=72)]),
        ZTestCase("GAP", "GAP/DISC/LIMM/BV-03-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_nonconn),
                   TestFunc(btp.gap_set_limdiscov),
                   TestFunc(btp.gap_adv_ind_on, start_wid=59)]),
        ZTestCase("GAP", "GAP/DISC/LIMM/BV-04-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_set_limdiscov),
                   TestFunc(btp.gap_adv_ind_on, start_wid=50)]),
        ZTestCase("GAP", "GAP/DISC/GENM/BV-03-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_nonconn),
                   TestFunc(btp.gap_set_gendiscov),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=51)]),
        ZTestCase("GAP", "GAP/DISC/GENM/BV-04-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_set_gendiscov),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=52)]),
        ZTestCase("GAP", "GAP/DISC/LIMP/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/LIMP/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/LIMP/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/LIMP/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/LIMP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/GENP/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/GENP/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/GENP/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/GENP/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/GENP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/DISC/RPA/BV-01-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   # Set RPA update to 1 minute (60*1000=60000 ms)
                   TestFunc(pts.update_pixit_param, "GAP",
                            "TSPX_iut_private_address_interval", '60000'),
                   TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78),
                   TestFunc(btp.gap_pair, start_wid=108),
                   TestFunc(btp.gap_start_discov, type='passive',
                            mode='observe', start_wid=204),
                   TestFunc(sleep, 10, start_wid=204),
                   TestFunc(btp.gap_stop_discov, start_wid=204),
                   TestFunc(btp.check_discov_results, discovered=True,
                            start_wid=204)]),
        ZTestCase("GAP", "GAP/IDLE/NAMP/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.core_reg_svc_gatt),
                   TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78),
                   TestFunc(btp.gattc_disc_prim_uuid, Addr.le_public,
                            pts_bd_addr, UUID.gap_svc, start_wid=73),
                   TestFunc(btp.gattc_disc_prim_uuid_find_attrs_rsp,
                            (SVC.gap,), store_attrs=True, start_wid=73),
                   TestFunc(btp.gattc_disc_all_chrc, Addr.le_public,
                            pts_bd_addr, None, None, (SVC.gap, 1),
                            start_wid=73),
                   TestFunc(btp.gattc_disc_all_chrc_find_attrs_rsp,
                            (CHAR.name,), store_attrs=True, start_wid=73),
                   TestFunc(btp.gattc_read_char_val, Addr.le_public,
                            pts_bd_addr, (CHAR.name, 1), start_wid=73),
                   TestFunc(btp.gattc_read_rsp, start_wid=73),
                   TestFunc(btp.gap_disconn, pts_bd_addr, Addr.le_public,
                            start_wid=77)]),
        ZTestCase("GAP", "GAP/IDLE/NAMP/BV-02-C",
                  pre_conditions +
                  [TestFunc(btp.core_reg_svc_gatt),
                   TestFunc(btp.gatts_add_svc, 0, UUID.gap_svc),
                   TestFunc(btp.gatts_add_char, 0, Prop.read,
                            Perm.read | Perm.write, UUID.device_name),
                   TestFunc(btp.gatts_set_val, 0, '1234'),
                   TestFunc(btp.gatts_start_server),
                   TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78)]),
        ZTestCase("GAP", "GAP/CONN/NCON/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_nonconn),
                   TestFunc(btp.gap_adv_ind_on)]),
        ZTestCase("GAP", "GAP/CONN/NCON/BV-02-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_nonconn, start_wid=122),
                   TestFunc(btp.gap_set_gendiscov, start_wid=122),
                   TestFunc(btp.gap_adv_ind_on, start_wid=54)]),
        ZTestCase("GAP", "GAP/CONN/NCON/BV-03-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_nonconn, start_wid=121),
                   TestFunc(btp.gap_set_limdiscov, start_wid=121),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=55)]),
        ZTestCase("GAP", "GAP/CONN/UCON/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_nondiscov, start_wid=74),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=74)]),
        ZTestCase("GAP", "GAP/CONN/UCON/BV-02-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_gendiscov, start_wid=75),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=75)]),
        ZTestCase("GAP", "GAP/CONN/UCON/BV-03-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_limdiscov, start_wid=76),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=76)]),
        ZTestCase("GAP", "GAP/CONN/UCON/BV-06-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_set_gendiscov, start_wid=91),
                   TestFunc(btp.gap_adv_ind_on, start_wid=91),
                   TestFunc(btp.gap_wait_for_connection, start_wid=91),
                   TestFunc(btp.gap_disconn, start_wid=77),

                   # Apparently PTS don't take into account value of
                   # TSPX_iut_private_address_interval, so let's simulate
                   # change of RPA
                   TestFunc(btp.gap_adv_off, start_wid=90),
                   TestFunc(btp.gap_read_ctrl_info, start_wid=90),
                   TestFunc(btp.gap_set_gendiscov, start_wid=90),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=90)]),
        ZTestCase("GAP", "GAP/CONN/ACEP/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78),
                   TestFunc(btp.gap_disconn, pts_bd_addr, Addr.le_public,
                            start_wid=77)]),
        ZTestCase("GAP", "GAP/CONN/ACEP/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/CONN/ACEP/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/CONN/GCEP/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.gap_conn, start_wid=78),
                   TestFunc(btp.gap_disconn, start_wid=77)]),
        ZTestCase("GAP", "GAP/CONN/GCEP/BV-02-C",
                  pre_conditions +
                  [TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78),
                   TestFunc(btp.gap_disconn, pts_bd_addr, Addr.le_public,
                            start_wid=77)]),
        ZTestCase("GAP", "GAP/CONN/GCEP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/CONN/GCEP/BV-06-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/CONN/DCEP/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78),
                   TestFunc(btp.gap_disconn, pts_bd_addr, Addr.le_public,
                            start_wid=77)]),
        ZTestCase("GAP", "GAP/CONN/DCEP/BV-03-C",
                  pre_conditions +
                  [TestFunc(btp.gap_conn, start_wid=78),
                   TestFunc(btp.gap_disconn, start_wid=77)]),
        ZTestCase("GAP", "GAP/CONN/DCEP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/CONN/DCEP/BV-06-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/CONN/CPUP/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=21)]),
        ZTestCase("GAP", "GAP/CONN/CPUP/BV-02-C",
                  pre_conditions +
                  [TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh])]),
        ZTestCase("GAP", "GAP/CONN/CPUP/BV-03-C",
                  pre_conditions +
                  [TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh])]),
        ZTestCase("GAP", "GAP/CONN/CPUP/BV-04-C",
                  pre_conditions +
                  [TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=40),
                   TestFunc(btp.gap_disconn, pts_bd_addr, Addr.le_public,
                            start_wid=77)]),
        ZTestCase("GAP", "GAP/CONN/CPUP/BV-05-C",
                  pre_conditions +
                  [TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=40),
                   TestFunc(btp.gap_disconn, pts_bd_addr, Addr.le_public,
                            start_wid=77)]),
        ZTestCase("GAP", "GAP/CONN/CPUP/BV-08-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_conn, start_wid=21),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=21)]),
        ZTestCase("GAP", "GAP/CONN/TERM/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78),
                   TestFunc(btp.gap_disconn, pts_bd_addr, Addr.le_public,
                            start_wid=77)]),
        ZTestCase("GAP", "GAP/CONN/PRDA/BV-01-C",
                  edit1_wids={1002: (btp.var_store_get_passkey)},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_set_gendiscov, start_wid=91),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=91),
                   TestFunc(btp.gap_identity_resolved_ev, post_wid=1002),
                   TestFunc(btp.gap_disconn, start_wid=77)]),
        ZTestCase("GAP", "GAP/CONN/PRDA/BV-02-C",
                  edit1_wids={1002: (btp.var_store_get_passkey)},
                  ok_cancel_wids={174: (btp.gap_rpa_conn)},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_pair, start_wid=108),
                   TestFunc(btp.gap_identity_resolved_ev, post_wid=1002),
                   TestFunc(btp.gap_conn, start_wid=142)]),
        ZTestCase("GAP", "GAP/BOND/NBON/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                   TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78)]),
        ZTestCase("GAP", "GAP/BOND/NBON/BV-02-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                   TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78),
                   TestFunc(btp.gap_pair, pts_bd_addr, Addr.le_public,
                            start_wid=100)]),
        ZTestCase("GAP", "GAP/BOND/NBON/BV-03-C",
                  pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                   TestFunc(btp.gap_set_conn, start_wid=91),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=91), ]),
        ZTestCase("GAP", "GAP/BOND/BON/BV-01-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                         TestFunc(btp.gap_set_conn),
                         TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                                  start_wid=91),
                         TestFunc(btp.gap_pair, pts_bd_addr, Addr.le_public,
                                  start_wid=108)]),
        ZTestCase("GAP", "GAP/BOND/BON/BV-02-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                         TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                                  start_wid=78),
                         TestFunc(btp.gap_pair, pts_bd_addr, Addr.le_public,
                                  start_wid=108)]),
        ZTestCase("GAP", "GAP/BOND/BON/BV-03-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                         TestFunc(btp.gap_set_conn),
                         TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                                  start_wid=91)]),
        ZTestCase("GAP", "GAP/BOND/BON/BV-04-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                         TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                                  start_wid=78),
                         TestFunc(btp.gap_pair, pts_bd_addr, Addr.le_public,
                                  start_wid=108),
                         TestFunc(btp.gap_disconn, pts_bd_addr,
                                  Addr.le_public, start_wid=77)]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-11-C",
                  edit1_wids={139: __get_attr_u16_hdl_str(3),
                              1002: btp.var_store_get_passkey},
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                         TestFunc(btp.gap_set_conn, start_wid=91),
                         TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                                  start_wid=91)]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-12-C",
                  edit1_wids={139: __get_attr_u16_hdl_str(3),
                              1002: btp.var_store_get_passkey},
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                         TestFunc(btp.gap_conn, start_wid=78)]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-13-C",
                  edit1_wids={139: __get_attr_u16_hdl_str(3),
                              1002: btp.var_store_get_passkey},
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                         TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                                  start_wid=78)]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-14-C",
                  edit1_wids={139: __get_attr_u16_hdl_str(3),
                              1002: btp.var_store_get_passkey},
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                         TestFunc(btp.gap_set_conn, start_wid=91),
                         TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                                  start_wid=91),
                         TestFunc(btp.gap_set_io_cap, IOCap.display_only,
                                  start_wid=139)]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-17-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.core_reg_svc_gatt),
                   TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_conn, start_wid=78),
                   TestFunc(btp.gattc_read, Addr.le_public,
                            pts_bd_addr, "0001", start_wid=112),
                   # Bonding shall start automatically, so ignore wid: 108
                   # "Please start the Bonding Procedure..."

                   # Await read response after bonding
                   TestFunc(btp.gattc_read_rsp, store_val=False,
                            post_wid=108),
                   TestFunc(btp.gap_disconn, start_wid=44)]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-18-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.core_reg_svc_gatt),
                         TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                         TestFunc(btp.gap_set_conn),
                         TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh]),
                         TestFunc(btp.gattc_read, Addr.le_public,
                                  pts_bd_addr, "0001", start_wid=112),
                         TestFunc(btp.gattc_read_rsp, store_val=False,
                                  start_wid=112),
                         TestFunc(btp.gap_pair, pts_bd_addr, Addr.le_public,
                                  start_wid=108)]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-19-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_conn, start_wid=78),
                   TestFunc(btp.gap_pair, start_wid=108, skip_call=(2,)),
                   TestFunc(btp.gattc_read, Addr.le_public,
                            pts_bd_addr, "0001", start_wid=112),
                   TestFunc(btp.gattc_read_rsp, store_val=False,
                            post_wid=112),
                   TestFunc(btp.gap_disconn, start_wid=44)]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-20-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.core_reg_svc_gatt),
                         TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                         TestFunc(btp.gap_set_conn, start_wid=91),
                         TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                                  start_wid=91),
                         # This sleep is workaround, because apparently PTS is
                         # asking for service request before it receives
                         # HCI encryption change event.
                         TestFunc(sleep, 2, start_wid=112),
                         TestFunc(btp.gattc_read, Addr.le_public,
                                  pts_bd_addr, "0001", start_wid=112),
                         TestFunc(btp.gattc_read_rsp, store_val=False,
                                  start_wid=112)]),
        # TODO: Inform about lost bond
        ZTestCase("GAP", "GAP/SEC/AUT/BV-21-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.core_reg_svc_gatt),
                   TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_conn, start_wid=78),
                   TestFunc(btp.gap_pair, start_wid=108),
                   TestFunc(btp.gap_disconn, start_wid=44)]),
        # TODO: Inform about lost bond
        ZTestCase("GAP", "GAP/SEC/AUT/BV-22-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.core_reg_svc_gatt),
                   TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_set_conn, start_wid=91),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=91),
                   TestFunc(btp.gattc_read, Addr.le_public,
                            pts_bd_addr, "0001", start_wid=112),
                   TestFunc(btp.gattc_read_rsp, store_val=False,
                            start_wid=112),
                   TestFunc(btp.gap_pair, pts_bd_addr, Addr.le_public,
                            start_wid=108)]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-23-C",
                  edit1_wids={1002: btp.var_store_get_passkey,
                              144: __get_attr_u16_hdl_str(3)},
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh])]),
        ZTestCase("GAP", "GAP/SEC/AUT/BV-24-C",
                  edit1_wids={1002: btp.var_store_get_passkey,
                              144: __get_attr_u16_hdl_str(3)},
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_conn, start_wid=78),
                   TestFunc(btp.gap_disconn, start_wid=44)]),
        ZTestCase("GAP", "GAP/SEC/CSIGN/BV-01-C",
                  pre_conditions +
                  [TestFunc(btp.core_reg_svc_gatt),
                   TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                   TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78),
                   TestFunc(btp.gap_pair, pts_bd_addr, Addr.le_public,
                            start_wid=108),
                   TestFunc(btp.gattc_signed_write, Addr.le_public,
                            pts_bd_addr, "0001", "01", start_wid=125),
                   TestFunc(btp.gap_disconn, pts_bd_addr, Addr.le_public,
                            start_wid=77)]),
        ZTestCase("GAP", "GAP/SEC/CSIGN/BV-02-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/SEC/CSIGN/BI-01-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP", "GAP/SEC/CSIGN/BI-02-C",
                  edit1_wids={161: hdl_wid_161},
                  verify_wids={130: lambda x: (
                      btp.gatts_verify_write_success(x) and
                      btp.gatts_verify_write_success(x) and
                      btp.gatts_verify_write_fail(x))},
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                   TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh]),
                   TestFunc(btp.gap_disconn, pts_bd_addr, Addr.le_public,
                            start_wid=77)]),
        ZTestCase("GAP", "GAP/SEC/CSIGN/BI-03-C",
                  edit1_wids={161: hdl_wid_161},
                  verify_wids={130: btp.gatts_verify_write_fail},
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                   TestFunc(btp.gap_set_gendiscov, start_wid=91),
                   TestFunc(btp.gap_set_conn, start_wid=91),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=91),
                   TestFunc(btp.gap_wait_for_connection, post_wid=91),
                   TestFunc(btp.gap_adv_off, post_wid=91),
                   TestFunc(btp.gap_disconn, start_wid=77),
                   TestFunc(btp.gap_unpair, start_wid=135)]),
        ZTestCase("GAP", "GAP/SEC/CSIGN/BI-04-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        # ZTestCase("GAP", "GAP/PRIV/CONN/BV-10-C",
        #           edit1_wids={1002: (btp.var_store_get_passkey, pts_bd_addr,
        #                              Addr.le_public)},
        #           cmds=pre_conditions +
        #                [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
        #                 TestFunc(
        #                     pts.update_pixit_param, "GAP",
        #                     "TSPX_iut_device_name_in_adv_packet_for_random_address",
        #                     iut_device_name),
        #
        #                 # Set RPA update to 15 minutes (15*60*1000=900000 ms)
        #                 TestFunc(pts.update_pixit_param, "GAP",
        #                          "TSPX_iut_private_address_interval",
        #                          '900000'),
        #                 TestFunc(btp.gap_set_conn),
        #                 TestFunc(btp.gap_set_gendiscov),
        #                 TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh]),
        #                 # Don't disable advertising here
        #                 TestFunc(btp.gap_disconn, start_wid=77)]),
        # Workaround BZ-197 and PTS issue #15170
        ZTestCase("GAP", "GAP/PRIV/CONN/BV-10-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(
                       pts.update_pixit_param, "GAP",
                       "TSPX_iut_device_name_in_adv_packet_for_random_address",
                       iut_device_name),

                   # Simulate RPA update every 10 seconds (10*1000=10000 ms)
                   TestFunc(pts.update_pixit_param, "GAP",
                            "TSPX_iut_private_address_interval",
                            '10000'),
                   TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_set_gendiscov),

                   # This step is used to speed up test execution, so
                   # that RPA is updated every 10 seconds. This shall
                   # be skipped on first wid: 91 requesting to send
                   # advertising report. Here, we are disabling
                   # previously started advertising, to generate new
                   # RPA to be used when advertising is started again.
                   TestFunc(btp.gap_adv_off, start_wid=91,
                            skip_call=(1,)),
                   TestFunc(sleep, 10, start_wid=91, skip_call=(1,)),
                   TestFunc(btp.gap_read_ctrl_info, start_wid=91,
                            skip_call=(1,)),

                   TestFunc(btp.gap_adv_ind_on,
                            sd=[AdData.ad_name_sh], start_wid=91),
                   # Don't disable advertising here
                   TestFunc(btp.gap_disconn, start_wid=77)]),
        ZTestCase("GAP", "GAP/PRIV/CONN/BV-11-C",
                  edit1_wids={1002: btp.var_store_get_passkey},
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                   TestFunc(btp.gap_conn, post_wid=78),
                   TestFunc(btp.gap_pair, start_wid=108),
                   TestFunc(btp.gap_conn, start_wid=2142),
                   TestFunc(btp.gap_conn, start_wid=148)],
                  # Please confirm IUT does not perform the Connection
                  # Establishment procedure since the resolvable private
                  # address is incorrect.
                  verify_wids={148: btp.verify_not_connected}),
        ZTestCase("GAP", "GAP/ADV/BV-01-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_adv_ind_on, ad)]),
        ZTestCase("GAP", "GAP/ADV/BV-02-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_adv_ind_on, ad)]),
        ZTestCase("GAP", "GAP/ADV/BV-03-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_set_gendiscov),
                   TestFunc(btp.gap_adv_ind_on)]),
        ZTestCase("GAP", "GAP/ADV/BV-04-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_adv_ind_on, ad)]),
        ZTestCase("GAP", "GAP/ADV/BV-10-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_adv_ind_on, ad)]),
        ZTestCase("GAP", "GAP/ADV/BV-11-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_conn),
                   TestFunc(btp.gap_adv_ind_on, ad)]),
        # GAP/GAT/BV-01-C
        # wid: 158 description: IUT support both Central and Peripheral roles.
        # Click Yes if IUT act as Central role to execute this test otherwise
        # click No to act as Peripheral role.
        #
        # Testing central role.
        ZTestCase("GAP", "GAP/GAT/BV-01-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_conn, pts_bd_addr, Addr.le_public,
                            start_wid=78)]),
        # Testing peripheral role.
        ZTestCase("GAP", "GAP/GAT/BV-01-C",
                  no_wid=158,
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_conn, start_wid=9),
                   TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh],
                            start_wid=9)]),
    ]

    return test_cases
Beispiel #5
0
def test_cases(pts):
    """Returns a list of GAP test cases
    pts -- Instance of PyPTS"""

    pts_bd_addr = pts.q_bd_addr

    stack = get_stack()

    pre_conditions = [
        TestFunc(btp.core_reg_svc_gap),
        TestFunc(btp.gap_reset),
        TestFunc(stack.gap_init, iut_device_name, iut_manufacturer_data,
                 iut_appearance, iut_svc_data, iut_flags, iut_svcs),
        TestFunc(btp.gap_read_ctrl_info),
        TestFunc(btp.gap_set_bondable_on),
        TestFunc(lambda: pts.update_pixit_param("GAP", "TSPX_bd_addr_iut",
                                                stack.gap.iut_addr_get_str())),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_iut_privacy_enabled", "TRUE"
            if stack.gap.iut_has_privacy() else "FALSE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_public_device_address", "FALSE"
            if stack.gap.iut_addr_is_random() else "TRUE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_private_device_address", "TRUE"
            if stack.gap.iut_addr_is_random() else "FALSE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_random_device_address", "TRUE"
            if stack.gap.iut_addr_is_random() else "FALSE")),

        # We do this on test case, because previous one could
        # update this if RPA was used by PTS
        # TODO: Get PTS address type
        TestFunc(btp.set_pts_addr, pts_bd_addr, Addr.le_public)
    ]

    test_cases = [
        BTestCase("GAP",
                  "GAP/BROB/BCST/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/BCST/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/BCST/BV-03-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/BCST/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/BCST/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-06-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/NONM/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/NONM/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/LIMM/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/LIMM/BV-04-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/GENM/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/GENM/BV-04-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/LIMP/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/LIMP/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/LIMP/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/LIMP/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/LIMP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/GENP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/DISC/RPA/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase(
            "GAP", "GAP/IDLE/NAMP/BV-01-C", pre_conditions + [
                TestFunc(btp.core_reg_svc_gatt),
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(btp.gattc_read_uuid,
                         Addr.le_public,
                         pts_bd_addr,
                         '0001',
                         'FFFF',
                         UUID.device_name,
                         start_wid=73),
                TestFunc(btp.gattc_read_uuid_rsp, post_wid=73),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase("GAP",
                  "GAP/IDLE/NAMP/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/NCON/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/NCON/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/NCON/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/UCON/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/UCON/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/UCON/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/UCON/BV-06-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/ACEP/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/ACEP/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/ACEP/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/GCEP/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/GCEP/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/GCEP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/GCEP/BV-06-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/DCEP/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/DCEP/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/DCEP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/DCEP/BV-06-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/CPUP/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/CPUP/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/CPUP/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/CPUP/BV-04-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/CPUP/BV-05-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/CPUP/BV-06-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/CPUP/BV-08-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/TERM/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/PRDA/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/CONN/PRDA/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/NBON/BV-01-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/NBON/BV-02-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/NBON/BV-03-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/BON/BV-01-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/BON/BV-02-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/BON/BV-03-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/BON/BV-04-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-11-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-12-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-13-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-14-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-17-C",
            cmds=pre_conditions + [
                TestFunc(btp.core_reg_svc_gatt),
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gattc_read,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         start_wid=112),
                # Bonding shall start automatically, so ignore wid: 108
                # "Please start the Bonding Procedure..."

                # Await read response after bonding
                TestFunc(btp.gattc_read_rsp, store_val=False, post_wid=108),
                TestFunc(btp.gap_disconn, start_wid=44)
            ]),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-18-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-19-C",
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gap_pair, start_wid=108, skip_call=(2, )),
                TestFunc(btp.gattc_read,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         start_wid=112),
                TestFunc(btp.gattc_read_rsp, store_val=False, post_wid=112),
                TestFunc(btp.gap_disconn, start_wid=44)
            ]),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-20-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-21-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        # TODO: Inform about lost bond
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-22-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-23-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-24-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BV-01-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BV-02-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-01-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase(
            "GAP",
            "GAP/SEC/CSIGN/BI-02-C",
            edit1_wids={161: hdl_wid_161},
            verify_wids={
                130:
                lambda x: (btp.gatts_verify_write_success(x) and btp
                           .gatts_verify_write_success(
                               x) and btp.gatts_verify_write_fail(x))
            },
            cmds=pre_conditions + init_gatt_db + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_set_conn),
                TestFunc(lambda: btp.gap_adv_ind_on(ad=get_stack().gap.ad,
                                                    sd=get_stack().gap.sd)),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-03-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-04-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/PRIV/CONN/BV-10-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/PRIV/CONN/BV-11-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/PRIV/CONN/BI-01-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-08-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-09-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-10-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-11-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-12-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-13-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-14-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-15-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-16-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/ADV/BV-17-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        # GAP/GAT/BV-01-C
        # wid: 158 description: IUT support both Central and Peripheral roles.
        # Click Yes if IUT act as Central role to execute this test otherwise
        # click No to act as Peripheral role.
        #
        # Testing central role.
        BTestCase("GAP",
                  "GAP/GAT/BV-01-C",
                  cmds=pre_conditions + init_gatt_db,
                  generic_wid_hdl=gap_wid_hdl),
        # Testing peripheral role.
        BTestCase(
            "GAP",
            "GAP/GAT/BV-01-C",
            #   no_wid=158,
            cmds=pre_conditions + init_gatt_db,
            generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/GAT/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/GAT/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
    ]

    return test_cases
Beispiel #6
0
def test_cases(pts):
    """Returns a list of GAP test cases
    pts -- Instance of PyPTS"""

    pts_bd_addr = pts.q_bd_addr

    stack = get_stack()

    pre_conditions = [
        TestFunc(btp.core_reg_svc_gap),
        TestFunc(stack.gap_init, iut_device_name, iut_manufacturer_data,
                 iut_appearance, iut_svc_data, iut_flags, iut_svcs),
        TestFunc(btp.gap_read_ctrl_info),
        TestFunc(lambda: pts.update_pixit_param("GAP", "TSPX_bd_addr_iut",
                                                stack.gap.iut_addr_get_str())),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_iut_privacy_enabled", "TRUE"
            if stack.gap.iut_has_privacy() else "FALSE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_public_device_address", "FALSE"
            if stack.gap.iut_addr_is_random() else "TRUE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_random_device_address", "TRUE"
            if stack.gap.iut_addr_is_random() else "FALSE")),

        # We do this on test case, because previous one could update
        # this if RPA was used by PTS
        # TODO: Get PTS address type
        TestFunc(btp.set_pts_addr, pts_bd_addr, Addr.le_public)
    ]

    test_cases = [
        ZTestCase("GAP",
                  "GAP/BROB/BCST/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BROB/BCST/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BROB/BCST/BV-03-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BROB/OBSV/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BROB/OBSV/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BROB/OBSV/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase(
            "GAP",
            "GAP/BROB/OBSV/BV-06-C",
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                # Set RPA update to 1 minute (60*1000=60000 ms)
                TestFunc(pts.update_pixit_param, "GAP",
                         "TSPX_iut_private_address_interval", '60000')
            ],
            generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/NONM/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/NONM/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/LIMM/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/LIMM/BV-04-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/GENM/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/GENM/BV-04-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/LIMP/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/LIMP/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/LIMP/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/LIMP/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/LIMP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/GENP/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/GENP/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/GENP/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/GENP/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/GENP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/DISC/RPA/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase(
            "GAP", "GAP/IDLE/NAMP/BV-01-C", pre_conditions + [
                TestFunc(btp.core_reg_svc_gatt),
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(btp.gattc_read_uuid,
                         Addr.le_public,
                         pts_bd_addr,
                         '0001',
                         'FFFF',
                         UUID.device_name,
                         start_wid=73),
                TestFunc(btp.gattc_read_uuid_rsp, post_wid=73),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        ZTestCase("GAP",
                  "GAP/IDLE/NAMP/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/NCON/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/NCON/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/NCON/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/UCON/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/UCON/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/UCON/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/UCON/BV-06-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/ACEP/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/ACEP/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/ACEP/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/GCEP/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/GCEP/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/GCEP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/GCEP/BV-06-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/DCEP/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/DCEP/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/DCEP/BV-05-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/DCEP/BV-06-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/CPUP/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/CPUP/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/CPUP/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/CPUP/BV-04-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/CPUP/BV-05-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/CPUP/BV-08-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/TERM/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/PRDA/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/CONN/PRDA/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BOND/NBON/BV-01-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BOND/NBON/BV-02-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BOND/NBON/BV-03-C",
                  pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BOND/BON/BV-01-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BOND/BON/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BOND/BON/BV-03-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/BOND/BON/BV-04-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-11-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-12-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-13-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-14-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-17-C",
            cmds=pre_conditions + [
                TestFunc(btp.core_reg_svc_gatt),
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gattc_read,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         start_wid=112),
                # Bonding shall start automatically, so ignore wid: 108
                # "Please start the Bonding Procedure..."

                # Await read response after bonding
                TestFunc(btp.gattc_read_rsp, store_val=False, post_wid=108),
                TestFunc(btp.gap_disconn, start_wid=44)
            ]),
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-18-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-19-C",
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gap_pair, start_wid=108, skip_call=(2, )),
                TestFunc(btp.gattc_read,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         start_wid=112),
                TestFunc(btp.gattc_read_rsp, store_val=False, post_wid=112),
                TestFunc(btp.gap_disconn, start_wid=44)
            ]),
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-20-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-21-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        # TODO: Inform about lost bond
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-22-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-23-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/AUT/BV-24-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/CSIGN/BV-01-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/CSIGN/BV-02-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-01-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase(
            "GAP",
            "GAP/SEC/CSIGN/BI-02-C",
            edit1_wids={161: hdl_wid_161},
            verify_wids={
                130:
                lambda x: (btp.gatts_verify_write_success(x) and btp
                           .gatts_verify_write_success(
                               x) and btp.gatts_verify_write_fail(x))
            },
            cmds=pre_conditions + init_gatt_db + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_set_conn),
                TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh]),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        ZTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-03-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-04-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        # ZTestCase("GAP", "GAP/PRIV/CONN/BV-10-C",
        #           edit1_wids={1002: (btp.var_store_get_passkey, pts_bd_addr,
        #                              Addr.le_public)},
        #           cmds=pre_conditions +
        #                [TestFunc(btp.gap_set_io_cap, IOCap.display_only),
        #                 TestFunc(
        #                     pts.update_pixit_param, "GAP",
        #                     "TSPX_iut_device_name_in_adv_packet_for_random_address",
        #                     iut_device_name),
        #
        #                 # Set RPA update to 15 minutes (15*60*1000=900000 ms)
        #                 TestFunc(pts.update_pixit_param, "GAP",
        #                          "TSPX_iut_private_address_interval",
        #                          '900000'),
        #                 TestFunc(btp.gap_set_conn),
        #                 TestFunc(btp.gap_set_gendiscov),
        #                 TestFunc(btp.gap_adv_ind_on, sd=[AdData.ad_name_sh]),
        #                 # Don't disable advertising here
        #                 TestFunc(btp.gap_disconn, start_wid=77)]),
        # Workaround BZ-197 and PTS issue #15170
        ZTestCase(
            "GAP",
            "GAP/PRIV/CONN/BV-10-C",
            edit1_wids={1002: btp.var_store_get_passkey},
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(
                    pts.update_pixit_param, "GAP",
                    "TSPX_iut_device_name_in_adv_packet_for_random_address",
                    iut_device_name),

                # Simulate RPA update every 10 seconds (10*1000=10000 ms)
                TestFunc(pts.update_pixit_param, "GAP",
                         "TSPX_iut_private_address_interval", '10000'),
                TestFunc(btp.gap_set_conn),
                TestFunc(btp.gap_set_gendiscov),

                # This step is used to speed up test execution, so
                # that RPA is updated every 10 seconds. This shall
                # be skipped on first wid: 91 requesting to send
                # advertising report. Here, we are disabling
                # previously started advertising, to generate new
                # RPA to be used when advertising is started again.
                TestFunc(btp.gap_adv_off, start_wid=91, skip_call=(1, )),
                TestFunc(sleep, 10, start_wid=91, skip_call=(1, )),
                TestFunc(btp.gap_read_ctrl_info, start_wid=91,
                         skip_call=(1, )),
                TestFunc(
                    btp.gap_adv_ind_on, sd=[AdData.ad_name_sh], start_wid=91),
                # Don't disable advertising here
                TestFunc(btp.gap_disconn, start_wid=77)
            ]),
        ZTestCase("GAP",
                  "GAP/PRIV/CONN/BV-11-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/ADV/BV-01-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/ADV/BV-02-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/ADV/BV-03-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/ADV/BV-04-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/ADV/BV-10-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        ZTestCase("GAP",
                  "GAP/ADV/BV-11-C",
                  cmds=pre_conditions,
                  generic_wid_hdl=gap_wid_hdl),
        # GAP/GAT/BV-01-C
        # wid: 158 description: IUT support both Central and Peripheral roles.
        # Click Yes if IUT act as Central role to execute this test otherwise
        # click No to act as Peripheral role.
        #
        # Testing central role.
        ZTestCase("GAP",
                  "GAP/GAT/BV-01-C",
                  cmds=pre_conditions + init_gatt_db,
                  generic_wid_hdl=gap_wid_hdl),
        # Testing peripheral role.
        ZTestCase(
            "GAP",
            "GAP/GAT/BV-01-C",
            #   no_wid=158,
            cmds=pre_conditions + init_gatt_db,
            generic_wid_hdl=gap_wid_hdl),
    ]

    return test_cases
Beispiel #7
0
def test_cases(ptses):
    """Returns a list of GAP test cases
    ptses -- list of PyPTS instances"""

    pts = ptses[0]

    ad_str_manufacturer_data = str(format(AdType.manufacturer_data, 'x')).zfill(2) + \
                               iut_manufacturer_data
    ad_str_manufacturer_data_len = str(len(ad_str_manufacturer_data) /
                                       2).zfill(2)

    ad_pixit = ad_str_manufacturer_data_len + ad_str_manufacturer_data

    pts_bd_addr = pts.q_bd_addr
    iut_device_name = get_unique_name(pts)
    stack = get_stack()

    pre_conditions = [
        TestFunc(btp.core_reg_svc_gap),
        TestFunc(btp.gap_reset),
        TestFunc(stack.gap_init, iut_device_name, iut_manufacturer_data,
                 iut_appearance, iut_svc_data, iut_flags, iut_svcs),
        TestFunc(btp.gap_read_ctrl_info),
        TestFunc(btp.gap_set_bondable_on),
        TestFunc(lambda: pts.update_pixit_param("GAP", "TSPX_bd_addr_iut",
                                                stack.gap.iut_addr_get_str())),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_iut_privacy_enabled", "TRUE"
            if stack.gap.iut_has_privacy() else "FALSE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_public_device_address", "FALSE"
            if stack.gap.iut_addr_is_random() else "TRUE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_private_device_address", "TRUE"
            if stack.gap.iut_addr_is_random() else "FALSE")),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_iut_device_name_in_adv_packet_for_random_address",
            iut_device_name)),
        TestFunc(lambda: pts.update_pixit_param("GAP", "TSPX_advertising_data",
                                                ad_pixit)),
        TestFunc(lambda: pts.update_pixit_param(
            "GAP", "TSPX_using_random_device_address", "TRUE"
            if stack.gap.iut_addr_is_random() else "FALSE")),

        # We do this on test case, because previous one could
        # update this if RPA was used by PTS
        # TODO: Get PTS address type
        TestFunc(btp.set_pts_addr, pts_bd_addr, Addr.le_public)
    ]

    custom_test_cases = [
        BTestCase("GAP",
                  "GAP/BROB/BCST/BV-03-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BROB/OBSV/BV-06-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase(
            "GAP", "GAP/IDLE/NAMP/BV-01-C", pre_conditions + [
                TestFunc(btp.core_reg_svc_gatt),
                TestFunc(
                    btp.gap_conn, pts_bd_addr, Addr.le_public, start_wid=78),
                TestFunc(btp.gattc_read_uuid,
                         Addr.le_public,
                         pts_bd_addr,
                         '0001',
                         'FFFF',
                         UUID.device_name,
                         start_wid=73),
                TestFunc(btp.gattc_read_uuid_rsp, post_wid=73),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase("GAP",
                  "GAP/CONN/UCON/BV-06-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/NBON/BV-01-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/NBON/BV-02-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/NBON/BV-03-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/BON/BV-01-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/BON/BV-02-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/BON/BV-03-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/BOND/BON/BV-04-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-11-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-12-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-13-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-14-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-17-C",
            cmds=pre_conditions + [
                TestFunc(btp.core_reg_svc_gatt),
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gattc_read,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         start_wid=112),
                # Bonding shall start automatically, so ignore wid: 108
                # "Please start the Bonding Procedure..."

                # Await read response after bonding
                TestFunc(btp.gattc_read_rsp, store_val=False, post_wid=108),
                TestFunc(btp.gap_disconn, start_wid=44)
            ]),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-18-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase(
            "GAP",
            "GAP/SEC/AUT/BV-19-C",
            cmds=pre_conditions + [
                TestFunc(btp.gap_set_io_cap, IOCap.display_only),
                TestFunc(btp.gap_conn, start_wid=78),
                TestFunc(btp.gap_pair, start_wid=108, skip_call=(2, )),
                TestFunc(btp.gattc_read,
                         Addr.le_public,
                         pts_bd_addr,
                         "0001",
                         start_wid=112),
                TestFunc(btp.gattc_read_rsp, store_val=False, post_wid=112),
                TestFunc(btp.gap_disconn, start_wid=44)
            ]),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-20-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        # TODO: Inform about lost bond
        # BTestCase("GAP", "GAP/SEC/AUT/BV-22-C",
        #           cmds=pre_conditions,
        #           generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-23-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/AUT/BV-24-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BV-01-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BV-02-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-01-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase(
            "GAP",
            "GAP/SEC/CSIGN/BI-02-C",
            edit1_wids={161: hdl_wid_161},
            verify_wids={
                130:
                lambda x: (btp.gatts_verify_write_success(x) and btp
                           .gatts_verify_write_success(
                               x) and btp.gatts_verify_write_fail(x))
            },
            cmds=pre_conditions + init_gatt_db + [
                TestFunc(btp.gap_set_io_cap, IOCap.no_input_output),
                TestFunc(btp.gap_set_conn),
                TestFunc(lambda: btp.gap_adv_ind_on(ad=get_stack().gap.ad,
                                                    sd=get_stack().gap.sd)),
                TestFunc(
                    btp.gap_disconn, pts_bd_addr, Addr.le_public, start_wid=77)
            ]),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-03-C",
                  cmds=pre_conditions + init_gatt_db +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/SEC/CSIGN/BI-04-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.no_input_output)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/PRIV/CONN/BV-10-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        BTestCase("GAP",
                  "GAP/PRIV/CONN/BI-01-C",
                  cmds=pre_conditions +
                  [TestFunc(btp.gap_set_io_cap, IOCap.display_only)],
                  generic_wid_hdl=gap_wid_hdl),
        # GAP/GAT/BV-01-C
        # wid: 158 description: IUT support both Central and Peripheral roles.
        # Click Yes if IUT act as Central role to execute this test otherwise
        # click No to act as Peripheral role.
        #
        # Testing central role.
        BTestCase("GAP",
                  "GAP/GAT/BV-01-C",
                  cmds=pre_conditions + init_gatt_db,
                  generic_wid_hdl=gap_wid_hdl),
        # Testing peripheral role.
        BTestCase(
            "GAP",
            "GAP/GAT/BV-01-C",
            #   no_wid=158,
            cmds=pre_conditions + init_gatt_db,
            generic_wid_hdl=gap_wid_hdl),
    ]

    test_case_name_list = pts.get_test_case_list('GAP')
    tc_list = []

    for tc_name in test_case_name_list:
        instance = BTestCase('GAP',
                             tc_name,
                             cmds=pre_conditions,
                             generic_wid_hdl=gap_wid_hdl)

        for custom_tc in custom_test_cases:
            if tc_name == custom_tc.name:
                instance = custom_tc
                break

        tc_list.append(instance)

    return tc_list
Beispiel #8
0
def hdl_wid_137(params: WIDParams):
    return btp.gatts_verify_write_fail(params.description)