Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 851880542 -> d61c6cd08
BLE host - add chr-read app err to unit tests. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d61c6cd0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d61c6cd0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d61c6cd0 Branch: refs/heads/develop Commit: d61c6cd08b054e1ea8b829a0b74aa6ce2688357a Parents: 206d7fd Author: Christopher Collins <[email protected]> Authored: Sat Feb 11 12:06:53 2017 -0800 Committer: Christopher Collins <[email protected]> Committed: Sat Feb 11 12:07:45 2017 -0800 ---------------------------------------------------------------------- net/nimble/host/test/src/ble_att_svr_test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d61c6cd0/net/nimble/host/test/src/ble_att_svr_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_att_svr_test.c b/net/nimble/host/test/src/ble_att_svr_test.c index 8ee9bc6..c5b964a 100644 --- a/net/nimble/host/test/src/ble_att_svr_test.c +++ b/net/nimble/host/test/src/ble_att_svr_test.c @@ -138,6 +138,15 @@ ble_att_svr_test_misc_attr_fn_r_2(uint16_t conn_handle, uint16_t attr_handle, } } +static int +ble_att_svr_test_misc_attr_fn_r_err(uint16_t conn_handle, uint16_t attr_handle, + uint8_t op, uint16_t offset, + struct os_mbuf **om, void *arg) +{ + os_mbuf_append(*om, (uint8_t[4]){1,2,3,4}, 4); + return BLE_ATT_ERR_UNLIKELY; +} + #define BLE_ATT_SVR_TEST_LAST_SVC 11 #define BLE_ATT_SVR_TEST_LAST_ATTR 24 @@ -777,6 +786,8 @@ TEST_CASE(ble_att_svr_test_read) uint16_t conn_handle; const ble_uuid_t *uuid_sec = BLE_UUID128_DECLARE( \ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + const ble_uuid_t *uuid_bad = BLE_UUID128_DECLARE( \ + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); const ble_uuid_t *uuid = BLE_UUID128_DECLARE( \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ); int rc; @@ -790,6 +801,16 @@ TEST_CASE(ble_att_svr_test_read) ble_hs_test_util_verify_tx_err_rsp(BLE_ATT_OP_READ_REQ, 0, BLE_ATT_ERR_INVALID_HANDLE); + /*** Application error. */ + rc = ble_att_svr_register(uuid_bad, HA_FLAG_PERM_RW, 0, &attr_handle, + ble_att_svr_test_misc_attr_fn_r_err, NULL); + TEST_ASSERT(rc == 0); + + rc = ble_hs_test_util_rx_att_read_req(conn_handle, attr_handle); + TEST_ASSERT(rc == BLE_HS_EAPP); + ble_hs_test_util_verify_tx_err_rsp(BLE_ATT_OP_READ_REQ, attr_handle, + BLE_ATT_ERR_UNLIKELY); + /*** Successful read. */ ble_att_svr_test_attr_r_1 = (uint8_t[]){0,1,2,3,4,5,6,7}; ble_att_svr_test_attr_r_1_len = 8;
