Skip to content

Commit 9ebb0e9

Browse files
committed
Fix happy path test.
1 parent 35f6a5c commit 9ebb0e9

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

testing/unit/channel_sounding_behavior/src/error_handling.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static struct net_buf test_buf = {
348348

349349
// static struct bt_conn test_conn;
350350

351-
ZTEST(channel_sounding_tests_error_handling, test_buffer_too_short)
351+
ZTEST(channel_sounding_tests_error_handling, test_bt_hci_le_cs_read_remote_fae_table_complete_invalid_buf_size_fail)
352352
{
353353
// Setup
354354
test_buf.len = sizeof(struct bt_hci_evt_le_cs_read_remote_fae_table_complete) - 1;
@@ -360,7 +360,7 @@ ZTEST(channel_sounding_tests_error_handling, test_buffer_too_short)
360360
zassert_equal(notify_remote_cs_fae_table_fake.call_count, 0, "Expected notify_remote_cs_fae_table not to be called");
361361
}
362362

363-
ZTEST(channel_sounding_tests_error_handling, test_evt_status_failure)
363+
ZTEST(channel_sounding_tests_error_handling, test_bt_hci_le_cs_read_remote_fae_table_complete_evt_status_fail)
364364
{
365365
struct bt_hci_evt_le_cs_read_remote_fae_table_complete *evt;
366366

@@ -375,7 +375,7 @@ ZTEST(channel_sounding_tests_error_handling, test_evt_status_failure)
375375
zassert_equal(notify_remote_cs_fae_table_fake.call_count, 0, "Expected notify_remote_cs_fae_table not to be called");
376376
}
377377

378-
ZTEST(channel_sounding_tests_error_handling, test_conn_lookup_failure)
378+
ZTEST(channel_sounding_tests_error_handling, test_bt_hci_le_cs_read_remote_fae_table_complete_conn_lookup_fail)
379379
{
380380
struct bt_hci_evt_le_cs_read_remote_fae_table_complete *evt;
381381

testing/unit/channel_sounding_behavior/src/main.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ ZTEST(channel_sounding_tests, test_read_remote_fae_table)
198198
zassert_equal_ptr(net_buf_simple_add_fake.arg0_val, simple_test_buf);
199199
}
200200

201+
void *net_buf_simple_pull_mem_mock(struct net_buf_simple *buf, size_t len)
202+
{
203+
void *data = buf->data; // Save the current data pointer
204+
buf->data += len; // Advance the data pointer
205+
buf->len -= len; // Reduce the remaining length
206+
return data; // Return the original data pointer
207+
}
208+
201209
ZTEST(channel_sounding_tests, test_successful_read)
202210
{
203211
struct bt_conn *test_conn = &test_conn_mock;
@@ -235,7 +243,7 @@ ZTEST(channel_sounding_tests, test_successful_read)
235243

236244
// Replace generic mock implementation with stubbed function
237245
// net_buf_simple_add_fake.custom_fake = custom_net_buf_simple_add;
238-
net_buf_simple_pull_mem_fake.return_val = &evt;
246+
net_buf_simple_pull_mem_fake.custom_fake = net_buf_simple_pull_mem_mock;
239247

240248
/* Call the function */
241249
bt_hci_le_cs_read_remote_fae_table_complete(&test_buf);

0 commit comments

Comments
 (0)