Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions c_pal_ll/interfaces/tests/interlocked_int/interlocked_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
#include "testrunnerswitcher.h"

#include "c_pal/interlocked.h"
#include "c_pal/timed_test_suite.h"

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(a)
TIMED_TEST_SUITE_INITIALIZE(a)
{
}

TEST_SUITE_CLEANUP(b)
TIMED_TEST_SUITE_CLEANUP(b)
{
}

Expand Down Expand Up @@ -1033,4 +1034,4 @@ TEST_FUNCTION(interlocked_xor_8_does_bitwise_xor)
ASSERT_ARE_EQUAL(uint8_t, 0xFF, return_val, "Return value is incorrect");
}

END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(a)
TIMED_TEST_SUITE_INITIALIZE(a)
{
}

TEST_SUITE_CLEANUP(b)
TIMED_TEST_SUITE_CLEANUP(b)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
#include "macro_utils/macro_utils.h" // IWYU pragma: keep

#include "c_pal/interlocked.h"
#include "c_pal/timed_test_suite.h"

#endif // INTERLOCKED_MACROS_UT_PCH_H
#endif // INTERLOCKED_MACROS_UT_PCH_H
7 changes: 4 additions & 3 deletions c_pal_ll/interfaces/tests/sync_int/sync_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "c_pal/threadapi.h"
#include "c_pal/sync.h"
#include "c_pal/timer.h"
#include "c_pal/timed_test_suite.h"

TEST_DEFINE_ENUM_TYPE(THREADAPI_RESULT, THREADAPI_RESULT_VALUES)
TEST_DEFINE_ENUM_TYPE(WAIT_ON_ADDRESS_RESULT, WAIT_ON_ADDRESS_RESULT_VALUES);
Expand Down Expand Up @@ -123,12 +124,12 @@ static int increment_on_wake_up_64(void* address)

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(a)
TIMED_TEST_SUITE_INITIALIZE(a)
{
ASSERT_ARE_EQUAL(int, 0, gballoc_hl_init(NULL, NULL));
}

TEST_SUITE_CLEANUP(b)
TIMED_TEST_SUITE_CLEANUP(b)
{
gballoc_hl_deinit();
}
Expand Down Expand Up @@ -351,4 +352,4 @@ TEST_FUNCTION(wait_on_address_64_returns_after_timeout_elapses)
ASSERT_ARE_EQUAL(WAIT_ON_ADDRESS_RESULT, WAIT_ON_ADDRESS_TIMEOUT, return_val, "wait_on_address_64 should have returned timeout");
}

END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static bool hook_mock_atomic_compare_exchange_pointer(void* volatile_atomic* obj

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(suite_init)
TIMED_TEST_SUITE_INITIALIZE(suite_init)
{
ASSERT_ARE_EQUAL(int, 0, umock_c_init(on_umock_c_error));
ASSERT_ARE_EQUAL(int, 0, umocktypes_stdint_register_types());
Expand All @@ -55,7 +55,7 @@ TEST_SUITE_INITIALIZE(suite_init)
REGISTER_GLOBAL_MOCK_HOOK(mock_atomic_compare_exchange_pointer, hook_mock_atomic_compare_exchange_pointer);
}

TEST_SUITE_CLEANUP(TestClassCleanup)
TIMED_TEST_SUITE_CLEANUP(TestClassCleanup)
{
umock_c_deinit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
#include "umock_c/umocktypes_stdint.h"

#include "c_pal/interlocked.h"
#include "c_pal/timed_test_suite.h"

#endif // INTERLOCKED_LINUX_UT_PCH_H
#endif // INTERLOCKED_LINUX_UT_PCH_H
4 changes: 2 additions & 2 deletions c_pal_ll/linux/tests/sync_linux_ut/sync_linux_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ IMPLEMENT_UMOCK_C_ENUM_TYPE(WAIT_ON_ADDRESS_RESULT, WAIT_ON_ADDRESS_RESULT_VALUE

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(suite_init)
TIMED_TEST_SUITE_INITIALIZE(suite_init)
{
ASSERT_ARE_EQUAL(int, 0, umock_c_init(on_umock_c_error));
REGISTER_GLOBAL_MOCK_HOOK(mock_syscall, hook_mock_syscall)
}

TEST_SUITE_CLEANUP(TestClassCleanup)
TIMED_TEST_SUITE_CLEANUP(TestClassCleanup)
{
umock_c_deinit();
}
Expand Down
3 changes: 2 additions & 1 deletion c_pal_ll/linux/tests/sync_linux_ut/sync_linux_ut_pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

#include "c_pal/interlocked.h"
#include "c_pal/sync.h"
#include "c_pal/timed_test_suite.h"

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

#endif // SYNC_LINUX_UT_PCH_H
#endif // SYNC_LINUX_UT_PCH_H
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ static void on_umock_c_error(UMOCK_C_ERROR_CODE error_code)

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(suite_init)
TIMED_TEST_SUITE_INITIALIZE(suite_init)
{
ASSERT_ARE_EQUAL(int, 0, umock_c_init(on_umock_c_error));
ASSERT_ARE_EQUAL(int, 0, umocktypes_windows_register_types());
REGISTER_UMOCK_ALIAS_TYPE(SHORT, int16_t);
}

TEST_SUITE_CLEANUP(TestClassCleanup)
TIMED_TEST_SUITE_CLEANUP(TestClassCleanup)
{
umock_c_deinit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
#include "umock_c/umocktypes_windows.h"

#include "c_pal/interlocked.h"
#include "c_pal/timed_test_suite.h"

#endif // INTERLOCKED_WIN32_UT_PCH_H
#endif // INTERLOCKED_WIN32_UT_PCH_H
4 changes: 2 additions & 2 deletions c_pal_ll/win32/tests/sync_win32_ut/sync_win32_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ IMPLEMENT_UMOCK_C_ENUM_TYPE(WAIT_ON_ADDRESS_RESULT, WAIT_ON_ADDRESS_RESULT_VALUE

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(suite_init)
TIMED_TEST_SUITE_INITIALIZE(suite_init)
{
ASSERT_ARE_EQUAL(int, 0, real_gballoc_hl_init(NULL, NULL));

Expand All @@ -29,7 +29,7 @@ TEST_SUITE_INITIALIZE(suite_init)
REGISTER_UMOCK_ALIAS_TYPE(SIZE_T, size_t);
}

TEST_SUITE_CLEANUP(TestClassCleanup)
TIMED_TEST_SUITE_CLEANUP(TestClassCleanup)
{
umock_c_deinit();

Expand Down
4 changes: 3 additions & 1 deletion c_pal_ll/win32/tests/sync_win32_ut/sync_win32_ut_pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "umock_c/umock_c.h"
#include "umock_c/umocktypes_windows.h"

#include "c_pal/timed_test_suite.h"

#include "umock_c/umock_c_ENABLE_MOCKS.h" // ============================== ENABLE_MOCKS
#include "c_pal/gballoc_hl.h"
#include "c_pal/gballoc_hl_redirect.h"
Expand All @@ -26,4 +28,4 @@

#include "c_pal/sync.h"

#endif // SYNC_WIN32_UT_PCH_H
#endif // SYNC_WIN32_UT_PCH_H
9 changes: 7 additions & 2 deletions common/inc/c_pal/timed_test_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#ifndef TIMED_TEST_SUITE_H
#define TIMED_TEST_SUITE_H

// Enable TEST_SUITE_INITIALIZE_INTERNAL/CLEANUP_INTERNAL for use by TIMED_ macros
#define DEFINE_TEST_SUITE_INITIALIZE
#define DEFINE_TEST_SUITE_CLEANUP
#include "testrunnerswitcher.h"

#include "c_pal/process_watchdog.h"

// Default timeout: 10 minutes
Expand All @@ -16,7 +20,7 @@
/*Codes_SRS_TIMED_TEST_SUITE_43_004: [ The watchdog init fixture shall execute before the user's initialization code. ]*/
#define TIMED_TEST_SUITE_INITIALIZE(name, timeout_ms, ...) \
static void MU_C2(timed_test_watchdog_init_, name)(void) { ASSERT_ARE_EQUAL(int, 0, process_watchdog_init(timeout_ms), "process_watchdog_init failed"); } \
TEST_SUITE_INITIALIZE(name, MU_C2(timed_test_watchdog_init_, name), ##__VA_ARGS__)
TEST_SUITE_INITIALIZE_INTERNAL(name, MU_C2(timed_test_watchdog_init_, name), ##__VA_ARGS__)

// Cleanup - stops the watchdog after user cleanup code runs
// Watchdog deinit fixture runs AFTER user cleanup code (last in fixture list)
Expand All @@ -25,6 +29,7 @@
/*Codes_SRS_TIMED_TEST_SUITE_43_007: [ The watchdog deinit fixture shall execute after the user's cleanup code. ]*/
#define TIMED_TEST_SUITE_CLEANUP(name, ...) \
static void MU_C2(timed_test_watchdog_deinit_, name)(void) { process_watchdog_deinit(); } \
TEST_SUITE_CLEANUP(name, ##__VA_ARGS__, MU_C2(timed_test_watchdog_deinit_, name))
TEST_SUITE_CLEANUP_INTERNAL(name, ##__VA_ARGS__, MU_C2(timed_test_watchdog_deinit_, name))


#endif // TIMED_TEST_SUITE_H
7 changes: 4 additions & 3 deletions common/tests/arithmetic_int/arithmetic_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
#include "testrunnerswitcher.h"

#include "c_pal/arithmetic.h"
#include "c_pal/timed_test_suite.h"

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(TestClassInitialize)
TIMED_TEST_SUITE_INITIALIZE(TestClassInitialize, TIMED_TEST_DEFAULT_TIMEOUT_MS)
{
}

TEST_SUITE_CLEANUP(TestClassCleanup)
TIMED_TEST_SUITE_CLEANUP(TestClassCleanup)
{
}

Expand Down Expand Up @@ -1098,4 +1099,4 @@ printf("{.left = %" ALIGN PRIu64 "ULL, .right = %" ALIGN PRIu64 "ULL, .high = %
}
*/

END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
7 changes: 4 additions & 3 deletions common/tests/call_once_int/call_once_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "c_pal/threadapi.h"

#include "c_pal/call_once.h"
#include "c_pal/timed_test_suite.h"

TEST_DEFINE_ENUM_TYPE(THREADAPI_RESULT, THREADAPI_RESULT_VALUES)

Expand Down Expand Up @@ -79,11 +80,11 @@ static int chaosThread(

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(suite_init)
TIMED_TEST_SUITE_INITIALIZE(suite_init, TIMED_TEST_DEFAULT_TIMEOUT_MS)
{
}

TEST_SUITE_CLEANUP(suite_cleanup)
TIMED_TEST_SUITE_CLEANUP(suite_cleanup)
{
}

Expand Down Expand Up @@ -151,4 +152,4 @@ TEST_FUNCTION(call_once_chaos_knight)
}


END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
4 changes: 2 additions & 2 deletions common/tests/call_once_ut/call_once_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static call_once_t g_state = CALL_ONCE_NOT_CALLED;

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(suite_init)
TIMED_TEST_SUITE_INITIALIZE(suite_init, TIMED_TEST_DEFAULT_TIMEOUT_MS)
{
ASSERT_ARE_EQUAL(int, 0, umock_c_init(on_umock_c_error), "umock_c_init");
ASSERT_ARE_EQUAL(int, 0, umocktypes_stdint_register_types());
Expand All @@ -29,7 +29,7 @@ TEST_SUITE_INITIALIZE(suite_init)
REGISTER_SYNC_GLOBAL_MOCK_HOOK();
}

TEST_SUITE_CLEANUP(suite_cleanup)
TIMED_TEST_SUITE_CLEANUP(suite_cleanup)
{
umock_c_deinit();
}
Expand Down
4 changes: 3 additions & 1 deletion common/tests/call_once_ut/call_once_ut_pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "umock_c/umocktypes.h"
#include "umock_c/umocktypes_stdint.h"

#include "c_pal/timed_test_suite.h"

#include "umock_c/umock_c_ENABLE_MOCKS.h" // ============================== ENABLE_MOCKS
#include "c_pal/interlocked.h"
#include "c_pal/sync.h"
Expand All @@ -26,4 +28,4 @@
#include "real_sync.h"
#include "c_pal/call_once.h"

#endif // CALL_ONCE_UT_PCH_H
#endif // CALL_ONCE_UT_PCH_H
4 changes: 2 additions & 2 deletions common/tests/interlocked_hl_ut/interlocked_hl_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ IMPLEMENT_UMOCK_C_ENUM_TYPE(WAIT_ON_ADDRESS_RESULT, WAIT_ON_ADDRESS_RESULT_VALUE
BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)


TEST_SUITE_INITIALIZE(a)
TIMED_TEST_SUITE_INITIALIZE(a, TIMED_TEST_DEFAULT_TIMEOUT_MS)
{
ASSERT_ARE_EQUAL(int, 0, umock_c_init(on_umock_c_error));
ASSERT_ARE_EQUAL(int, 0, umocktypes_stdint_register_types());
Expand All @@ -86,7 +86,7 @@ TEST_SUITE_INITIALIZE(a)
REGISTER_GLOBAL_MOCK_HOOK(wait_on_address_64, hook_wait_on_address_64);
}

TEST_SUITE_CLEANUP(b)
TIMED_TEST_SUITE_CLEANUP(b)
{
umock_c_deinit();
}
Expand Down
4 changes: 3 additions & 1 deletion common/tests/interlocked_hl_ut/interlocked_hl_ut_pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "umock_c/umocktypes_stdint.h"
#include "umock_c/umocktypes_bool.h"

#include "c_pal/timed_test_suite.h"

#include "umock_c/umock_c_ENABLE_MOCKS.h" // ============================== ENABLE_MOCKS
#include "c_pal/interlocked.h"
#include "c_pal/sync.h"
Expand All @@ -29,4 +31,4 @@
#include "real_gballoc_hl.h"
#include "c_pal/interlocked_hl.h"

#endif // INTERLOCKED_HL_UT_PCH_H
#endif // INTERLOCKED_HL_UT_PCH_H
9 changes: 5 additions & 4 deletions common/tests/lazy_init_int/lazy_init_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "c_pal/gballoc_hl.h" // IWYU pragma: keep
#include "c_pal/gballoc_hl_redirect.h" // IWYU pragma: keep
#include "c_pal/timed_test_suite.h"

TEST_DEFINE_ENUM_TYPE(LAZY_INIT_RESULT, LAZY_INIT_RESULT_VALUES);
TEST_DEFINE_ENUM_TYPE(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
Expand Down Expand Up @@ -91,12 +92,12 @@ static int chaosThread(

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(suite_init)
TIMED_TEST_SUITE_INITIALIZE(suite_init, TIMED_TEST_DEFAULT_TIMEOUT_MS)
{
nThreadsForChaos = sysinfo_get_processor_count();
}

TEST_SUITE_CLEANUP(suite_cleanup)
TIMED_TEST_SUITE_CLEANUP(suite_cleanup)
{
}

Expand Down Expand Up @@ -139,10 +140,10 @@ TEST_FUNCTION(lazy_init_chaos_knight)
}

///assert - all done in the threads themselves

///clean
free(threads);
}


END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
4 changes: 2 additions & 2 deletions common/tests/lazy_init_ut/lazy_init_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IMPLEMENT_UMOCK_C_ENUM_TYPE(CALL_ONCE_RESULT, CALL_ONCE_RESULT_VALUES);

BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)

TEST_SUITE_INITIALIZE(suite_init)
TIMED_TEST_SUITE_INITIALIZE(suite_init, TIMED_TEST_DEFAULT_TIMEOUT_MS)
{
ASSERT_ARE_EQUAL(int, 0, umock_c_init(on_umock_c_error), "umock_c_init");
ASSERT_ARE_EQUAL(int, 0, umocktypes_stdint_register_types());
Expand All @@ -37,7 +37,7 @@ TEST_SUITE_INITIALIZE(suite_init)

}

TEST_SUITE_CLEANUP(suite_cleanup)
TIMED_TEST_SUITE_CLEANUP(suite_cleanup)
{
umock_c_deinit();
}
Expand Down
Loading
Loading