Skip to content

Commit c7b91fa

Browse files
parth21999Copilot
andcommitted
Convert all tests to use TIMED_TEST_SUITE_INITIALIZE/CLEANUP
- Replace TEST_SUITE_INITIALIZE/CLEANUP with TIMED_ versions in 91 test files - Add c_pal/timed_test_suite.h to 62 PCH files and 36 int/perf test files - Add c_pal_reals and c_pal to ADDITIONAL_LIBS in test CMakeLists.txt - Add process_watchdog reals (real_process_watchdog.c/.h) for both win32 and linux - timed_test_suite.h uses real_ renames so the watchdog works even when interlocked and other dependencies are mocked in unit tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2e23fd9 commit c7b91fa

226 files changed

Lines changed: 548 additions & 324 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.

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,30 @@ else()
218218
target_link_libraries(c_pal_reals INTERFACE linux_reals linux_ll_reals)
219219
endif()
220220

221+
# Separate library for real_process_watchdog - kept out of c_pal_reals to avoid
222+
# conflicts with process_watchdog_ut which provides its own mocked version.
223+
# Tests using TIMED_TEST_SUITE_INITIALIZE link this via ADDITIONAL_LIBS.
224+
# Use OBJECT library so it compiles but doesn't link transitively.
225+
# Consumer tests link c_pal_reals (for UTs) or c_pal (for int tests) separately.
226+
if(MSVC)
227+
add_library(real_process_watchdog OBJECT ${CMAKE_CURRENT_LIST_DIR}/win32/reals/real_process_watchdog.c)
228+
else()
229+
add_library(real_process_watchdog OBJECT ${CMAKE_CURRENT_LIST_DIR}/linux/linux_reals/real_process_watchdog.c)
230+
endif()
231+
target_include_directories(real_process_watchdog PUBLIC
232+
${CMAKE_CURRENT_LIST_DIR}/common/reals
233+
${CMAKE_CURRENT_LIST_DIR}/common/inc
234+
${CMAKE_CURRENT_LIST_DIR}/c_pal_ll/interfaces/reals
235+
${CMAKE_CURRENT_LIST_DIR}/interfaces/reals
236+
$<TARGET_PROPERTY:c_pal,INTERFACE_INCLUDE_DIRECTORIES>
237+
)
238+
if(NOT MSVC)
239+
target_include_directories(real_process_watchdog PRIVATE
240+
${CMAKE_CURRENT_LIST_DIR}/linux/src
241+
${CMAKE_CURRENT_LIST_DIR}/linux/inc
242+
)
243+
endif()
244+
221245
if(${run_reals_check})
222246
add_reals_check_target()
223247
endif()

c_pal_ll/interfaces/tests/interlocked_macros_ut/CMakeLists.txt

Lines changed: 2 additions & 2 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
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
set(theseTestsName interlocked_macros_ut)
@@ -11,6 +11,6 @@ set(${theseTestsName}_h_files
1111
../../inc/c_pal/interlocked_macros.h
1212
)
1313

14-
build_test_artifacts(${theseTestsName} "tests/c_pal_ll/int" ADDITIONAL_LIBS pal_ll_interfaces c_pal
14+
build_test_artifacts(${theseTestsName} "tests/c_pal_ll/int" ADDITIONAL_LIBS c_pal_reals real_process_watchdog pal_ll_interfaces c_pal
1515
ENABLE_TEST_FILES_PRECOMPILED_HEADERS "${CMAKE_CURRENT_LIST_DIR}/interlocked_macros_ut_pch.h"
1616
)

c_pal_ll/interfaces/tests/interlocked_macros_ut/interlocked_macros_ut_pch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
#include "macro_utils/macro_utils.h" // IWYU pragma: keep
1515

1616
#include "c_pal/interlocked.h"
17+
#include "c_pal/timed_test_suite.h"
1718

1819
#endif // INTERLOCKED_MACROS_UT_PCH_H

c_pal_ll/linux/tests/interlocked_linux_ut/CMakeLists.txt

Lines changed: 2 additions & 2 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
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
set(theseTestsName interlocked_linux_ut)
@@ -16,6 +16,6 @@ set(${theseTestsName}_h_files
1616
mock_interlocked.h
1717
)
1818

19-
build_test_artifacts(${theseTestsName} "tests/c_pal/linux" ADDITIONAL_LIBS pal_ll_interfaces
19+
build_test_artifacts(${theseTestsName} "tests/c_pal/linux" ADDITIONAL_LIBS c_pal c_pal_reals real_process_watchdog pal_ll_interfaces
2020
ENABLE_TEST_FILES_PRECOMPILED_HEADERS "${CMAKE_CURRENT_LIST_DIR}/interlocked_linux_ut_pch.h"
2121
)

c_pal_ll/linux/tests/interlocked_linux_ut/interlocked_linux_ut_pch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
#include "umock_c/umocktypes_stdint.h"
1919

2020
#include "c_pal/interlocked.h"
21+
#include "c_pal/timed_test_suite.h"
2122

2223
#endif // INTERLOCKED_LINUX_UT_PCH_H

c_pal_ll/linux/tests/sync_linux_ut/CMakeLists.txt

Lines changed: 2 additions & 2 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
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
set(theseTestsName sync_linux_ut)
@@ -16,6 +16,6 @@ set(${theseTestsName}_h_files
1616
mock_sync.h
1717
)
1818

19-
build_test_artifacts(${theseTestsName} "tests/c_pal/linux" ADDITIONAL_LIBS pal_ll_interfaces
19+
build_test_artifacts(${theseTestsName} "tests/c_pal/linux" ADDITIONAL_LIBS c_pal c_pal_reals real_process_watchdog pal_ll_interfaces
2020
ENABLE_TEST_FILES_PRECOMPILED_HEADERS "${CMAKE_CURRENT_LIST_DIR}/sync_linux_ut_pch.h"
2121
)

c_pal_ll/linux/tests/sync_linux_ut/sync_linux_ut_pch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "c_pal/interlocked.h"
2626
#include "c_pal/sync.h"
27+
#include "c_pal/timed_test_suite.h"
2728

2829
// No idea why iwyu warns about this since we include time.h but...
2930
// IWYU pragma: no_forward_declare timespec

c_pal_ll/win32/tests/interlocked_win32_ut/CMakeLists.txt

Lines changed: 2 additions & 2 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
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
set(theseTestsName interlocked_win32_ut)
@@ -16,6 +16,6 @@ set(${theseTestsName}_h_files
1616
mock_interlocked.h
1717
)
1818

19-
build_test_artifacts(${theseTestsName} "tests/c_pal/win32" ADDITIONAL_LIBS pal_ll_interfaces
19+
build_test_artifacts(${theseTestsName} "tests/c_pal/win32" ADDITIONAL_LIBS c_pal c_pal_reals real_process_watchdog pal_ll_interfaces
2020
ENABLE_TEST_FILES_PRECOMPILED_HEADERS "${CMAKE_CURRENT_LIST_DIR}/interlocked_win32_ut_pch.h"
2121
)

c_pal_ll/win32/tests/interlocked_win32_ut/interlocked_win32_ut_pch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
#include "umock_c/umocktypes_windows.h"
1919

2020
#include "c_pal/interlocked.h"
21+
#include "c_pal/timed_test_suite.h"
2122

2223
#endif // INTERLOCKED_WIN32_UT_PCH_H

c_pal_ll/win32/tests/sync_win32_ut/CMakeLists.txt

Lines changed: 2 additions & 2 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
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
set(theseTestsName sync_win32_ut)
@@ -16,6 +16,6 @@ set(${theseTestsName}_h_files
1616
mock_sync.h
1717
)
1818

19-
build_test_artifacts(${theseTestsName} "tests/c_pal/win32" ADDITIONAL_LIBS pal_interfaces c_pal_reals
19+
build_test_artifacts(${theseTestsName} "tests/c_pal/win32" ADDITIONAL_LIBS c_pal pal_interfaces c_pal_reals real_process_watchdog
2020
ENABLE_TEST_FILES_PRECOMPILED_HEADERS "${CMAKE_CURRENT_LIST_DIR}/sync_win32_ut_pch.h"
2121
)

0 commit comments

Comments
 (0)