Skip to content

Commit 5802483

Browse files
parth21999Copilot
andcommitted
Convert all tests to use TIMED_TEST_SUITE_INITIALIZE/CLEANUP
Replace TEST_SUITE_INITIALIZE/CLEANUP with TIMED_TEST_SUITE_INITIALIZE/ TIMED_TEST_SUITE_CLEANUP across 65 test files. Add c_pal/timed_test_suite.h to 49 PCH files and 17 integration test files. The timed versions inject a process watchdog that terminates test suites that hang, preventing CI pipelines from stalling indefinitely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 886a915 commit 5802483

114 files changed

Lines changed: 273 additions & 210 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

samples/async_op_samples_int/async_op_samples_int.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "c_pal/sync.h"
1717
#include "c_pal/thandle.h"
1818
#include "c_pal/threadapi.h"
19+
#include "c_pal/timed_test_suite.h"
1920

2021
#include "c_util/async_op.h"
2122

@@ -366,12 +367,12 @@ static void test_ASYNC_OP_MODULE_CALLBACK(void* context, COMMON_ASYNC_OP_MODULE_
366367

367368
BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
368369

369-
TEST_SUITE_INITIALIZE(TestClassInit)
370+
TIMED_TEST_SUITE_INITIALIZE(TestClassInit, TIMED_TEST_DEFAULT_TIMEOUT_MS)
370371
{
371372
ASSERT_ARE_EQUAL(int, 0, gballoc_hl_init(NULL, NULL));
372373
}
373374

374-
TEST_SUITE_CLEANUP(TestClassCleanup)
375+
TIMED_TEST_SUITE_CLEANUP(TestClassCleanup)
375376
{
376377
gballoc_hl_deinit();
377378
}
@@ -1444,4 +1445,4 @@ TEST_FUNCTION(all_modules_can_be_canceled_successfully_with_real_cancel_after_ma
14441445
}
14451446
}
14461447

1447-
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
1448+
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

tests/async_op_int/async_op_int.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "c_pal/gballoc_hl_redirect.h"
1616

1717
#include "c_pal/thandle.h"
18+
#include "c_pal/timed_test_suite.h"
1819

1920
#include "c_util/async_op.h"
2021

@@ -84,12 +85,12 @@ static ASYNC_OP_DISPOSE disposes[] =
8485

8586
BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
8687

87-
TEST_SUITE_INITIALIZE(setsBufferTempSize)
88+
TIMED_TEST_SUITE_INITIALIZE(setsBufferTempSize, TIMED_TEST_DEFAULT_TIMEOUT_MS)
8889
{
8990
ASSERT_ARE_EQUAL(int, 0, gballoc_hl_init(NULL, NULL));
9091
}
9192

92-
TEST_SUITE_CLEANUP(TestClassCleanup)
93+
TIMED_TEST_SUITE_CLEANUP(TestClassCleanup)
9394
{
9495
gballoc_hl_deinit();
9596
}
@@ -144,4 +145,4 @@ TEST_FUNCTION(async_op_from_context_with_alignment_1)
144145
}
145146
}
146147

147-
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
148+
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

tests/async_op_ut/async_op_ut.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static void on_umock_c_error(UMOCK_C_ERROR_CODE error_code)
2222

2323
BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
2424

25-
TEST_SUITE_INITIALIZE(setsBufferTempSize)
25+
TIMED_TEST_SUITE_INITIALIZE(setsBufferTempSize, TIMED_TEST_DEFAULT_TIMEOUT_MS)
2626
{
2727
ASSERT_ARE_EQUAL(int, 0, real_gballoc_hl_init(NULL, NULL));
2828

@@ -33,7 +33,7 @@ TEST_SUITE_INITIALIZE(setsBufferTempSize)
3333
REGISTER_GLOBAL_MOCK_FAIL_RETURN(realloc, NULL);
3434
}
3535

36-
TEST_SUITE_CLEANUP(TestClassCleanup)
36+
TIMED_TEST_SUITE_CLEANUP(TestClassCleanup)
3737
{
3838
umock_c_deinit();
3939

tests/async_op_ut/async_op_ut_pch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
#include "real_gballoc_hl.h"
2424

2525
#include "c_pal/thandle.h"
26+
#include "c_pal/timed_test_suite.h"
2627

2728
#include "c_util/async_op.h"
2829

29-
#endif // ASYNC_OP_UT_PCH_H
30+
#endif // ASYNC_OP_UT_PCH_H

tests/async_retry_wrapper_ut/async_retry_wrapper_ut.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static void on_umock_c_error(UMOCK_C_ERROR_CODE error_code)
205205

206206
BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
207207

208-
TEST_SUITE_INITIALIZE(suite_init)
208+
TIMED_TEST_SUITE_INITIALIZE(suite_init, TIMED_TEST_DEFAULT_TIMEOUT_MS)
209209
{
210210
ASSERT_ARE_EQUAL(int, 0, real_gballoc_hl_init(NULL, NULL));
211211

@@ -258,7 +258,7 @@ TEST_SUITE_INITIALIZE(suite_init)
258258
REGISTER_TYPE(TEST_ASYNC_API_SYNC_MULTIPLE_RESULT, TEST_ASYNC_API_SYNC_MULTIPLE_RESULT);
259259
}
260260

261-
TEST_SUITE_CLEANUP(suite_cleanup)
261+
TIMED_TEST_SUITE_CLEANUP(suite_cleanup)
262262
{
263263
THANDLE_ASSIGN(REAL_THREADPOOL)(&g.test_threadpool, NULL);
264264
umock_c_deinit();

tests/async_retry_wrapper_ut/async_retry_wrapper_ut_pch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "c_pal/interlocked_hl.h"
3434
#include "c_pal/log_critical_and_terminate.h"
35+
#include "c_pal/timed_test_suite.h"
3536

3637
#include "test_async.h"
3738
#include "test_ref_counted.h"
@@ -46,4 +47,4 @@
4647

4748
#include "c_util/async_retry_wrapper.h"
4849

49-
#endif // ASYNC_RETRY_WRAPPER_UT_PCH_H
50+
#endif // ASYNC_RETRY_WRAPPER_UT_PCH_H

tests/async_type_helper_copy_value_handler_ut/async_type_helper_copy_value_handler_ut.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft. All rights reserved.
1+
// Copyright (c) Microsoft. All rights reserved.
22

33

44

@@ -27,7 +27,7 @@ static void on_umock_c_error(UMOCK_C_ERROR_CODE error_code)
2727

2828
BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
2929

30-
TEST_SUITE_INITIALIZE(suite_init)
30+
TIMED_TEST_SUITE_INITIALIZE(suite_init, TIMED_TEST_DEFAULT_TIMEOUT_MS)
3131
{
3232
ASSERT_ARE_EQUAL(int, 0, real_gballoc_hl_init(NULL, NULL));
3333

@@ -38,7 +38,7 @@ TEST_SUITE_INITIALIZE(suite_init)
3838

3939
}
4040

41-
TEST_SUITE_CLEANUP(suite_cleanup)
41+
TIMED_TEST_SUITE_CLEANUP(suite_cleanup)
4242
{
4343
umock_c_deinit();
4444

tests/async_type_helper_copy_value_handler_ut/async_type_helper_copy_value_handler_ut_pch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "umock_c/umock_c_ENABLE_MOCKS.h" // ============================== ENABLE_MOCKS
2121
#include "c_pal/gballoc_hl.h"
2222
#include "c_pal/gballoc_hl_redirect.h"
23+
#include "c_pal/timed_test_suite.h"
2324
#include "umock_c/umock_c_DISABLE_MOCKS.h" // ============================== DISABLE_MOCKS
2425

2526
#include "real_gballoc_hl.h"
@@ -28,4 +29,4 @@
2829

2930
#include "c_util/async_type_helper_copy_value_handler.h"
3031

31-
#endif // ASYNC_TYPE_HELPER_COPY_VALUE_HANDLER_UT_PCH_H
32+
#endif // ASYNC_TYPE_HELPER_COPY_VALUE_HANDLER_UT_PCH_H

tests/async_type_helper_ref_counted_handler_ut/async_type_helper_ref_counted_handler_ut.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static void on_umock_c_error(UMOCK_C_ERROR_CODE error_code)
2121

2222
BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
2323

24-
TEST_SUITE_INITIALIZE(suite_init)
24+
TIMED_TEST_SUITE_INITIALIZE(suite_init, TIMED_TEST_DEFAULT_TIMEOUT_MS)
2525
{
2626
ASSERT_ARE_EQUAL(int, 0, real_gballoc_hl_init(NULL, NULL));
2727

@@ -38,7 +38,7 @@ TEST_SUITE_INITIALIZE(suite_init)
3838
REGISTER_UMOCK_ALIAS_TYPE(TEST_REFCOUNTED_HANDLE, void*);
3939
}
4040

41-
TEST_SUITE_CLEANUP(suite_cleanup)
41+
TIMED_TEST_SUITE_CLEANUP(suite_cleanup)
4242
{
4343
umock_c_deinit();
4444

tests/async_type_helper_ref_counted_handler_ut/async_type_helper_ref_counted_handler_ut_pch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "umock_c/umock_c_ENABLE_MOCKS.h" // ============================== ENABLE_MOCKS
2121
#include "c_pal/gballoc_hl.h"
2222
#include "c_pal/gballoc_hl_redirect.h"
23+
#include "c_pal/timed_test_suite.h"
2324
#include "test_ref_counted.h"
2425
#include "umock_c/umock_c_DISABLE_MOCKS.h" // ============================== DISABLE_MOCKS
2526
#include "real_gballoc_hl.h"
@@ -29,4 +30,4 @@
2930

3031
#include "c_util/async_type_helper_ref_counted_handler.h"
3132

32-
#endif // ASYNC_TYPE_HELPER_REF_COUNTED_HANDLER_UT_PCH_H
33+
#endif // ASYNC_TYPE_HELPER_REF_COUNTED_HANDLER_UT_PCH_H

0 commit comments

Comments
 (0)