tests: build tests with C90 standard

C90 mode is disabled for:
- testautomation: use of isnan/isfinite
- testlock: use of kill
- testvulkan: use of c++ style strings in vulkan.h
main
Anonymous Maarten 2023-05-25 01:15:12 +02:00 committed by Anonymous Maarten
parent 5b5b67df20
commit b4291412a4
8 changed files with 25 additions and 20 deletions

View File

@ -63,7 +63,7 @@ define_property(TARGET PROPERTY SDL_NONINTERACTIVE_ARGUMENTS BRIEF_DOCS "Argumen
define_property(TARGET PROPERTY SDL_NONINTERACTIVE_TIMEOUT BRIEF_DOCS "Timeout for noninteractive executable." FULL_DOCS "Timeout for noninteractive executable.")
macro(add_sdl_test_executable TARGET)
cmake_parse_arguments(AST "NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS" "" "NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;SOURCES" ${ARGN})
cmake_parse_arguments(AST "NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS;NO_C90" "" "NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;SOURCES" ${ARGN})
if(AST_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown argument(s): ${AST_UNPARSED_ARGUMENTS}")
endif()
@ -82,6 +82,10 @@ macro(add_sdl_test_executable TARGET)
if(AST_TESTUTILS)
target_link_libraries(${TARGET} PRIVATE sdltests_utils)
endif()
if(NOT AST_NO_C90 AND NOT SDL_CMAKE_PLATFORM MATCHES "^(n3ds|ps2|psp)$")
set_property(TARGET ${TARGET} PROPERTY C_STANDARD 90)
set_property(TARGET ${TARGET} PROPERTY C_EXTENSIONS FALSE)
endif()
list(APPEND SDL_TEST_EXECUTABLES ${TARGET})
if(AST_NONINTERACTIVE)
@ -154,7 +158,7 @@ add_sdl_test_executable(testaudioinfo SOURCES testaudioinfo.c)
add_sdl_test_executable(testaudiostreamdynamicresample SOURCES testaudiostreamdynamicresample.c)
file(GLOB TESTAUTOMATION_SOURCE_FILES testautomation*.c)
add_sdl_test_executable(testautomation NEEDS_RESOURCES SOURCES ${TESTAUTOMATION_SOURCE_FILES})
add_sdl_test_executable(testautomation NEEDS_RESOURCES NO_C90 SOURCES ${TESTAUTOMATION_SOURCE_FILES})
add_sdl_test_executable(testmultiaudio NEEDS_RESOURCES TESTUTILS SOURCES testmultiaudio.c)
add_sdl_test_executable(testaudiohotplug NEEDS_RESOURCES TESTUTILS SOURCES testaudiohotplug.c)
add_sdl_test_executable(testaudiocapture SOURCES testaudiocapture.c)
@ -224,7 +228,7 @@ add_sdl_test_executable(testjoystick SOURCES testjoystick.c)
add_sdl_test_executable(testkeys SOURCES testkeys.c)
add_sdl_test_executable(testloadso SOURCES testloadso.c)
add_sdl_test_executable(testlocale NONINTERACTIVE SOURCES testlocale.c)
add_sdl_test_executable(testlock SOURCES testlock.c)
add_sdl_test_executable(testlock NO_C90 SOURCES testlock.c)
add_sdl_test_executable(testrwlock SOURCES testrwlock.c)
add_sdl_test_executable(testmouse SOURCES testmouse.c)
@ -255,7 +259,7 @@ add_sdl_test_executable(testqsort NONINTERACTIVE SOURCES testqsort.c)
add_sdl_test_executable(testbounds NONINTERACTIVE SOURCES testbounds.c)
add_sdl_test_executable(testcustomcursor SOURCES testcustomcursor.c)
add_sdl_test_executable(gamepadmap NEEDS_RESOURCES TESTUTILS SOURCES gamepadmap.c)
add_sdl_test_executable(testvulkan SOURCES testvulkan.c)
add_sdl_test_executable(testvulkan NO_C90 SOURCES testvulkan.c)
add_sdl_test_executable(testoffscreen SOURCES testoffscreen.c)
add_sdl_test_executable(testpopup SOURCES testpopup.c)

View File

@ -174,7 +174,6 @@ static void loop(void)
(void)fprintf(stderr, "starting loop\n");
(void)fflush(stderr);
// while (SDL_PollEvent(&event)) {
while (!done && SDL_WaitEvent(&event)) {
SDL_Log("Got event type: %" SDL_PRIu32 "\n", event.type);
switch (event.type) {

View File

@ -87,19 +87,19 @@ int main(int argc, char *argv[])
}
SDL_SetWindowTitle(window, title);
// this math sucks, but whatever.
/* this math sucks, but whatever. */
if (multiplier < 0) {
newfreq = spec.freq + (int) ((spec.freq * (multiplier / 400.0f)) * 0.75f);
} else if (multiplier > 0) {
newfreq = spec.freq + (int) (spec.freq * (multiplier / 100.0f));
}
//SDL_Log("newfreq=%d multiplier=%d\n", newfreq, multiplier);
/* SDL_Log("newfreq=%d multiplier=%d\n", newfreq, multiplier); */
SDL_LockAudioDevice(device);
SDL_SetAudioStreamFormat(stream, spec.format, spec.channels, newfreq, spec.format, spec.channels, spec.freq);
SDL_UnlockAudioDevice(device);
}
// keep it looping.
/* keep it looping. */
if (SDL_GetAudioStreamAvailable(stream) < (1024 * 100)) {
SDL_PutAudioStreamData(stream, audio_buf, audio_len);
}

View File

@ -758,7 +758,7 @@ int main(int argc, char *argv[])
ctx.glBindTexture(g_texture_type, g_texture);
GL_CHECK(ctx.glClearColor(1, 1, 1, 1));
// SDL_BLENDMODE_BLEND
/* SDL_BLENDMODE_BLEND */
GL_CHECK(ctx.glEnable(GL_BLEND));
ctx.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
ctx.glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);

View File

@ -180,7 +180,7 @@ static void loop(void)
SDL_HideWindow(menus[i].win);
}
}
// Don't process this event in SDLTest_CommonEvent()
/* Don't process this event in SDLTest_CommonEvent() */
continue;
}
}

View File

@ -232,8 +232,8 @@ int main(int argc, char **argv)
rc = 0;
// SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
// SDL_SetHint(SDL_HINT_VIDEO_FORCE_EGL, "0");
/* SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); */
/* SDL_SetHint(SDL_HINT_VIDEO_FORCE_EGL, "0"); */
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

View File

@ -177,8 +177,8 @@ typedef struct VulkanContext
} VulkanContext;
static SDLTest_CommonState *state;
static VulkanContext *vulkanContexts = NULL; // an array of state->num_windows items
static VulkanContext *vulkanContext = NULL; // for the currently-rendering window
static VulkanContext *vulkanContexts = NULL; /* an array of state->num_windows items */
static VulkanContext *vulkanContext = NULL; /* for the currently-rendering window */
static void shutdownVulkan(SDL_bool doDestroySwapchain);

View File

@ -27,12 +27,14 @@ static void RGBtoYUV(const Uint8 *rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, i
yuv[1] = (int)((rgb[2] - yuv[0]) * 0.565 + 128);
yuv[2] = (int)((rgb[0] - yuv[0]) * 0.713 + 128);
} else {
// This formula is from Microsoft's documentation:
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd206750(v=vs.85).aspx
// L = Kr * R + Kb * B + (1 - Kr - Kb) * G
// Y = SDL_floor(2^(M-8) * (219*(L-Z)/S + 16) + 0.5);
// U = clip3(0, (2^M)-1, SDL_floor(2^(M-8) * (112*(B-L) / ((1-Kb)*S) + 128) + 0.5));
// V = clip3(0, (2^M)-1, SDL_floor(2^(M-8) * (112*(R-L) / ((1-Kr)*S) + 128) + 0.5));
/**
* This formula is from Microsoft's documentation:
* https://msdn.microsoft.com/en-us/library/windows/desktop/dd206750(v=vs.85).aspx
* L = Kr * R + Kb * B + (1 - Kr - Kb) * G
* Y = SDL_floor(2^(M-8) * (219*(L-Z)/S + 16) + 0.5);
* U = clip3(0, (2^M)-1, SDL_floor(2^(M-8) * (112*(B-L) / ((1-Kb)*S) + 128) + 0.5));
* V = clip3(0, (2^M)-1, SDL_floor(2^(M-8) * (112*(R-L) / ((1-Kr)*S) + 128) + 0.5));
*/
float S, Z, R, G, B, L, Kr, Kb, Y, U, V;
if (mode == SDL_YUV_CONVERSION_BT709) {