From 4a6528e3f0091f44142f3e4cd7fe14eb7660735a Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 17 Mar 2023 00:25:39 +0100
Subject: [PATCH] testprograms: parse arguments using SDLTest_CommonState
---
VisualC/tests/gamepadmap/gamepadmap.vcxproj | 6 +
VisualC/tests/loopwave/loopwave.vcxproj | 6 +
VisualC/tests/testatomic/testatomic.vcxproj | 6 +
VisualC/tests/testfile/testfile.vcxproj | 6 +
VisualC/tests/testgamepad/testgamepad.vcxproj | 6 +
.../tests/testjoystick/testjoystick.vcxproj | 6 +
.../tests/testplatform/testplatform.vcxproj | 6 +
VisualC/tests/testpower/testpower.vcxproj | 6 +
VisualC/tests/testrumble/testrumble.vcxproj | 6 +
VisualC/tests/testsensor/testsensor.vcxproj | 6 +
VisualC/tests/testshape/testshape.vcxproj | 6 +
.../tests/testsurround/testsurround.vcxproj | 6 +
VisualC/tests/testyuv/testyuv.vcxproj | 1 +
test/CMakeLists.txt | 58 +++---
test/checkkeys.c | 16 +-
test/checkkeysthreads.c | 14 ++
test/gamepadmap.c | 34 +++-
test/loopwave.c | 31 +++-
test/loopwavequeue.c | 34 +++-
test/testatomic.c | 15 ++
test/testaudiocapture.c | 44 ++++-
test/testaudiohotplug.c | 42 ++++-
test/testaudioinfo.c | 16 +-
test/testbounds.c | 14 ++
test/testdisplayinfo.c | 14 ++
test/testdrawchessboard.c | 15 ++
test/testdropfile.c | 6 +-
test/testerror.c | 14 ++
test/testevdev.c | 20 +-
test/testfile.c | 16 ++
test/testfilesystem.c | 14 ++
test/testgamepad.c | 74 +++++---
test/testgeometry.c | 7 +-
test/testgl.c | 9 +-
test/testgles.c | 16 +-
test/testgles2.c | 9 +-
test/testgles2_sdf.c | 9 +-
test/testhaptic.c | 53 ++++--
test/testhotplug.c | 32 +++-
test/testiconv.c | 33 +++-
test/testime.c | 47 +++--
test/testjoystick.c | 28 ++-
test/testkeys.c | 14 ++
test/testloadso.c | 63 +++++--
test/testlocale.c | 75 ++++++--
test/testmessage.c | 14 ++
test/testmouse.c | 48 +++--
test/testmultiaudio.c | 46 ++++-
test/testnative.c | 14 ++
test/testnative.h | 8 +
test/testoffscreen.c | 14 ++
test/testplatform.c | 32 +++-
test/testpopup.c | 8 +
test/testpower.c | 18 +-
test/testqsort.c | 62 +++++--
test/testrelative.c | 7 +-
test/testrendercopyex.c | 6 +-
test/testresample.c | 74 +++++++-
test/testrumble.c | 53 ++++--
test/testscale.c | 14 +-
test/testsem.c | 42 ++++-
test/testsensor.c | 18 ++
test/testshader.c | 38 +++-
test/testshape.c | 175 ++++++++++--------
test/teststreaming.c | 14 ++
test/testsurround.c | 13 ++
test/testtimer.c | 42 ++++-
test/testvulkan.c | 6 +-
test/testwm.c | 10 +-
test/testyuv.c | 152 +++++++++------
test/torturethread.c | 14 ++
71 files changed, 1514 insertions(+), 387 deletions(-)
diff --git a/VisualC/tests/gamepadmap/gamepadmap.vcxproj b/VisualC/tests/gamepadmap/gamepadmap.vcxproj
index a5c0ee7f568f..2f3ee2bb7237 100644
--- a/VisualC/tests/gamepadmap/gamepadmap.vcxproj
+++ b/VisualC/tests/gamepadmap/gamepadmap.vcxproj
@@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\..\test\axis.bmp">
diff --git a/VisualC/tests/loopwave/loopwave.vcxproj b/VisualC/tests/loopwave/loopwave.vcxproj
index 197f77942ecf..d755abe9f183 100644
--- a/VisualC/tests/loopwave/loopwave.vcxproj
+++ b/VisualC/tests/loopwave/loopwave.vcxproj
@@ -194,6 +194,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\Test\loopwave.c" />
diff --git a/VisualC/tests/testatomic/testatomic.vcxproj b/VisualC/tests/testatomic/testatomic.vcxproj
index 2347709c3ee2..d8b7bf9a5b74 100644
--- a/VisualC/tests/testatomic/testatomic.vcxproj
+++ b/VisualC/tests/testatomic/testatomic.vcxproj
@@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\test\testatomic.c" />
diff --git a/VisualC/tests/testfile/testfile.vcxproj b/VisualC/tests/testfile/testfile.vcxproj
index b4d94ca47389..f0e138eede12 100644
--- a/VisualC/tests/testfile/testfile.vcxproj
+++ b/VisualC/tests/testfile/testfile.vcxproj
@@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\Test\testfile.c" />
diff --git a/VisualC/tests/testgamepad/testgamepad.vcxproj b/VisualC/tests/testgamepad/testgamepad.vcxproj
index cd5fecfbb38e..add2fd53069f 100644
--- a/VisualC/tests/testgamepad/testgamepad.vcxproj
+++ b/VisualC/tests/testgamepad/testgamepad.vcxproj
@@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\..\test\axis.bmp">
diff --git a/VisualC/tests/testjoystick/testjoystick.vcxproj b/VisualC/tests/testjoystick/testjoystick.vcxproj
index e1b1e4fc09f9..d35450f42d22 100644
--- a/VisualC/tests/testjoystick/testjoystick.vcxproj
+++ b/VisualC/tests/testjoystick/testjoystick.vcxproj
@@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\test\testjoystick.c" />
diff --git a/VisualC/tests/testplatform/testplatform.vcxproj b/VisualC/tests/testplatform/testplatform.vcxproj
index 0c66384ba798..b88aa4f7b962 100644
--- a/VisualC/tests/testplatform/testplatform.vcxproj
+++ b/VisualC/tests/testplatform/testplatform.vcxproj
@@ -216,6 +216,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\Test\testplatform.c" />
diff --git a/VisualC/tests/testpower/testpower.vcxproj b/VisualC/tests/testpower/testpower.vcxproj
index 7ffadf346da6..308555f5324f 100644
--- a/VisualC/tests/testpower/testpower.vcxproj
+++ b/VisualC/tests/testpower/testpower.vcxproj
@@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\test\testpower.c" />
diff --git a/VisualC/tests/testrumble/testrumble.vcxproj b/VisualC/tests/testrumble/testrumble.vcxproj
index 4214849ccec1..6fab2f944e3e 100644
--- a/VisualC/tests/testrumble/testrumble.vcxproj
+++ b/VisualC/tests/testrumble/testrumble.vcxproj
@@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\test\testrumble.c" />
diff --git a/VisualC/tests/testsensor/testsensor.vcxproj b/VisualC/tests/testsensor/testsensor.vcxproj
index cbfa28774b4c..cf480e586291 100644
--- a/VisualC/tests/testsensor/testsensor.vcxproj
+++ b/VisualC/tests/testsensor/testsensor.vcxproj
@@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\test\testsensor.c" />
diff --git a/VisualC/tests/testshape/testshape.vcxproj b/VisualC/tests/testshape/testshape.vcxproj
index 70f7a95f8dd9..1c59aa430e90 100644
--- a/VisualC/tests/testshape/testshape.vcxproj
+++ b/VisualC/tests/testshape/testshape.vcxproj
@@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\test\testshape.c" />
diff --git a/VisualC/tests/testsurround/testsurround.vcxproj b/VisualC/tests/testsurround/testsurround.vcxproj
index f0de9842a568..47c5cff3e7f8 100644
--- a/VisualC/tests/testsurround/testsurround.vcxproj
+++ b/VisualC/tests/testsurround/testsurround.vcxproj
@@ -194,6 +194,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\Test\testsurround.c" />
diff --git a/VisualC/tests/testyuv/testyuv.vcxproj b/VisualC/tests/testyuv/testyuv.vcxproj
index 22a6ab37e8e5..9df29c3d5804 100644
--- a/VisualC/tests/testyuv/testyuv.vcxproj
+++ b/VisualC/tests/testyuv/testyuv.vcxproj
@@ -218,6 +218,7 @@
<ItemGroup>
<ClCompile Include="..\..\..\test\testyuv.c" />
<ClCompile Include="..\..\..\test\testyuv_cvt.c" />
+ <ClCompile Include="..\..\..\test\testutils.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\test\testyuv_cvt.h" />
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 23a25ecb1171..03ad9bee52dc 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -136,9 +136,39 @@ add_sdl_test_executable(testdropfile testdropfile.c)
add_sdl_test_executable(testerror NONINTERACTIVE testerror.c)
if(LINUX AND TARGET sdl-build-options)
+ set(build_options_dependent_tests )
+
add_sdl_test_executable(testevdev NONINTERACTIVE testevdev.c)
- target_include_directories(testevdev BEFORE PRIVATE $<TARGET_PROPERTY:sdl-build-options,INTERFACE_INCLUDE_DIRECTORIES>)
- target_include_directories(testevdev BEFORE PRIVATE ${SDL3_SOURCE_DIR}/src)
+ list(APPEND build_options_dependent_tests testevdev)
+
+ if(APPLE)
+ add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS
+ testnative.c
+ testnativecocoa.m
+ testnativex11.c
+ )
+ target_compile_definitions(testnative PRIVATE TEST_NATIVE_COCOA)
+
+ cmake_push_check_state()
+ check_c_compiler_flag(-Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
+ cmake_pop_check_state()
+ if(HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
+ set_property(SOURCE "testnativecocoa.m" APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-error=deprecated-declarations")
+ endif()
+ list(APPEND build_options_dependent_tests testnative)
+ elseif(WINDOWS)
+ add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS testnative.c testnativew32.c)
+ list(APPEND build_options_dependent_tests testnative)
+ elseif(HAVE_X11)
+ add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS testnative.c testnativex11.c)
+ target_link_libraries(testnative PRIVATE X11)
+ list(APPEND build_options_dependent_tests testnative)
+ endif()
+
+ foreach(t ${build_options_dependent_tests})
+ target_include_directories(${t} BEFORE PRIVATE $<TARGET_PROPERTY:sdl-build-options,INTERFACE_INCLUDE_DIRECTORIES>)
+ target_include_directories(${t} BEFORE PRIVATE ${SDL3_SOURCE_DIR}/src)
+ endforeach()
endif()
add_sdl_test_executable(testfile testfile.c)
@@ -161,26 +191,6 @@ add_sdl_test_executable(testlocale NONINTERACTIVE testlocale.c)
add_sdl_test_executable(testlock testlock.c)
add_sdl_test_executable(testmouse testmouse.c)
-if(APPLE)
- add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS
- testnative.c
- testnativecocoa.m
- testnativex11.c
- )
-
- cmake_push_check_state()
- check_c_compiler_flag(-Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
- cmake_pop_check_state()
- if(HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
- set_property(SOURCE "testnativecocoa.m" APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-error=deprecated-declarations")
- endif()
-elseif(WINDOWS)
- add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS testnative.c testnativew32.c)
-elseif(HAVE_X11)
- add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS testnative.c testnativex11.c)
- target_link_libraries(testnative PRIVATE X11)
-endif()
-
add_sdl_test_executable(testoverlay NEEDS_RESOURCES TESTUTILS testoverlay.c)
add_sdl_test_executable(testplatform NONINTERACTIVE testplatform.c)
add_sdl_test_executable(testpower NONINTERACTIVE testpower.c)
@@ -189,7 +199,7 @@ add_sdl_test_executable(testrendertarget NEEDS_RESOURCES TESTUTILS testrendertar
add_sdl_test_executable(testscale NEEDS_RESOURCES TESTUTILS testscale.c)
add_sdl_test_executable(testsem testsem.c)
add_sdl_test_executable(testsensor testsensor.c)
-add_sdl_test_executable(testshader NEEDS_RESOURCES testshader.c)
+add_sdl_test_executable(testshader NEEDS_RESOURCES TESTUTILS testshader.c)
add_sdl_test_executable(testshape NEEDS_RESOURCES testshape.c)
add_sdl_test_executable(testsprite NEEDS_RESOURCES TESTUTILS testsprite.c)
add_sdl_test_executable(testspriteminimal NEEDS_RESOURCES TESTUTILS testspriteminimal.c)
@@ -199,7 +209,7 @@ add_sdl_test_executable(testurl testurl.c)
add_sdl_test_executable(testver NONINTERACTIVE testver.c)
add_sdl_test_executable(testviewport NEEDS_RESOURCES TESTUTILS testviewport.c)
add_sdl_test_executable(testwm testwm.c)
-add_sdl_test_executable(testyuv NEEDS_RESOURCES testyuv.c testyuv_cvt.c)
+add_sdl_test_executable(testyuv NEEDS_RESOURCES TESTUTILS testyuv.c testyuv_cvt.c)
add_sdl_test_executable(torturethread torturethread.c)
add_sdl_test_executable(testrendercopyex NEEDS_RESOURCES TESTUTILS testrendercopyex.c)
add_sdl_test_executable(testmessage testmessage.c)
diff --git a/test/checkkeys.c b/test/checkkeys.c
index b9cb97f10091..dccd67291e5a 100644
--- a/test/checkkeys.c
+++ b/test/checkkeys.c
@@ -23,7 +23,7 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
-#include <SDL3/SDL_test_font.h>
+#include <SDL3/SDL_test.h>
static SDL_Window *window;
static SDL_Renderer *renderer;
@@ -249,9 +249,22 @@ static void loop(void)
int main(int argc, char *argv[])
{
+ SDLTest_CommonState *state;
+
+ /* Initialize test framework */
+ state = SDLTest_CommonCreateState(argv, 0);
+ if (state == NULL) {
+ return 1;
+ }
+
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+ /* Parse commandline */
+ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
+ return 1;
+ }
+
/* Disable mouse emulation */
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
@@ -304,5 +317,6 @@ int main(int argc, char *argv[])
#endif
SDL_Quit();
+ SDLTest_CommonDestroyState(state);
return 0;
}
diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c
index 0a8cb7947f72..8a058a0a5f7d 100644
--- a/test/checkkeysthreads.c
+++ b/test/checkkeysthreads.c
@@ -24,6 +24,7 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
+#include <SDL3/SDL_test.h>
static int done;
@@ -240,10 +241,22 @@ int main(int argc, char *argv[])
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Thread *thread;
+ SDLTest_CommonState *state;
+
+ /* Initialize test framework */
+ state = SDLTest_CommonCreateState(argv, 0);
+ if (state == NULL) {
+ return 1;
+ }
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+ /* Parse commandline */
+ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
+ return 1;
+ }
+
/* Initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
@@ -290,5 +303,6 @@ int main(int argc, char *argv[])
SDL_WaitThread(thread, NULL);
SDL_Quit();
+ SDLTest_CommonDestroyState(state);
return 0;
}
diff --git a/test/gamepadmap.c b/test/gamepadmap.c
index 51f98c0e69e1..c33e4da2884d 100644
--- a/test/gamepadmap.c
+++ b/test/gamepadmap.c
@@ -18,6 +18,7 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
+#include <SDL3/SDL_test.h>
#include "testutils.h"
/* Define this for verbose output while mapping gamepads */
@@ -729,22 +730,45 @@ int main(int argc, char *argv[])
SDL_JoystickID *joysticks;
int joystick_index;
SDL_Joystick *joystick = NULL;
+ SDLTest_CommonState *state;
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
+ /* Initialize test framework */
+ state = SDLTest_CommonCreateState(argv, 0);
+ if (state == NULL) {
+ return 1;
+ }
+
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+ /* Parse commandline */
+ for (i = 1; i < argc;) {
+ int consumed;
+
+ consumed = SDLTest_CommonArg(state, i);
+ if (!consumed) {
+ if (SDL_strcmp(argv[i], "--bind-touchpad") == 0) {
+ bind_touchpad = SDL_TRUE;
+ consumed = 1;
+ }
+ }
+ if (consumed <= 0) {
+ static const char *options[] = { "[--bind-touchpad]", NULL };
+ SDLTest_CommonLogUsage(state, argv[0], options);
+ exit(1);
+ }
+
+ i += consumed;
+ }
+
/* Initialize SDL (Note: video is required to start event loop) */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
- if (argv[1] && SDL_strcmp(argv[1], "--bind-touchpad") == 0) {
- bind_touchpad = SDL_TRUE;
- }
-
/* Create a window to display joystick axis position */
window = SDL_CreateWindow("Game Controller Map", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
if (window == NULL) {
@@ -830,5 +854,7 @@ int main(int argc, char *argv[])
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
+ SDLTest_CommonDestroyState(state);
+
return 0;
}
diff --git a/test/loopwave.c b/test/loopwave.c
index f4182fadb23e..7ebb01477d67 100644
--- a/test/loopwave.c
+++ b/test/loopwave.c
@@ -23,6 +23,7 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
+#include <SDL3/SDL_test.h>
#include "testutils.h"
static struct
@@ -113,17 +114,44 @@ int main(int argc, char *argv[])
{
int i;
char *filename = NULL;
+ SDLTest_CommonState *state;
+
+ /* Initialize test framework */
+ state = SDLTest_CommonCreateState(argv, 0);
+ if (state == NULL) {
+ return 1;
+ }
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+ /* Parse commandline */
+ for (i = 1; i < argc;) {
+ int consumed;
+
+ consumed = SDLTest_CommonArg(state, i);
+ if (!consumed) {
+ if (!filename) {
+ filename = argv[i];
+ consumed = 1;
+ }
+ }
+ if (consumed <= 0) {
+ static const char *options[] = { "[sample.wav]", NULL };
+ SDLTest_CommonLogUsage(state, argv[0], options);
+ exit(1);
+ }
+
+ i += consumed;
+ }
+
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_EVENTS) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
- filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
+ filename = GetResourceFilename(filename, "sample.wav");
if (filename == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
@@ -174,5 +202,6 @@ int main(int argc, char *argv[])
SDL_free(wave.sound);
SDL_free(filename);
SDL_Quit();
+ SDLTest_CommonDestroyState(state);
return 0;
}
diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c
index 0ecf5d29691d..d7c3f98ed7e9 100644
--- a/test/loopwavequeue.c
+++ b/test/loopwavequeue.c
@@ -20,6 +20,7 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
+#include <SDL3/SDL_test.h>
#if HAVE_SIGNAL_H
#include <signal.h>
@@ -73,18 +74,46 @@ static void loop(void)
int main(int argc, char *argv[])
{
+ int i;
char *filename = NULL;
+ SDLTest_CommonState *state;
+
+ /* Initialize test framework */
+ state = SDLTest_CommonCreateState(argv, 0);
+ if (state == NULL) {
+ return 1;
+ }
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+ /* Parse commandline */
+ for (i = 1; i < argc;) {
+ int consumed;
+
+ consumed = SDLTest_CommonArg(state, i);
+ if (!consumed) {
+ if (!filename) {
+ filename = argv[i];
+ consumed = 1;
+ }
+ }
+ if (consumed <= 0) {
+ static const char *options[] = { "[sample.wav]", NULL };
+ SDLTest_CommonLogUsage(state, argv[0], options);
+ exit(1);
+ }
+
+ i += consumed;
+ }
+
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
- filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
+ filename = GetResourceFilename(filename, "sample.wav");
if (filename == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
@@ -137,7 +166,7 @@ int main(int argc, char *argv[])
while (!done && (SDL_GetAudioDeviceStatus(g_audio_id) == SDL_AUDIO_PLAYING)) {
loop();
- SDL_Delay(100); /* let it play for awhile. */
+ SDL_Delay(100); /* let it play for a while. */
}
#endif
@@ -146,5 +175,6 @@ int main(int argc, char *argv[])
SDL_free(wave.sound);
SDL_free(filename);
SDL_Quit();
+ SDLTest_CommonDestroyState(state);
return 0;
}
diff --git a/test/testatomic.c b/test/testatomic.c
index 53feb9796ca4..891f1ac4572c 100644
--- a/test/testatomic.c
+++ b/test/testatomic.c
@@ -12,6 +12,7 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
+#include <SDL3/SDL_test.h>
/*
Absolutely basic tests just to see if we get the expected value
@@ -695,9 +696,22 @@ static void RunFIFOTest(SDL_bool lock_free)
int main(int argc, char *argv[])
{
+ SDLTest_CommonState *state;
+
+ /* Initialize test framework */
+ state = SDLTest_CommonCreateState(argv, 0);
+ if (state == NULL) {
+ return 1;
+ }
+
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+ /* Parse commandline */
+ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
+ return 1;
+ }
+
RunBasicTest();
if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
@@ -711,5 +725,6 @@ int main(int argc, char *argv[])
RunFIFOTest(SDL_FALSE);
#endif
RunFIFOTest(SDL_TRUE);
+ SDLTest_CommonDestroyState(state);
return 0;
}
diff --git a/test/testaudiocapture.c b/test/testaudiocapture.c
index 156b379403fa..f251defc50dd 100644
--- a/test/testaudiocapture.c
+++ b/test/testaudiocapture.c
@@ -14,6 +14,7 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
+#include <SDL3/SDL_test.h>
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
@@ -89,23 +90,52 @@ static void loop(void)
int main(int argc, char **argv)
{
- /* (argv[1] == NULL means "open default device.") */
- const char *devname = argv[1];
+ /* (NULL means "open default device.") */
+ const char *devname = NULL;
SDL_AudioSpec wanted;
int devcount;
int i;
+ SDLTest_CommonState *state;
+
+ /* Initialize test framework */
+ state = SDLTest_CommonCreateState(argv, 0);
+ if (state == NULL) {
+ return 1;
+ }
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+ /* Parse commandline */
+ for (i = 1; i < argc;) {
+ int consumed;
+
+ consumed = SDLTest_CommonArg(state, i);
+ if (!consumed) {
+ if (!devname) {
+ devname = argv[i];
+ consumed = 1;
+ }
+ }
+ if (consumed <= 0) {
+ static const char *options[] = { "[driver_name]", NULL };
+ SDLTest_CommonLogUsage(state, argv[0], options);
+ exit(1);
+ }
+
+ i += consumed;
+ }
+
/* Load the SDL library */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
- window = SDL_CreateWindow("testaudiocapture", 320, 240, 0);
- renderer = SDL_CreateRenderer(window, NULL, 0);
+ if (SDL_CreateWindowAndRenderer(320, 240, 0, &window, &renderer) < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window and renderer: %s\n", SDL_GetError());
+ return 1;
+ }
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
@@ -145,7 +175,7 @@ int main(int argc, char **argv)
devname ? devname : "[[default]]",
devname ? "'" : "");
- devid_in = SDL_OpenAudioDevice(argv[1], SDL_TRUE, &spec, &spec, 0);
+ devid_in = SDL_OpenAudioDevice(devname, SDL_TRUE, &spec, &spec, 0);
if (!devid_in) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for capture: %s!\n", SDL_GetError());
SDL_Quit();
@@ -162,6 +192,10 @@ int main(int argc, char **argv)
SDL_Delay(16);
}
#endif
+ /* SDL_DestroyRender
(Patch may be truncated, please check the link at the top of this post.)