From 430f448ea125a847220a80fbeaba1687d947747b Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 17 Aug 2024 23:10:58 +0200 Subject: [PATCH] testautomation: skip timerTestCallback on Emscripten Timer callbacks on Emscripten require a main event loop --- test/testautomation_timer.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/testautomation_timer.c b/test/testautomation_timer.c index 23d971218..e58e23d25 100644 --- a/test/testautomation_timer.c +++ b/test/testautomation_timer.c @@ -5,6 +5,8 @@ #include #include "testautomation_suites.h" +#ifndef SDL_PLATFORM_EMSCRIPTEN + /* Flag indicating if the param should be checked */ static int g_paramCheck = 0; @@ -14,6 +16,8 @@ static int g_paramValue = 0; /* Flag indicating that the callback was called */ static int g_timerCallbackCalled = 0; +#endif + /* Fixture */ static void timerSetUp(void *arg) @@ -100,6 +104,8 @@ static int timer_delayAndGetTicks(void *arg) return TEST_COMPLETED; } +#ifndef SDL_PLATFORM_EMSCRIPTEN + /* Test callback */ static Uint32 SDLCALL timerTestCallback(void *param, SDL_TimerID timerID, Uint32 interval) { @@ -115,11 +121,17 @@ static Uint32 SDLCALL timerTestCallback(void *param, SDL_TimerID timerID, Uint32 return 0; } +#endif + /** * Call to SDL_AddTimer and SDL_RemoveTimer */ static int timer_addRemoveTimer(void *arg) { +#ifdef SDL_PLATFORM_EMSCRIPTEN + SDLTest_Log("Timer callbacks on Emscripten require a main loop to handle events"); + return TEST_SKIPPED; +#else SDL_TimerID id; int result; int param; @@ -166,25 +178,26 @@ static int timer_addRemoveTimer(void *arg) SDLTest_AssertCheck(g_timerCallbackCalled == 1, "Check callback WAS called, expected: 1, got: %i", g_timerCallbackCalled); return TEST_COMPLETED; +#endif } /* ================= Test References ================== */ /* Timer test cases */ static const SDLTest_TestCaseReference timerTest1 = { - (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED + timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED }; static const SDLTest_TestCaseReference timerTest2 = { - (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED + timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED }; static const SDLTest_TestCaseReference timerTest3 = { - (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED + timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED }; static const SDLTest_TestCaseReference timerTest4 = { - (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED + timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED }; /* Sequence of Timer test cases */