From 7d1d701222ff420ec85d063c616ef471ec142bb7 Mon Sep 17 00:00:00 2001 From: Matt Durak Date: Tue, 10 Mar 2026 12:16:12 -0700 Subject: [PATCH 1/8] Update deps + parameterized test refactoring - Update deps/c-testrunnerswitcher to master (adds PARAMETERIZED_TEST_FUNCTION support) - Refactor 3 gballoc_hl_malloc tests into 1 PARAMETERIZED_TEST_FUNCTION (varying alloc size and timer values) - Refactor 3 gballoc_hl_realloc NULL-ptr tests into 1 PARAMETERIZED_TEST_FUNCTION (varying alloc size) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- deps/c-testrunnerswitcher | 2 +- .../gballoc_hl_metrics_ut.c | 210 ++---------------- 2 files changed, 20 insertions(+), 192 deletions(-) diff --git a/deps/c-testrunnerswitcher b/deps/c-testrunnerswitcher index a62e7067..48b0066e 160000 --- a/deps/c-testrunnerswitcher +++ b/deps/c-testrunnerswitcher @@ -1 +1 @@ -Subproject commit a62e7067882f11addd52aee5c569d2cdfb9eddaf +Subproject commit 48b0066eef2dd726ba0ea48189923060aacfb449 diff --git a/win32/tests/gballoc_hl_metrics_ut/gballoc_hl_metrics_ut.c b/win32/tests/gballoc_hl_metrics_ut/gballoc_hl_metrics_ut.c index 4cad2bb8..b8d7fb0b 100644 --- a/win32/tests/gballoc_hl_metrics_ut/gballoc_hl_metrics_ut.c +++ b/win32/tests/gballoc_hl_metrics_ut/gballoc_hl_metrics_ut.c @@ -191,52 +191,11 @@ TEST_FUNCTION(gballoc_hl_deinit_when_not_initialized_returns) /* Tests_SRS_GBALLOC_HL_METRICS_01_044: [ If the computed latency is less than the minimum tracked latency, gballoc_hl_malloc shall store it as the new minimum malloc latency. ]*/ /* Tests_SRS_GBALLOC_HL_METRICS_01_045: [ If the computed latency is more than the maximum tracked latency, gballoc_hl_malloc shall store it as the new maximum malloc latency. ]*/ /* Tests_SRS_GBALLOC_HL_METRICS_01_042: [ gballoc_hl_malloc shall increment the count of malloc latency samples. ]*/ -TEST_FUNCTION(gballoc_hl_malloc_calls_gballoc_ll_malloc_and_returns_the_result) -{ - // arrange - void* result; - void* gballoc_ll_malloc_result; - STRICT_EXPECTED_CALL(gballoc_ll_init(NULL)); - (void)gballoc_hl_init(NULL, NULL); - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(lazy_init(IGNORED_ARG, IGNORED_ARG, NULL)); - STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(5); - STRICT_EXPECTED_CALL(gballoc_ll_malloc(42)) - .CaptureReturn(&gballoc_ll_malloc_result); - STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(7); - STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, 2)); - // min - STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 2, IGNORED_ARG)); - // max - STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 2, IGNORED_ARG)); - STRICT_EXPECTED_CALL(interlocked_increment(IGNORED_ARG)); - - // act - result = gballoc_hl_malloc(42); - - // assert - ASSERT_IS_NOT_NULL(result); - ASSERT_ARE_EQUAL(void_ptr, result, gballoc_ll_malloc_result); - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - gballoc_hl_free(result); - gballoc_hl_deinit(); -} - -/* Tests_SRS_GBALLOC_HL_METRICS_01_028: [ gballoc_hl_malloc shall call timer_global_get_elapsed_us to obtain the start time of the allocate. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_007: [ gballoc_hl_malloc shall call gballoc_ll_malloc(size) and return the result of gballoc_ll_malloc. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_029: [ gballoc_hl_malloc shall call timer_global_get_elapsed_us to obtain the end time of the allocate. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_043: [ gballoc_hl_malloc shall add the computed latency to the running malloc latency sum used to compute the average. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_044: [ If the computed latency is less than the minimum tracked latency, gballoc_hl_malloc shall store it as the new minimum malloc latency. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_045: [ If the computed latency is more than the maximum tracked latency, gballoc_hl_malloc shall store it as the new maximum malloc latency. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_042: [ gballoc_hl_malloc shall increment the count of malloc latency samples. ]*/ -TEST_FUNCTION(gballoc_hl_malloc_with_1_byte_calls_gballoc_ll_malloc_and_returns_the_result) +PARAMETERIZED_TEST_FUNCTION(gballoc_hl_malloc_calls_gballoc_ll_malloc_and_returns_the_result, + ARGS(size_t, alloc_size, double, timer_start_value, double, timer_end_value, int32_t, expected_latency), + CASE((42, 5, 7, 2), with_42_bytes), + CASE((1, 1, 8, 7), with_1_byte), + CASE((0, 1, 8, 7), with_0_bytes)) { // arrange void* result; @@ -247,67 +206,22 @@ TEST_FUNCTION(gballoc_hl_malloc_with_1_byte_calls_gballoc_ll_malloc_and_returns_ STRICT_EXPECTED_CALL(lazy_init(IGNORED_ARG, IGNORED_ARG, NULL)); STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(1); - STRICT_EXPECTED_CALL(gballoc_ll_malloc(1)) + .SetReturn(timer_start_value); + STRICT_EXPECTED_CALL(gballoc_ll_malloc(alloc_size)) .CaptureReturn(&gballoc_ll_result); STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(8); - STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, 7)); + .SetReturn(timer_end_value); + STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, expected_latency)); // min STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 7, IGNORED_ARG)); + STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, expected_latency, IGNORED_ARG)); // max STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 7, IGNORED_ARG)); + STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, expected_latency, IGNORED_ARG)); STRICT_EXPECTED_CALL(interlocked_increment(IGNORED_ARG)); // act - result = gballoc_hl_malloc(1); - - // assert - ASSERT_IS_NOT_NULL(result); - ASSERT_ARE_EQUAL(void_ptr, result, gballoc_ll_result); - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - gballoc_hl_free(result); - gballoc_hl_deinit(); -} - -/* Tests_SRS_GBALLOC_HL_METRICS_01_028: [ gballoc_hl_malloc shall call timer_global_get_elapsed_us to obtain the start time of the allocate. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_007: [ gballoc_hl_malloc shall call gballoc_ll_malloc(size) and return the result of gballoc_ll_malloc. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_029: [ gballoc_hl_malloc shall call timer_global_get_elapsed_us to obtain the end time of the allocate. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_043: [ gballoc_hl_malloc shall add the computed latency to the running malloc latency sum used to compute the average. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_044: [ If the computed latency is less than the minimum tracked latency, gballoc_hl_malloc shall store it as the new minimum malloc latency. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_045: [ If the computed latency is more than the maximum tracked latency, gballoc_hl_malloc shall store it as the new maximum malloc latency. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_042: [ gballoc_hl_malloc shall increment the count of malloc latency samples. ]*/ -TEST_FUNCTION(gballoc_hl_malloc_with_0_bytes_calls_gballoc_ll_malloc_and_returns_the_result) -{ - // arrange - void* result; - void* gballoc_ll_result; - STRICT_EXPECTED_CALL(gballoc_ll_init(NULL)); - (void)gballoc_hl_init(NULL, NULL); - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(lazy_init(IGNORED_ARG, IGNORED_ARG, NULL)); - STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(1); - STRICT_EXPECTED_CALL(gballoc_ll_malloc(0)) - .CaptureReturn(&gballoc_ll_result); - STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(8); - STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, 7)); - // min - STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 7, IGNORED_ARG)); - // max - STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 7, IGNORED_ARG)); - STRICT_EXPECTED_CALL(interlocked_increment(IGNORED_ARG)); - - // act - result = gballoc_hl_malloc(0); + result = gballoc_hl_malloc(alloc_size); // assert ASSERT_IS_NOT_NULL(result); @@ -825,97 +739,11 @@ TEST_FUNCTION(gballoc_hl_calloc_when_not_initialized_fails) /* Tests_SRS_GBALLOC_HL_METRICS_01_059: [ If the computed latency is less than the minimum tracked latency, gballoc_hl_realloc shall store it as the new minimum realloc latency. ]*/ /* Tests_SRS_GBALLOC_HL_METRICS_01_060: [ If the computed latency is more than the maximum tracked latency, gballoc_hl_realloc shall store it as the new maximum realloc latency. ]*/ /* Tests_SRS_GBALLOC_HL_METRICS_01_061: [ gballoc_hl_realloc shall increment the count of realloc latency samples. ]*/ -TEST_FUNCTION(gballoc_hl_realloc_with_NULL_calls_gballoc_ll_realloc_and_returns_the_result) -{ - // arrange - void* result; - void* gballoc_ll_result; - STRICT_EXPECTED_CALL(gballoc_ll_init(NULL)); - (void)gballoc_hl_init(NULL, NULL); - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(lazy_init(IGNORED_ARG, IGNORED_ARG, NULL)); - STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(1); - STRICT_EXPECTED_CALL(gballoc_ll_realloc(NULL, 42)) - .CaptureReturn(&gballoc_ll_result); - STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(8); - STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, 7)); - // min - STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 7, IGNORED_ARG)); - // max - STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 7, IGNORED_ARG)); - STRICT_EXPECTED_CALL(interlocked_increment(IGNORED_ARG)); - - // act - result = gballoc_hl_realloc(NULL, 42); - - // assert - ASSERT_IS_NOT_NULL(result); - ASSERT_ARE_EQUAL(void_ptr, result, gballoc_ll_result); - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - gballoc_hl_free(result); - gballoc_hl_deinit(); -} - -/* Tests_SRS_GBALLOC_HL_METRICS_01_032: [ gballoc_hl_realloc shall call timer_global_get_elapsed_us to obtain the start time of the allocate. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_013: [ gballoc_hl_realloc shall call gballoc_ll_realloc(ptr, size) and return the result of gballoc_ll_realloc ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_033: [ gballoc_hl_realloc shall call timer_global_get_elapsed_us to obtain the end time of the allocate. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_058: [ gballoc_hl_realloc shall add the computed latency to the running realloc latency sum used to compute the average. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_059: [ If the computed latency is less than the minimum tracked latency, gballoc_hl_realloc shall store it as the new minimum realloc latency. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_060: [ If the computed latency is more than the maximum tracked latency, gballoc_hl_realloc shall store it as the new maximum realloc latency. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_061: [ gballoc_hl_realloc shall increment the count of realloc latency samples. ]*/ -TEST_FUNCTION(gballoc_hl_realloc_with_1_byte_size_with_NULL_ptr_calls_gballoc_ll_realloc_and_returns_the_result) -{ - // arrange - void* result; - void* gballoc_ll_result; - STRICT_EXPECTED_CALL(gballoc_ll_init(NULL)); - (void)gballoc_hl_init(NULL, NULL); - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(lazy_init(IGNORED_ARG, IGNORED_ARG, NULL)); - STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(1); - STRICT_EXPECTED_CALL(gballoc_ll_realloc(NULL, 1)) - .CaptureReturn(&gballoc_ll_result); - STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) - .SetReturn(8); - STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, 7)); - // min - STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 7, IGNORED_ARG)); - // max - STRICT_EXPECTED_CALL(interlocked_add(IGNORED_ARG, 0)); - STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, 7, IGNORED_ARG)); - STRICT_EXPECTED_CALL(interlocked_increment(IGNORED_ARG)); - - // act - result = gballoc_hl_realloc(NULL, 1); - - // assert - ASSERT_IS_NOT_NULL(result); - ASSERT_ARE_EQUAL(void_ptr, result, gballoc_ll_result); - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - gballoc_hl_free(result); - gballoc_hl_deinit(); -} - -/* Tests_SRS_GBALLOC_HL_METRICS_01_032: [ gballoc_hl_realloc shall call timer_global_get_elapsed_us to obtain the start time of the allocate. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_013: [ gballoc_hl_realloc shall call gballoc_ll_realloc(ptr, size) and return the result of gballoc_ll_realloc ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_033: [ gballoc_hl_realloc shall call timer_global_get_elapsed_us to obtain the end time of the allocate. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_058: [ gballoc_hl_realloc shall add the computed latency to the running realloc latency sum used to compute the average. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_059: [ If the computed latency is less than the minimum tracked latency, gballoc_hl_realloc shall store it as the new minimum realloc latency. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_060: [ If the computed latency is more than the maximum tracked latency, gballoc_hl_realloc shall store it as the new maximum realloc latency. ]*/ -/* Tests_SRS_GBALLOC_HL_METRICS_01_061: [ gballoc_hl_realloc shall increment the count of realloc latency samples. ]*/ -TEST_FUNCTION(gballoc_hl_realloc_with_0_bytes_size_with_NULL_ptr_calls_gballoc_ll_realloc_and_returns_the_result) +PARAMETERIZED_TEST_FUNCTION(gballoc_hl_realloc_with_NULL_calls_gballoc_ll_realloc_and_returns_the_result, + ARGS(size_t, alloc_size), + CASE((42), with_42_bytes), + CASE((1), with_1_byte), + CASE((0), with_0_bytes)) { // arrange void* result; @@ -927,7 +755,7 @@ TEST_FUNCTION(gballoc_hl_realloc_with_0_bytes_size_with_NULL_ptr_calls_gballoc_l STRICT_EXPECTED_CALL(lazy_init(IGNORED_ARG, IGNORED_ARG, NULL)); STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) .SetReturn(1); - STRICT_EXPECTED_CALL(gballoc_ll_realloc(NULL, 0)) + STRICT_EXPECTED_CALL(gballoc_ll_realloc(NULL, alloc_size)) .CaptureReturn(&gballoc_ll_result); STRICT_EXPECTED_CALL(timer_global_get_elapsed_us()) .SetReturn(8); @@ -941,7 +769,7 @@ TEST_FUNCTION(gballoc_hl_realloc_with_0_bytes_size_with_NULL_ptr_calls_gballoc_l STRICT_EXPECTED_CALL(interlocked_increment(IGNORED_ARG)); // act - result = gballoc_hl_realloc(NULL, 0); + result = gballoc_hl_realloc(NULL, alloc_size); // assert ASSERT_IS_NOT_NULL(result); From b786a11cae415c9aedc560105585d25a93c45709 Mon Sep 17 00:00:00 2001 From: Matt Durak Date: Tue, 10 Mar 2026 14:09:52 -0700 Subject: [PATCH 2/8] Additional parameterized test refactoring Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/tests/tqueue_ut/tqueue_ut.c | 142 +++++------------------------ 1 file changed, 23 insertions(+), 119 deletions(-) diff --git a/common/tests/tqueue_ut/tqueue_ut.c b/common/tests/tqueue_ut/tqueue_ut.c index d658f7f3..0920ce1e 100644 --- a/common/tests/tqueue_ut/tqueue_ut.c +++ b/common/tests/tqueue_ut/tqueue_ut.c @@ -347,87 +347,14 @@ TEST_FUNCTION(TQUEUE_DISPOSE_FUNC_with_non_NULL_dispose_item_with_1_item_calls_d /* Tests_SRS_TQUEUE_01_011: [ For each item in the queue, dispose_item_function shall be called with dispose_item_function_context and a pointer to the array entry value (T*). ]*/ /* Tests_SRS_TQUEUE_01_056: [ The lock initialized in TQUEUE_CREATE(T) shall be de-initialized. ] */ /* Tests_SRS_TQUEUE_01_057: [ The array backing the queue shall be freed. ] */ -TEST_FUNCTION(TQUEUE_DISPOSE_FUNC_with_non_NULL_dispose_item_with_2_items_calls_dispose_item_2_times) +PARAMETERIZED_TEST_FUNCTION(TQUEUE_DISPOSE_FUNC_with_non_NULL_dispose_item_with_2_items_calls_dispose_item_2_times, + ARGS(uint32_t, initial_queue_size, uint32_t, max_queue_size), + CASE((1024, 1024), same_initial_and_max_size), + CASE((1024, 2048), max_size_bigger_than_initial_size), + CASE((1, 2048), queue_that_was_grown)) { // arrange - TQUEUE(int32_t) queue = test_queue_create(1024, 1024, test_copy_item, test_dispose_item, (void*)0x4242); - test_queue_push(queue, 42); - test_queue_push(queue, 42); - - STRICT_EXPECTED_CALL(interlocked_decrement(IGNORED_ARG)); - STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, 0)); // head - STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, 0)); // tail - STRICT_EXPECTED_CALL(test_dispose_item((void*)0x4242, IGNORED_ARG)); - STRICT_EXPECTED_CALL(test_dispose_item((void*)0x4242, IGNORED_ARG)); - STRICT_EXPECTED_CALL(srw_lock_ll_deinit(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - TQUEUE_ASSIGN(int32_t)(&queue, NULL); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); -} - -/* Tests_SRS_TQUEUE_01_009: [ Otherwise, TQUEUE_DISPOSE_FUNC(T) shall obtain the current queue head by calling interlocked_add_64. ]*/ -/* Tests_SRS_TQUEUE_01_010: [ TQUEUE_DISPOSE_FUNC(T) shall obtain the current queue tail by calling interlocked_add_64. ]*/ -/* Tests_SRS_TQUEUE_01_011: [ For each item in the queue, dispose_item_function shall be called with dispose_item_function_context and a pointer to the array entry value (T*). ]*/ -/* Tests_SRS_TQUEUE_01_056: [ The lock initialized in TQUEUE_CREATE(T) shall be de-initialized. ] */ -/* Tests_SRS_TQUEUE_01_057: [ The array backing the queue shall be freed. ] */ -TEST_FUNCTION(TQUEUE_DISPOSE_FUNC_for_a_queue_with_max_size_bigger_than_initial_size_frees_resources) -{ - // arrange - TQUEUE(int32_t) queue = test_queue_create(1024, 2048, test_copy_item, test_dispose_item, (void*)0x4242); - test_queue_push(queue, 42); - test_queue_push(queue, 42); - - STRICT_EXPECTED_CALL(interlocked_decrement(IGNORED_ARG)); - STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, 0)); // head - STRICT_EXPECTED_CALL(interlocked_add_64(IGNORED_ARG, 0)); // tail - STRICT_EXPECTED_CALL(test_dispose_item((void*)0x4242, IGNORED_ARG)); - STRICT_EXPECTED_CALL(test_dispose_item((void*)0x4242, IGNORED_ARG)); - STRICT_EXPECTED_CALL(srw_lock_ll_deinit(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - TQUEUE_ASSIGN(int32_t)(&queue, NULL); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); -} - -/* Tests_SRS_TQUEUE_01_056: [ The lock initialized in TQUEUE_CREATE(T) shall be de-initialized. ] */ -/* Tests_SRS_TQUEUE_01_057: [ The array backing the queue shall be freed. ] */ -TEST_FUNCTION(TQUEUE_DISPOSE_FUNC_for_a_queue_with_max_size_bigger_than_initial_size_with_NULL_copy_and_dispose_function_frees_resources) -{ - // arrange - TQUEUE(int32_t) queue = test_queue_create(1024, 2048, NULL, NULL, (void*)0x4242); - test_queue_push(queue, 42); - test_queue_push(queue, 42); - - STRICT_EXPECTED_CALL(interlocked_decrement(IGNORED_ARG)); - STRICT_EXPECTED_CALL(srw_lock_ll_deinit(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - TQUEUE_ASSIGN(int32_t)(&queue, NULL); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); -} - -/* Tests_SRS_TQUEUE_01_009: [ Otherwise, TQUEUE_DISPOSE_FUNC(T) shall obtain the current queue head by calling interlocked_add_64. ]*/ -/* Tests_SRS_TQUEUE_01_010: [ TQUEUE_DISPOSE_FUNC(T) shall obtain the current queue tail by calling interlocked_add_64. ]*/ -/* Tests_SRS_TQUEUE_01_011: [ For each item in the queue, dispose_item_function shall be called with dispose_item_function_context and a pointer to the array entry value (T*). ]*/ -/* Tests_SRS_TQUEUE_01_056: [ The lock initialized in TQUEUE_CREATE(T) shall be de-initialized. ] */ -/* Tests_SRS_TQUEUE_01_057: [ The array backing the queue shall be freed. ] */ -TEST_FUNCTION(TQUEUE_DISPOSE_FUNC_for_a_queue_that_was_grown_frees_resources) -{ - // arrange - TQUEUE(int32_t) queue = test_queue_create(1, 2048, test_copy_item, test_dispose_item, (void*)0x4242); + TQUEUE(int32_t) queue = test_queue_create(initial_queue_size, max_queue_size, test_copy_item, test_dispose_item, (void*)0x4242); test_queue_push(queue, 42); test_queue_push(queue, 42); @@ -449,10 +376,13 @@ TEST_FUNCTION(TQUEUE_DISPOSE_FUNC_for_a_queue_that_was_grown_frees_resources) /* Tests_SRS_TQUEUE_01_056: [ The lock initialized in TQUEUE_CREATE(T) shall be de-initialized. ] */ /* Tests_SRS_TQUEUE_01_057: [ The array backing the queue shall be freed. ] */ -TEST_FUNCTION(TQUEUE_DISPOSE_FUNC_for_a_queue_that_was_grown__with_NULL_copy_and_dispose_function_frees_resources) +PARAMETERIZED_TEST_FUNCTION(TQUEUE_DISPOSE_FUNC_with_NULL_copy_and_dispose_function_frees_resources, + ARGS(uint32_t, initial_queue_size, uint32_t, max_queue_size), + CASE((1024, 2048), max_size_bigger_than_initial_size), + CASE((1, 2048), queue_that_was_grown)) { // arrange - TQUEUE(int32_t) queue = test_queue_create(1, 2048, NULL, NULL, (void*)0x4242); + TQUEUE(int32_t) queue = test_queue_create(initial_queue_size, max_queue_size, NULL, NULL, (void*)0x4242); test_queue_push(queue, 42); test_queue_push(queue, 42); @@ -607,7 +537,12 @@ TEST_FUNCTION(TQUEUE_PUSH_twice_for_queue_size_1_returns_QUEUE_FULL) TQUEUE_ASSIGN(int32_t)(&queue, NULL); } -static void test_TQUEUE_PUSH_when_entry_state_is_different_than_NOT_USED_tries_again(QUEUE_ENTRY_STATE queue_entry_state) +/* Tests_SRS_TQUEUE_01_023: [ If the state of the array entry corresponding to the head is not NOT_USED, TQUEUE_PUSH(T) shall retry the whole push. ]*/ +PARAMETERIZED_TEST_FUNCTION(TQUEUE_PUSH_when_entry_state_is_different_than_NOT_USED_tries_again, + ARGS(QUEUE_ENTRY_STATE, queue_entry_state), + CASE((QUEUE_ENTRY_STATE_PUSHING), PUSHING), + CASE((QUEUE_ENTRY_STATE_POPPING), POPPING), + CASE((QUEUE_ENTRY_STATE_USED), USED)) { // arrange int32_t item = 42; @@ -644,24 +579,6 @@ static void test_TQUEUE_PUSH_when_entry_state_is_different_than_NOT_USED_tries_a TQUEUE_ASSIGN(int32_t)(&queue, NULL); } -/* Tests_SRS_TQUEUE_01_023: [ If the state of the array entry corresponding to the head is not NOT_USED, TQUEUE_PUSH(T) shall retry the whole push. ]*/ -TEST_FUNCTION(TQUEUE_PUSH_when_entry_state_is_PUSHING_tries_again) -{ - test_TQUEUE_PUSH_when_entry_state_is_different_than_NOT_USED_tries_again(QUEUE_ENTRY_STATE_PUSHING); -} - -/* Tests_SRS_TQUEUE_01_023: [ If the state of the array entry corresponding to the head is not NOT_USED, TQUEUE_PUSH(T) shall retry the whole push. ]*/ -TEST_FUNCTION(TQUEUE_PUSH_when_entry_state_is_POPPING_tries_again) -{ - test_TQUEUE_PUSH_when_entry_state_is_different_than_NOT_USED_tries_again(QUEUE_ENTRY_STATE_POPPING); -} - -/* Tests_SRS_TQUEUE_01_023: [ If the state of the array entry corresponding to the head is not NOT_USED, TQUEUE_PUSH(T) shall retry the whole push. ]*/ -TEST_FUNCTION(TQUEUE_PUSH_when_entry_state_is_USED_tries_again) -{ - test_TQUEUE_PUSH_when_entry_state_is_different_than_NOT_USED_tries_again(QUEUE_ENTRY_STATE_USED); -} - /* Tests_SRS_TQUEUE_01_043: [ If the queue head has changed, TQUEUE_PUSH(T) shall set the state back to NOT_USED and retry the push. ]*/ TEST_FUNCTION(when_head_changes_TQUEUE_PUSH_tries_again) { @@ -1214,7 +1131,12 @@ TEST_FUNCTION(TQUEUE_POP_when_queue_is_empty_after_a_push_and_a_pop_and_queue_si TQUEUE_ASSIGN(int32_t)(&queue, NULL); } -static void test_TQUEUE_POP_when_entry_state_is_different_than_USED_tries_again(QUEUE_ENTRY_STATE queue_entry_state) +/* Tests_SRS_TQUEUE_01_036: [ If the state of the array entry corresponding to the tail is not USED, TQUEUE_POP(T) shall try again. ]*/ +PARAMETERIZED_TEST_FUNCTION(TQUEUE_POP_when_entry_state_is_different_than_USED_tries_again, + ARGS(QUEUE_ENTRY_STATE, queue_entry_state), + CASE((QUEUE_ENTRY_STATE_PUSHING), PUSHING), + CASE((QUEUE_ENTRY_STATE_POPPING), POPPING), + CASE((QUEUE_ENTRY_STATE_NOT_USED), NOT_USED)) { // arrange int32_t item = 45; @@ -1246,24 +1168,6 @@ static void test_TQUEUE_POP_when_entry_state_is_different_than_USED_tries_again( TQUEUE_ASSIGN(int32_t)(&queue, NULL); } -/* Tests_SRS_TQUEUE_01_036: [ If the state of the array entry corresponding to the tail is not USED, TQUEUE_POP(T) shall try again. ]*/ -TEST_FUNCTION(TQUEUE_POP_when_entry_state_is_PUSHING_tries_again) -{ - test_TQUEUE_POP_when_entry_state_is_different_than_USED_tries_again(QUEUE_ENTRY_STATE_PUSHING); -} - -/* Tests_SRS_TQUEUE_01_036: [ If the state of the array entry corresponding to the tail is not USED, TQUEUE_POP(T) shall try again. ]*/ -TEST_FUNCTION(TQUEUE_POP_when_entry_state_is_POPPING_tries_again) -{ - test_TQUEUE_POP_when_entry_state_is_different_than_USED_tries_again(QUEUE_ENTRY_STATE_POPPING); -} - -/* Tests_SRS_TQUEUE_01_036: [ If the state of the array entry corresponding to the tail is not USED, TQUEUE_POP(T) shall try again. ]*/ -TEST_FUNCTION(TQUEUE_POP_when_entry_state_is_NOT_USED_tries_again) -{ - test_TQUEUE_POP_when_entry_state_is_different_than_USED_tries_again(QUEUE_ENTRY_STATE_NOT_USED); -} - /* Tests_SRS_TQUEUE_01_037: [ If copy_item_function and sispose_item_function were specified in TQUEUE_CREATE(T): ]*/ /* Tests_SRS_TQUEUE_01_038: [ TQUEUE_POP(T) shall call copy_item_function with copy_item_function_context as context, the array entry value whose state was changed to POPPING to item as pop_src and item as pop_dst. ]*/ /* Tests_SRS_TQUEUE_01_045: [ TQUEUE_POP(T) shall call dispose_item_function with dispose_item_function_context as context and the array entry value whose state was changed to POPPING as item. ]*/ From 156a6ecd8dff32f0f81ae066815489c5695777dc Mon Sep 17 00:00:00 2001 From: Matt Durak Date: Tue, 10 Mar 2026 16:15:07 -0700 Subject: [PATCH 3/8] Parameterize event_complete_func notify tests and file_io_complete callback tests Refactor 8 identical notify event tests in async_socket_linux_ut.c into a single PARAMETERIZED_TEST_FUNCTION with 3 parameters (io_type, epoll_action, expected_result) and 8 cases. Refactor 6 identical on_file_io_complete_win32 callback tests in file_win32_ut.c into a single PARAMETERIZED_TEST_FUNCTION with 4 parameters (io_type, io_result, num_bytes_transferred, expected_success) and 6 cases. Net reduction: 333 lines removed, 26 added. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../async_socket_linux_ut.c | 197 ++---------------- win32/tests/file_win32_ut/file_win32_ut.c | 162 ++------------ 2 files changed, 26 insertions(+), 333 deletions(-) diff --git a/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c b/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c index 752a1d4f..27be075a 100644 --- a/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c +++ b/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c @@ -1856,204 +1856,35 @@ TEST_FUNCTION(event_complete_func_recv_returns_0_bytes_success) } // Tests_SRS_ASYNC_SOCKET_LINUX_04_008: [ event_complete_callback shall call the notify complete callback with an ABANDONED flag when the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY. ] -TEST_FUNCTION(event_complete_func_notify_for_io_type_IN_EPOLLRDHUP_and_abandons_the_connection) -{ - // arrange - ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine); - ASSERT_IS_NOT_NULL(async_socket); - ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx)); - - ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, test_on_notify_complete, test_callback_ctx)); - - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(test_on_notify_complete(test_callback_ctx, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - g_event_callback(g_event_callback_ctx, COMPLETION_PORT_EPOLL_EPOLLRDHUP); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - async_socket_close(async_socket); - async_socket_destroy(async_socket); -} - -// Tests_SRS_ASYNC_SOCKET_LINUX_04_008: [ event_complete_callback shall call the notify complete callback with an ABANDONED flag when the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY. ] -TEST_FUNCTION(event_complete_func_notify_for_io_type_IN_ABANDONED_and_abandons_the_connection) -{ - // arrange - ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine); - ASSERT_IS_NOT_NULL(async_socket); - ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx)); - - ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, test_on_notify_complete, test_callback_ctx)); - - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(test_on_notify_complete(test_callback_ctx, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - g_event_callback(g_event_callback_ctx, COMPLETION_PORT_EPOLL_ABANDONED); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - async_socket_close(async_socket); - async_socket_destroy(async_socket); -} - -// Tests_SRS_ASYNC_SOCKET_LINUX_04_008: [ event_complete_callback shall call the notify complete callback with an ABANDONED flag when the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY. ] -TEST_FUNCTION(event_complete_func_notify_for_io_type_OUT_EPOLLRDHUP_and_abandons_the_connection) -{ - // arrange - ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine); - ASSERT_IS_NOT_NULL(async_socket); - ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx)); - - ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, test_on_notify_complete, test_callback_ctx)); - - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(test_on_notify_complete(test_callback_ctx, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - g_event_callback(g_event_callback_ctx, COMPLETION_PORT_EPOLL_EPOLLRDHUP); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - async_socket_close(async_socket); - async_socket_destroy(async_socket); -} - -// Tests_SRS_ASYNC_SOCKET_LINUX_04_008: [ event_complete_callback shall call the notify complete callback with an ABANDONED flag when the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY. ] -TEST_FUNCTION(event_complete_func_notify_for_io_type_OUT_ABANDONED_and_abandons_the_connection) -{ - // arrange - ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine); - ASSERT_IS_NOT_NULL(async_socket); - ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx)); - - ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, test_on_notify_complete, test_callback_ctx)); - - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(test_on_notify_complete(test_callback_ctx, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - g_event_callback(g_event_callback_ctx, COMPLETION_PORT_EPOLL_ABANDONED); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - async_socket_close(async_socket); - async_socket_destroy(async_socket); -} - // Tests_SRS_ASYNC_SOCKET_LINUX_04_009: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an IN flag. ] -TEST_FUNCTION(event_complete_func_notify_EPOLLIN_calls_callback_with_IN_flag) -{ - // arrange - ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine); - ASSERT_IS_NOT_NULL(async_socket); - ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx)); - - ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, test_on_notify_complete, test_callback_ctx)); - - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(test_on_notify_complete(test_callback_ctx, ASYNC_SOCKET_NOTIFY_IO_RESULT_IN)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - g_event_callback(g_event_callback_ctx, COMPLETION_PORT_EPOLL_EPOLLIN); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - async_socket_close(async_socket); - async_socket_destroy(async_socket); -} - // Tests_SRS_ASYNC_SOCKET_LINUX_04_010: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an OUT flag. ] -TEST_FUNCTION(event_complete_func_notify_EPOLLOUT_calls_callback_with_OUT_flag) -{ - // arrange - ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine); - ASSERT_IS_NOT_NULL(async_socket); - ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx)); - - ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, test_on_notify_complete, test_callback_ctx)); - - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(test_on_notify_complete(test_callback_ctx, ASYNC_SOCKET_NOTIFY_IO_RESULT_OUT)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - g_event_callback(g_event_callback_ctx, COMPLETION_PORT_EPOLL_EPOLLOUT); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - async_socket_close(async_socket); - async_socket_destroy(async_socket); -} - // Tests_SRS_ASYNC_SOCKET_LINUX_04_011: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an ERROR flag. ] -TEST_FUNCTION(event_complete_func_notify_for_io_type_IN_ERROR_calls_callback_with_ERROR_flag) +// Tests_SRS_ASYNC_SOCKET_LINUX_04_012: [ event_complete_callback shall call the notify complete callback with an ABANDONED flag when the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY. ] +PARAMETERIZED_TEST_FUNCTION(event_complete_func_notify_calls_callback_with_expected_result, // no-srs + ARGS(ASYNC_SOCKET_NOTIFY_IO_TYPE, io_type, COMPLETION_PORT_EPOLL_ACTION, epoll_action, ASYNC_SOCKET_NOTIFY_IO_RESULT, expected_result), + CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, COMPLETION_PORT_EPOLL_EPOLLRDHUP, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED), IN_EPOLLRDHUP_abandons), + CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, COMPLETION_PORT_EPOLL_ABANDONED, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED), IN_ABANDONED_abandons), + CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, COMPLETION_PORT_EPOLL_EPOLLRDHUP, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED), OUT_EPOLLRDHUP_abandons), + CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, COMPLETION_PORT_EPOLL_ABANDONED, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED), OUT_ABANDONED_abandons), + CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, COMPLETION_PORT_EPOLL_EPOLLIN, ASYNC_SOCKET_NOTIFY_IO_RESULT_IN), IN_EPOLLIN), + CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, COMPLETION_PORT_EPOLL_EPOLLOUT, ASYNC_SOCKET_NOTIFY_IO_RESULT_OUT), OUT_EPOLLOUT), + CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, COMPLETION_PORT_EPOLL_ERROR, ASYNC_SOCKET_NOTIFY_IO_RESULT_ERROR), IN_ERROR), + CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, COMPLETION_PORT_EPOLL_ERROR, ASYNC_SOCKET_NOTIFY_IO_RESULT_ERROR), OUT_ERROR)) { // arrange ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine); ASSERT_IS_NOT_NULL(async_socket); ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx)); - ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, test_on_notify_complete, test_callback_ctx)); + ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, io_type, test_on_notify_complete, test_callback_ctx)); umock_c_reset_all_calls(); - STRICT_EXPECTED_CALL(test_on_notify_complete(test_callback_ctx, ASYNC_SOCKET_NOTIFY_IO_RESULT_ERROR)); + STRICT_EXPECTED_CALL(test_on_notify_complete(test_callback_ctx, expected_result)); STRICT_EXPECTED_CALL(free(IGNORED_ARG)); // act - g_event_callback(g_event_callback_ctx, COMPLETION_PORT_EPOLL_ERROR); - - // assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - // cleanup - async_socket_close(async_socket); - async_socket_destroy(async_socket); -} - -// Tests_SRS_ASYNC_SOCKET_LINUX_04_011: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an ERROR flag. ] -TEST_FUNCTION(event_complete_func_notify_for_io_type_OUT_ERROR_calls_callback_with_ERROR_flag) -{ - // arrange - ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine); - ASSERT_IS_NOT_NULL(async_socket); - ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx)); - - ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, test_on_notify_complete, test_callback_ctx)); - - umock_c_reset_all_calls(); - - STRICT_EXPECTED_CALL(test_on_notify_complete(test_callback_ctx, ASYNC_SOCKET_NOTIFY_IO_RESULT_ERROR)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - // act - g_event_callback(g_event_callback_ctx, COMPLETION_PORT_EPOLL_ERROR); + g_event_callback(g_event_callback_ctx, epoll_action); // assert ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); diff --git a/win32/tests/file_win32_ut/file_win32_ut.c b/win32/tests/file_win32_ut/file_win32_ut.c index d60e0889..38d161c4 100644 --- a/win32/tests/file_win32_ut/file_win32_ut.c +++ b/win32/tests/file_win32_ut/file_win32_ut.c @@ -806,171 +806,33 @@ TEST_FUNCTION(file_extend_returns_zero) /*Tests_SRS_FILE_WIN32_43_034: [ on_file_io_complete_win32 shall recover the file handle, the number of bytes requested by the user, user_callback and user_context from the context containing overlapped. ]*/ /*Tests_SRS_FILE_WIN32_43_066: [ on_file_io_complete_win32 shall call user_callback with is_successful as true if and only if io_result is equal to NO_ERROR and number_of_bytes_transferred is equal to the number of bytes requested by the user. ]*/ -TEST_FUNCTION(on_file_io_complete_win32_calls_callback_successfully_for_write) -{ - ///arrange - unsigned char source[10]; - uint64_t position = 11; - void* user_context = (void*)20; - - PTP_WIN32_IO_CALLBACK captured_callback = NULL; - LPOVERLAPPED captured_ov; - - FILE_HANDLE file_handle = start_file_io_async(FILE_WRITE_ASYNC, source, sizeof(source), position, mock_user_callback, user_context, &captured_callback, &captured_ov); - - STRICT_EXPECTED_CALL(mock_CloseHandle(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - STRICT_EXPECTED_CALL(mock_user_callback(user_context, true)); - ASSERT_ARE_EQUAL(uint64_t, position, captured_ov->Offset); - - ///act - captured_callback(NULL, NULL, captured_ov, NO_ERROR, sizeof(source), NULL); - - ///assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - ///cleanup - file_destroy(file_handle); -} - -/*Tests_SRS_FILE_WIN32_43_034: [ on_file_io_complete_win32 shall recover the file handle, the number of bytes requested by the user, user_callback and user_context from the context containing overlapped. ]*/ /*Tests_SRS_FILE_WIN32_43_068: [ If either io_result is not equal to NO_ERROR or number_of_bytes_transferred is not equal to the bytes requested by the user, on_file_io_complete_win32 shall return false. ]*/ -TEST_FUNCTION(on_file_io_complete_win32_calls_callback_unsuccessfully_for_write_because_io_failed) +PARAMETERIZED_TEST_FUNCTION(on_file_io_complete_win32_calls_callback, // no-srs + ARGS(FILE_IO_ASYNC_TYPE, io_type, ULONG, io_result, ULONG_PTR, num_bytes_transferred, bool, expected_success), + CASE((FILE_WRITE_ASYNC, NO_ERROR, 10, true), write_success), + CASE((FILE_WRITE_ASYNC, ERROR_IO_INCOMPLETE, 10, false), write_io_failed), + CASE((FILE_WRITE_ASYNC, NO_ERROR, 9, false), write_num_bytes_less), + CASE((FILE_READ_ASYNC, NO_ERROR, 10, true), read_success), + CASE((FILE_READ_ASYNC, ERROR_IO_INCOMPLETE, 10, false), read_io_failed), + CASE((FILE_READ_ASYNC, NO_ERROR, 9, false), read_num_bytes_less)) { ///arrange - unsigned char source[10]; - uint64_t position = 11; - void* user_context = (void*)20; - - PTP_WIN32_IO_CALLBACK captured_callback = NULL; - LPOVERLAPPED captured_ov; - - FILE_HANDLE file_handle = start_file_io_async(FILE_WRITE_ASYNC, source, sizeof(source), position, mock_user_callback, user_context, &captured_callback, &captured_ov); - - STRICT_EXPECTED_CALL(mock_CloseHandle(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - - STRICT_EXPECTED_CALL(mock_user_callback(user_context, false)); - ASSERT_ARE_EQUAL(uint64_t, position, captured_ov->Offset); - - ///act - captured_callback(NULL, NULL, captured_ov, ERROR_IO_INCOMPLETE, sizeof(source), NULL); - - ///assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - ///cleanup - file_destroy(file_handle); -} - -/*Tests_SRS_FILE_WIN32_43_034: [on_file_io_complete_win32 shall recover the file handle, the number of bytes requested by the user, user_callback and user_context from the context containing overlapped.]*/ -/*Tests_SRS_FILE_WIN32_43_068 : [If either io_result is not equal to NO_ERROR or number_of_bytes_transferred is not equal to the bytes requested by the user, on_file_io_complete_win32 shall return false.]*/ -TEST_FUNCTION(on_file_io_complete_win32_calls_callback_unsuccessfully_for_write_because_num_bytes_is_less) -{ - ///arrange - unsigned char source[10]; - uint64_t position = 11; - void* user_context = (void*)20; - - PTP_WIN32_IO_CALLBACK captured_callback = NULL; - LPOVERLAPPED captured_ov; - - FILE_HANDLE file_handle = start_file_io_async(FILE_WRITE_ASYNC, source, sizeof(source), position, mock_user_callback, user_context, &captured_callback, &captured_ov); - - STRICT_EXPECTED_CALL(mock_CloseHandle(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - STRICT_EXPECTED_CALL(mock_user_callback(user_context, false)); - ASSERT_ARE_EQUAL(uint64_t, position, captured_ov->Offset); - - ///act - captured_callback(NULL, NULL, captured_ov, NO_ERROR, sizeof(source)-1, NULL); - - ///assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - ///cleanup - file_destroy(file_handle); -} - -/*Tests_SRS_FILE_WIN32_43_034: [ on_file_io_complete_win32 shall recover the file handle, the number of bytes requested by the user, user_callback and user_context from the context containing overlapped. ]*/ -/*Tests_SRS_FILE_WIN32_43_066: [ on_file_io_complete_win32 shall call user_callback with is_successful as true if and only if io_result is equal to NO_ERROR and number_of_bytes_transferred is equal to the number of bytes requested by the user. ]*/ -TEST_FUNCTION(on_file_io_complete_win32_calls_callback_successfully_for_read) -{ - ///arrange - unsigned char destination[10]; - uint64_t position = 11; - void* user_context = (void*)20; - - PTP_WIN32_IO_CALLBACK captured_callback = NULL; - LPOVERLAPPED captured_ov; - - FILE_HANDLE file_handle = start_file_io_async(FILE_READ_ASYNC, destination, sizeof(destination), position, mock_user_callback, user_context, &captured_callback, &captured_ov); - - STRICT_EXPECTED_CALL(mock_CloseHandle(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - STRICT_EXPECTED_CALL(mock_user_callback(user_context, true)); - ASSERT_ARE_EQUAL(uint64_t, position, captured_ov->Offset); - - ///act - captured_callback(NULL, NULL, captured_ov, NO_ERROR, sizeof(destination), NULL); - - ///assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - ///cleanup - file_destroy(file_handle); -} - -/*Tests_SRS_FILE_WIN32_43_034: [ on_file_io_complete_win32 shall recover the file handle, the number of bytes requested by the user, user_callback and user_context from the context containing overlapped. ]*/ -/*Tests_SRS_FILE_WIN32_43_068: [ If either io_result is not equal to NO_ERROR or number_of_bytes_transferred is not equal to the bytes requested by the user, on_file_io_complete_win32 shall return false. ]*/ -TEST_FUNCTION(on_file_io_complete_win32_calls_callback_unsuccessfully_for_read_because_io_failed) -{ - ///arrange - unsigned char destination[10]; - uint64_t position = 11; - void* user_context = (void*)20; - - PTP_WIN32_IO_CALLBACK captured_callback = NULL; - LPOVERLAPPED captured_ov; - - FILE_HANDLE file_handle = start_file_io_async(FILE_READ_ASYNC, destination, sizeof(destination), position, mock_user_callback, user_context, &captured_callback, &captured_ov); - - STRICT_EXPECTED_CALL(mock_CloseHandle(IGNORED_ARG)); - STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - STRICT_EXPECTED_CALL(mock_user_callback(user_context, false)); - ASSERT_ARE_EQUAL(uint64_t, position, captured_ov->Offset); - - ///act - captured_callback(NULL, NULL, captured_ov, ERROR_IO_INCOMPLETE, sizeof(destination), NULL); - - ///assert - ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); - - ///cleanup - file_destroy(file_handle); -} - -/*Tests_SRS_FILE_WIN32_43_034: [on_file_io_complete_win32 shall recover the file handle, the number of bytes requested by the user, user_callback and user_context from the context containing overlapped.]*/ -/*Tests_SRS_FILE_WIN32_43_068 : [If either io_result is not equal to NO_ERROR or number_of_bytes_transferred is not equal to the bytes requested by the user, on_file_io_complete_win32 shall return false.]*/ -TEST_FUNCTION(on_file_io_complete_win32_calls_callback_unsuccessfully_for_read_because_num_bytes_is_less) -{ - ///arrange - unsigned char destination[10]; + unsigned char buffer[10]; uint64_t position = 11; void* user_context = (void*)20; PTP_WIN32_IO_CALLBACK captured_callback = NULL; LPOVERLAPPED captured_ov; - FILE_HANDLE file_handle = start_file_io_async(FILE_READ_ASYNC, destination, sizeof(destination), position, mock_user_callback, user_context, &captured_callback, &captured_ov); + FILE_HANDLE file_handle = start_file_io_async(io_type, buffer, sizeof(buffer), position, mock_user_callback, user_context, &captured_callback, &captured_ov); STRICT_EXPECTED_CALL(mock_CloseHandle(IGNORED_ARG)); STRICT_EXPECTED_CALL(free(IGNORED_ARG)); - STRICT_EXPECTED_CALL(mock_user_callback(user_context, false)); + STRICT_EXPECTED_CALL(mock_user_callback(user_context, expected_success)); ASSERT_ARE_EQUAL(uint64_t, position, captured_ov->Offset); ///act - captured_callback(NULL, NULL, captured_ov, NO_ERROR, sizeof(destination) -1, NULL); + captured_callback(NULL, NULL, captured_ov, io_result, num_bytes_transferred, NULL); ///assert ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); From 6eaeff34ffd465fe6935c689f6824efba9701765 Mon Sep 17 00:00:00 2001 From: Matt Durak Date: Tue, 10 Mar 2026 22:19:21 -0700 Subject: [PATCH 4/8] Fix: remove no-srs comments from test functions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c | 4 ++-- .../real_thandle_log_context_handle_ut.c | 2 +- linux/tests/async_socket_linux_ut/async_socket_linux_ut.c | 2 +- linux/tests/linux_reals_ut/reals_linux_ut.c | 2 +- win32/tests/file_win32_ut/file_win32_ut.c | 2 +- win32/tests/reals_win32_ut/reals_win32_ut.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c b/common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c index e8a8067e..c7d46691 100644 --- a/common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c +++ b/common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c @@ -86,7 +86,7 @@ TEST_FUNCTION_CLEANUP(TestMethodCleanup) umock_c_reset_all_calls(); } -TEST_FUNCTION(thandle_test_helper_can_register_for_a_real_thandle) // no-srs +TEST_FUNCTION(thandle_test_helper_can_register_for_a_real_thandle) { // arrange THANDLE(MOCKED_STRUCT) upcounted_MOCKED_STRUCT = NULL; @@ -98,7 +98,7 @@ TEST_FUNCTION(thandle_test_helper_can_register_for_a_real_thandle) // no-srs THANDLE_ASSIGN(MOCKED_STRUCT)(&upcounted_MOCKED_STRUCT, NULL); } -TEST_FUNCTION(function_call_is_mocked_correctly) // no-srs +TEST_FUNCTION(function_call_is_mocked_correctly) { // arrange STRICT_EXPECTED_CALL(interlocked_exchange(IGNORED_ARG, 0)); diff --git a/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c b/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c index d874d27d..1c5baf4a 100644 --- a/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c +++ b/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c @@ -47,7 +47,7 @@ TEST_FUNCTION_CLEANUP(TestMethodCleanup) } -TEST_FUNCTION(thandle_ptr_log_context_handle_with_mocks) // no-srs +TEST_FUNCTION(thandle_ptr_log_context_handle_with_mocks) { ///arrange STRICT_EXPECTED_CALL(THANDLE_PTR_CREATE_WITH_MOVE(LOG_CONTEXT_HANDLE)(IGNORED_ARG, NULL)); diff --git a/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c b/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c index 27be075a..03e7db62 100644 --- a/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c +++ b/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c @@ -1860,7 +1860,7 @@ TEST_FUNCTION(event_complete_func_recv_returns_0_bytes_success) // Tests_SRS_ASYNC_SOCKET_LINUX_04_010: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an OUT flag. ] // Tests_SRS_ASYNC_SOCKET_LINUX_04_011: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an ERROR flag. ] // Tests_SRS_ASYNC_SOCKET_LINUX_04_012: [ event_complete_callback shall call the notify complete callback with an ABANDONED flag when the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY. ] -PARAMETERIZED_TEST_FUNCTION(event_complete_func_notify_calls_callback_with_expected_result, // no-srs +PARAMETERIZED_TEST_FUNCTION(event_complete_func_notify_calls_callback_with_expected_result ARGS(ASYNC_SOCKET_NOTIFY_IO_TYPE, io_type, COMPLETION_PORT_EPOLL_ACTION, epoll_action, ASYNC_SOCKET_NOTIFY_IO_RESULT, expected_result), CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, COMPLETION_PORT_EPOLL_EPOLLRDHUP, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED), IN_EPOLLRDHUP_abandons), CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, COMPLETION_PORT_EPOLL_ABANDONED, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED), IN_ABANDONED_abandons), diff --git a/linux/tests/linux_reals_ut/reals_linux_ut.c b/linux/tests/linux_reals_ut/reals_linux_ut.c index 77585553..6731b54c 100644 --- a/linux/tests/linux_reals_ut/reals_linux_ut.c +++ b/linux/tests/linux_reals_ut/reals_linux_ut.c @@ -7,7 +7,7 @@ BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE) // this test makes sure that the mappings work // (there is a real_ function corresponding to the original) -TEST_FUNCTION(check_all_c_pal_reals) // no-srs +TEST_FUNCTION(check_all_c_pal_reals) { // arrange diff --git a/win32/tests/file_win32_ut/file_win32_ut.c b/win32/tests/file_win32_ut/file_win32_ut.c index 38d161c4..09ba8fee 100644 --- a/win32/tests/file_win32_ut/file_win32_ut.c +++ b/win32/tests/file_win32_ut/file_win32_ut.c @@ -807,7 +807,7 @@ TEST_FUNCTION(file_extend_returns_zero) /*Tests_SRS_FILE_WIN32_43_034: [ on_file_io_complete_win32 shall recover the file handle, the number of bytes requested by the user, user_callback and user_context from the context containing overlapped. ]*/ /*Tests_SRS_FILE_WIN32_43_066: [ on_file_io_complete_win32 shall call user_callback with is_successful as true if and only if io_result is equal to NO_ERROR and number_of_bytes_transferred is equal to the number of bytes requested by the user. ]*/ /*Tests_SRS_FILE_WIN32_43_068: [ If either io_result is not equal to NO_ERROR or number_of_bytes_transferred is not equal to the bytes requested by the user, on_file_io_complete_win32 shall return false. ]*/ -PARAMETERIZED_TEST_FUNCTION(on_file_io_complete_win32_calls_callback, // no-srs +PARAMETERIZED_TEST_FUNCTION(on_file_io_complete_win32_calls_callback ARGS(FILE_IO_ASYNC_TYPE, io_type, ULONG, io_result, ULONG_PTR, num_bytes_transferred, bool, expected_success), CASE((FILE_WRITE_ASYNC, NO_ERROR, 10, true), write_success), CASE((FILE_WRITE_ASYNC, ERROR_IO_INCOMPLETE, 10, false), write_io_failed), diff --git a/win32/tests/reals_win32_ut/reals_win32_ut.c b/win32/tests/reals_win32_ut/reals_win32_ut.c index 6123b31e..f20b0286 100644 --- a/win32/tests/reals_win32_ut/reals_win32_ut.c +++ b/win32/tests/reals_win32_ut/reals_win32_ut.c @@ -7,7 +7,7 @@ BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE) // this test makes sure that the mappings work // (there is a real_ function corresponding to the original) -TEST_FUNCTION(check_all_c_pal_reals) // no-srs +TEST_FUNCTION(check_all_c_pal_reals) { // arrange From 46199803bd065b41ebe6891428784f01ea61cb3c Mon Sep 17 00:00:00 2001 From: Matt Durak Date: Tue, 10 Mar 2026 23:26:00 -0700 Subject: [PATCH 5/8] Fix PR review: remove extraneous SRS comment, restore // no-srs on non-parameterized tests - Remove extraneous Tests_SRS_ASYNC_SOCKET_LINUX_04_012 comment from async_socket_linux_ut.c - Restore // no-srs on TEST_FUNCTIONs in real_thandle_helper_ut.c, real_thandle_log_context_handle_ut.c, reals_linux_ut.c, reals_win32_ut.c Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c | 4 ++-- .../real_thandle_log_context_handle_ut.c | 2 +- linux/tests/async_socket_linux_ut/async_socket_linux_ut.c | 1 - linux/tests/linux_reals_ut/reals_linux_ut.c | 2 +- win32/tests/reals_win32_ut/reals_win32_ut.c | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c b/common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c index c7d46691..e8a8067e 100644 --- a/common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c +++ b/common/tests/real_thandle_helper_ut/real_thandle_helper_ut.c @@ -86,7 +86,7 @@ TEST_FUNCTION_CLEANUP(TestMethodCleanup) umock_c_reset_all_calls(); } -TEST_FUNCTION(thandle_test_helper_can_register_for_a_real_thandle) +TEST_FUNCTION(thandle_test_helper_can_register_for_a_real_thandle) // no-srs { // arrange THANDLE(MOCKED_STRUCT) upcounted_MOCKED_STRUCT = NULL; @@ -98,7 +98,7 @@ TEST_FUNCTION(thandle_test_helper_can_register_for_a_real_thandle) THANDLE_ASSIGN(MOCKED_STRUCT)(&upcounted_MOCKED_STRUCT, NULL); } -TEST_FUNCTION(function_call_is_mocked_correctly) +TEST_FUNCTION(function_call_is_mocked_correctly) // no-srs { // arrange STRICT_EXPECTED_CALL(interlocked_exchange(IGNORED_ARG, 0)); diff --git a/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c b/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c index 1c5baf4a..d874d27d 100644 --- a/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c +++ b/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c @@ -47,7 +47,7 @@ TEST_FUNCTION_CLEANUP(TestMethodCleanup) } -TEST_FUNCTION(thandle_ptr_log_context_handle_with_mocks) +TEST_FUNCTION(thandle_ptr_log_context_handle_with_mocks) // no-srs { ///arrange STRICT_EXPECTED_CALL(THANDLE_PTR_CREATE_WITH_MOVE(LOG_CONTEXT_HANDLE)(IGNORED_ARG, NULL)); diff --git a/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c b/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c index 03e7db62..b95cc8df 100644 --- a/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c +++ b/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c @@ -1859,7 +1859,6 @@ TEST_FUNCTION(event_complete_func_recv_returns_0_bytes_success) // Tests_SRS_ASYNC_SOCKET_LINUX_04_009: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an IN flag. ] // Tests_SRS_ASYNC_SOCKET_LINUX_04_010: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an OUT flag. ] // Tests_SRS_ASYNC_SOCKET_LINUX_04_011: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an ERROR flag. ] -// Tests_SRS_ASYNC_SOCKET_LINUX_04_012: [ event_complete_callback shall call the notify complete callback with an ABANDONED flag when the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY. ] PARAMETERIZED_TEST_FUNCTION(event_complete_func_notify_calls_callback_with_expected_result ARGS(ASYNC_SOCKET_NOTIFY_IO_TYPE, io_type, COMPLETION_PORT_EPOLL_ACTION, epoll_action, ASYNC_SOCKET_NOTIFY_IO_RESULT, expected_result), CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, COMPLETION_PORT_EPOLL_EPOLLRDHUP, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED), IN_EPOLLRDHUP_abandons), diff --git a/linux/tests/linux_reals_ut/reals_linux_ut.c b/linux/tests/linux_reals_ut/reals_linux_ut.c index 6731b54c..77585553 100644 --- a/linux/tests/linux_reals_ut/reals_linux_ut.c +++ b/linux/tests/linux_reals_ut/reals_linux_ut.c @@ -7,7 +7,7 @@ BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE) // this test makes sure that the mappings work // (there is a real_ function corresponding to the original) -TEST_FUNCTION(check_all_c_pal_reals) +TEST_FUNCTION(check_all_c_pal_reals) // no-srs { // arrange diff --git a/win32/tests/reals_win32_ut/reals_win32_ut.c b/win32/tests/reals_win32_ut/reals_win32_ut.c index f20b0286..6123b31e 100644 --- a/win32/tests/reals_win32_ut/reals_win32_ut.c +++ b/win32/tests/reals_win32_ut/reals_win32_ut.c @@ -7,7 +7,7 @@ BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE) // this test makes sure that the mappings work // (there is a real_ function corresponding to the original) -TEST_FUNCTION(check_all_c_pal_reals) +TEST_FUNCTION(check_all_c_pal_reals) // no-srs { // arrange From 71674909bf047a591e2666149a4227a37756dfc3 Mon Sep 17 00:00:00 2001 From: Matt Durak Date: Wed, 11 Mar 2026 14:48:59 -0700 Subject: [PATCH 6/8] Update deps/umock-c to master (parameterized tests merged) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- deps/umock-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/umock-c b/deps/umock-c index e051923e..b1803d97 160000 --- a/deps/umock-c +++ b/deps/umock-c @@ -1 +1 @@ -Subproject commit e051923ef27c842d2b22417c702a933e9d7f8388 +Subproject commit b1803d9775c4474af4ee1a7526387d27654ae7cf From b8830f3bfdbe0d5dba2e2271a9611c3834f37e01 Mon Sep 17 00:00:00 2001 From: Matt Durak Date: Wed, 11 Mar 2026 15:21:22 -0700 Subject: [PATCH 7/8] Fix missing comma in file_win32_ut.c PARAMETERIZED_TEST_FUNCTION Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- win32/tests/file_win32_ut/file_win32_ut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32/tests/file_win32_ut/file_win32_ut.c b/win32/tests/file_win32_ut/file_win32_ut.c index 09ba8fee..69381edc 100644 --- a/win32/tests/file_win32_ut/file_win32_ut.c +++ b/win32/tests/file_win32_ut/file_win32_ut.c @@ -807,7 +807,7 @@ TEST_FUNCTION(file_extend_returns_zero) /*Tests_SRS_FILE_WIN32_43_034: [ on_file_io_complete_win32 shall recover the file handle, the number of bytes requested by the user, user_callback and user_context from the context containing overlapped. ]*/ /*Tests_SRS_FILE_WIN32_43_066: [ on_file_io_complete_win32 shall call user_callback with is_successful as true if and only if io_result is equal to NO_ERROR and number_of_bytes_transferred is equal to the number of bytes requested by the user. ]*/ /*Tests_SRS_FILE_WIN32_43_068: [ If either io_result is not equal to NO_ERROR or number_of_bytes_transferred is not equal to the bytes requested by the user, on_file_io_complete_win32 shall return false. ]*/ -PARAMETERIZED_TEST_FUNCTION(on_file_io_complete_win32_calls_callback +PARAMETERIZED_TEST_FUNCTION(on_file_io_complete_win32_calls_callback, ARGS(FILE_IO_ASYNC_TYPE, io_type, ULONG, io_result, ULONG_PTR, num_bytes_transferred, bool, expected_success), CASE((FILE_WRITE_ASYNC, NO_ERROR, 10, true), write_success), CASE((FILE_WRITE_ASYNC, ERROR_IO_INCOMPLETE, 10, false), write_io_failed), From 1a7242b719248b1e9c1e0cecce2922330b47134e Mon Sep 17 00:00:00 2001 From: Matt Durak Date: Wed, 11 Mar 2026 15:41:47 -0700 Subject: [PATCH 8/8] Fix missing comma in async_socket_linux_ut.c PARAMETERIZED_TEST_FUNCTION Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- linux/tests/async_socket_linux_ut/async_socket_linux_ut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c b/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c index b95cc8df..d274750a 100644 --- a/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c +++ b/linux/tests/async_socket_linux_ut/async_socket_linux_ut.c @@ -1859,7 +1859,7 @@ TEST_FUNCTION(event_complete_func_recv_returns_0_bytes_success) // Tests_SRS_ASYNC_SOCKET_LINUX_04_009: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an IN flag. ] // Tests_SRS_ASYNC_SOCKET_LINUX_04_010: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an OUT flag. ] // Tests_SRS_ASYNC_SOCKET_LINUX_04_011: [ If the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY then event_complete_callback shall call the notify complete callback with an ERROR flag. ] -PARAMETERIZED_TEST_FUNCTION(event_complete_func_notify_calls_callback_with_expected_result +PARAMETERIZED_TEST_FUNCTION(event_complete_func_notify_calls_callback_with_expected_result, ARGS(ASYNC_SOCKET_NOTIFY_IO_TYPE, io_type, COMPLETION_PORT_EPOLL_ACTION, epoll_action, ASYNC_SOCKET_NOTIFY_IO_RESULT, expected_result), CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, COMPLETION_PORT_EPOLL_EPOLLRDHUP, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED), IN_EPOLLRDHUP_abandons), CASE((ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, COMPLETION_PORT_EPOLL_ABANDONED, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED), IN_ABANDONED_abandons),