test: update tests

This commit is contained in:
Milanka Ringwald 2023-12-06 17:49:16 +01:00 committed by Matthias Ringwald
parent c502a66c58
commit ce00005722
3 changed files with 50 additions and 3 deletions

View File

@ -489,6 +489,24 @@ static void test_hci_event_encryption_events(hci_con_handle_t con_handle, uint8_
mock_call_att_packet_handler(HCI_EVENT_PACKET, 0, &buffer[0], buffer_size);
}
TEST(ATT_SERVER, att_server_multiple_notify) {
const uint16_t attribute_handles[] = {gatt_server_get_value_handle_for_characteristic_with_uuid16(0, 0xffff, ORG_BLUETOOTH_CHARACTERISTIC_BATTERY_LEVEL)};
const uint16_t value_lens[] = { 1};
static uint8_t battery_value[] = {0x55};
const uint8_t * value_data[] = {battery_value };
uint8_t num_attributes = 1;
hci_setup_le_connection(att_con_handle);
// correct command
uint8_t status = att_server_multiple_notify(att_con_handle, 1, attribute_handles, value_data, value_lens);
CHECK_EQUAL(ERROR_CODE_SUCCESS, status);
// invalid con handle
status = att_server_multiple_notify(HCI_CON_HANDLE_INVALID, 1, attribute_handles, value_data, value_lens);
CHECK_EQUAL(ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, status);
}
TEST(ATT_SERVER, hci_event_encryption_key_refresh_complete_event) {
uint8_t buffer[5];
buffer[0] = HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE;

View File

@ -93,6 +93,7 @@ TEST_GROUP(LE_DEVICE_DB_TLV){
TEST(LE_DEVICE_DB_TLV, Empty){
CHECK_EQUAL(0, le_device_db_count());
le_device_db_dump();
}
TEST(LE_DEVICE_DB_TLV, AddZero){
@ -100,6 +101,22 @@ TEST(LE_DEVICE_DB_TLV, AddZero){
CHECK_TRUE(index >= 0);
CHECK_EQUAL(1, le_device_db_count());
le_device_db_dump();
le_device_db_tlv_configure(btstack_tlv_impl, &btstack_tlv_context);
}
TEST(LE_DEVICE_DB_TLV, AddZero2){
int index = le_device_db_add(BD_ADDR_TYPE_LE_PUBLIC, addr_zero, sm_key_zero);
CHECK_TRUE(index >= 0);
CHECK_EQUAL(1, le_device_db_count());
index = le_device_db_add(BD_ADDR_TYPE_LE_PUBLIC, addr_zero, sm_key_zero);
CHECK_TRUE(index >= 0);
CHECK_EQUAL(1, le_device_db_count());
index = le_device_db_add(BD_ADDR_TYPE_LE_RANDOM, addr_zero, sm_key_zero);
CHECK_TRUE(index >= 0);
CHECK_EQUAL(2, le_device_db_count());
}
TEST(LE_DEVICE_DB_TLV, AddOne){
@ -109,12 +126,17 @@ TEST(LE_DEVICE_DB_TLV, AddOne){
}
TEST(LE_DEVICE_DB_TLV, RetrieveOne){
int index = le_device_db_add(BD_ADDR_TYPE_LE_PUBLIC, addr_aa, sm_key_aa);
CHECK_TRUE(index >= 0);
CHECK_EQUAL(1, le_device_db_count());
bd_addr_t addr;
sm_key_t sm_key;
int addr_type;
le_device_db_info(0, NULL, addr, sm_key);
le_device_db_info(0, &addr_type, NULL, sm_key);
int index = le_device_db_add(BD_ADDR_TYPE_LE_PUBLIC, addr_aa, sm_key_aa);
CHECK_TRUE(index >= 0);
CHECK_EQUAL(1, le_device_db_count());
le_device_db_info((uint16_t) index, &addr_type, addr, sm_key);
MEMCMP_EQUAL(sm_key_aa, sm_key, 16);
MEMCMP_EQUAL(addr_aa, addr, 6);

View File

@ -263,6 +263,13 @@ TEST(SecurityManager, CallFunctions){
sm_use_fixed_passkey_in_display_role(1000);
sm_allow_ltk_reconstruction_without_le_device_db_entry(1);
sm_numeric_comparison_confirm(HCI_CON_HANDLE_INVALID);
sm_send_security_request(HCI_CON_HANDLE_INVALID);
gap_get_persistent_irk();
bd_addr_t address = {0,0,0,0,0,0};
gap_delete_bonding(BD_ADDR_TYPE_UNKNOWN, address);
sm_identity_resolving_state(HCI_CON_HANDLE_INVALID);
sm_authorization_decline(HCI_CON_HANDLE_INVALID);
sm_request_pairing(HCI_CON_HANDLE_INVALID);
}
TEST(SecurityManager, MainTest){