SDL: Add SDL_main.h includes to tests

From 22e22ba1964c6ff8effc0e71c5672d620f725ab5 Mon Sep 17 00:00:00 2001
From: Daniel Gibson <[EMAIL REDACTED]>
Date: Thu, 15 Dec 2022 05:58:20 +0100
Subject: [PATCH] Add SDL_main.h includes to tests

.. including cmake/test/*.c, whatever that does

(this is needed now because SDL.h doesn't include SDL_main.h anymore)
---
 cmake/test/main_cli.c     | 1 +
 cmake/test/main_gui.c     | 1 +
 cmake/test/main_lib.c     | 2 ++
 test/checkkeys.c          | 1 +
 test/checkkeysthreads.c   | 1 +
 test/controllermap.c      | 1 +
 test/loopwave.c           | 1 +
 test/loopwavequeue.c      | 1 +
 test/testatomic.c         | 1 +
 test/testaudiocapture.c   | 1 +
 test/testaudiohotplug.c   | 1 +
 test/testaudioinfo.c      | 1 +
 test/testautomation.c     | 1 +
 test/testbounds.c         | 1 +
 test/testcustomcursor.c   | 1 +
 test/testdisplayinfo.c    | 1 +
 test/testdraw2.c          | 1 +
 test/testdrawchessboard.c | 1 +
 test/testdropfile.c       | 1 +
 test/testerror.c          | 1 +
 test/testfile.c           | 1 +
 test/testfilesystem.c     | 1 +
 test/testgamecontroller.c | 1 +
 test/testgeometry.c       | 1 +
 test/testgl2.c            | 1 +
 test/testgles.c           | 1 +
 test/testgles2.c          | 1 +
 test/testgles2_sdf.c      | 1 +
 test/testhaptic.c         | 1 +
 test/testhittesting.c     | 1 +
 test/testhotplug.c        | 1 +
 test/testiconv.c          | 1 +
 test/testime.c            | 1 +
 test/testintersections.c  | 1 +
 test/testjoystick.c       | 1 +
 test/testkeys.c           | 1 +
 test/testloadso.c         | 1 +
 test/testlocale.c         | 1 +
 test/testlock.c           | 1 +
 test/testmessage.c        | 1 +
 test/testmouse.c          | 1 +
 test/testmultiaudio.c     | 1 +
 test/testnative.c         | 2 ++
 test/testoffscreen.c      | 1 +
 test/testoverlay2.c       | 1 +
 test/testplatform.c       | 1 +
 test/testpower.c          | 1 +
 test/testqsort.c          | 1 +
 test/testrelative.c       | 1 +
 test/testrendercopyex.c   | 1 +
 test/testrendertarget.c   | 1 +
 test/testresample.c       | 1 +
 test/testrumble.c         | 1 +
 test/testscale.c          | 1 +
 test/testsem.c            | 1 +
 test/testsensor.c         | 1 +
 test/testshader.c         | 1 +
 test/testshape.c          | 1 +
 test/testsprite2.c        | 1 +
 test/testspriteminimal.c  | 1 +
 test/teststreaming.c      | 1 +
 test/testsurround.c       | 1 +
 test/testthread.c         | 1 +
 test/testtimer.c          | 1 +
 test/testurl.c            | 1 +
 test/testver.c            | 1 +
 test/testviewport.c       | 1 +
 test/testvulkan.c         | 1 +
 test/testwm2.c            | 1 +
 test/testyuv.c            | 1 +
 test/torturethread.c      | 1 +
 71 files changed, 73 insertions(+)

diff --git a/cmake/test/main_cli.c b/cmake/test/main_cli.c
index 658b9d54b24d..0449709c025d 100644
--- a/cmake/test/main_cli.c
+++ b/cmake/test/main_cli.c
@@ -1,5 +1,6 @@
 #define SDL_MAIN_HANDLED
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include <stdio.h>
 
 int main(int argc, char *argv[]) {
diff --git a/cmake/test/main_gui.c b/cmake/test/main_gui.c
index 1f482b6bbc05..84d8d67f8897 100644
--- a/cmake/test/main_gui.c
+++ b/cmake/test/main_gui.c
@@ -1,4 +1,5 @@
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include <stdio.h>
 
 int main(int argc, char *argv[]) {
diff --git a/cmake/test/main_lib.c b/cmake/test/main_lib.c
index 5e7763df75c1..78d7c60dd918 100644
--- a/cmake/test/main_lib.c
+++ b/cmake/test/main_lib.c
@@ -1,4 +1,6 @@
 #include <SDL3/SDL.h>
+#define SDL_MAIN_HANDLED /* don't drag in header-only SDL_main implementation */
+#include <SDL3/SDL_main.h>
 #include <stdio.h>
 
 #include EXPORT_HEADER
diff --git a/test/checkkeys.c b/test/checkkeys.c
index 6c739b1ed8ec..6a3a6bad660f 100644
--- a/test/checkkeys.c
+++ b/test/checkkeys.c
@@ -22,6 +22,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include <SDL3/SDL_test_font.h>
 
 static SDL_Window *window;
diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c
index b361c1487eaa..153bd825849b 100644
--- a/test/checkkeysthreads.c
+++ b/test/checkkeysthreads.c
@@ -23,6 +23,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 int done;
 
diff --git a/test/controllermap.c b/test/controllermap.c
index b0aa86f881a3..a9fadf13cf3c 100644
--- a/test/controllermap.c
+++ b/test/controllermap.c
@@ -17,6 +17,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 /* Define this for verbose output while mapping controllers */
diff --git a/test/loopwave.c b/test/loopwave.c
index 132ebbc7bdb0..e2a2ada508fa 100644
--- a/test/loopwave.c
+++ b/test/loopwave.c
@@ -22,6 +22,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 static struct
diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c
index 95c71d75459e..ff85c29447a8 100644
--- a/test/loopwavequeue.c
+++ b/test/loopwavequeue.c
@@ -19,6 +19,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #if HAVE_SIGNAL_H
 #include <signal.h>
diff --git a/test/testatomic.c b/test/testatomic.c
index a81b6117b257..4b3eca50ccd3 100644
--- a/test/testatomic.c
+++ b/test/testatomic.c
@@ -10,6 +10,7 @@
   freely.
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 /*
   Absolutely basic tests just to see if we get the expected value
diff --git a/test/testaudiocapture.c b/test/testaudiocapture.c
index d0db38b13f87..b20d9180f82f 100644
--- a/test/testaudiocapture.c
+++ b/test/testaudiocapture.c
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #ifdef __EMSCRIPTEN__
 #include <emscripten/emscripten.h>
diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c
index cb7020b302a0..5d145f8d4a2d 100644
--- a/test/testaudiohotplug.c
+++ b/test/testaudiohotplug.c
@@ -23,6 +23,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 static SDL_AudioSpec spec;
diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c
index 2bdf92893569..f262e92dcfda 100644
--- a/test/testaudioinfo.c
+++ b/test/testaudioinfo.c
@@ -10,6 +10,7 @@
   freely.
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static void
 print_devices(int iscapture)
diff --git a/test/testautomation.c b/test/testautomation.c
index 1bb5627cc671..4c69d6cc0d6f 100644
--- a/test/testautomation.c
+++ b/test/testautomation.c
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include <SDL3/SDL_test.h>
 
 #include "testautomation_suites.h"
diff --git a/test/testbounds.c b/test/testbounds.c
index a44dc079dd39..de1bd1b099f3 100644
--- a/test/testbounds.c
+++ b/test/testbounds.c
@@ -11,6 +11,7 @@
 */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 int main(int argc, char **argv)
 {
diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c
index 8592d097acdf..0aad0a325f50 100644
--- a/test/testcustomcursor.c
+++ b/test/testcustomcursor.c
@@ -16,6 +16,7 @@
 #endif
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 
 /* Stolen from the mailing list */
 /* Creates a new mouse cursor from an XPM */
diff --git a/test/testdisplayinfo.c b/test/testdisplayinfo.c
index 6cfddecdb188..cbbd21a3831c 100644
--- a/test/testdisplayinfo.c
+++ b/test/testdisplayinfo.c
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static void
 print_mode(const char *prefix, const SDL_DisplayMode *mode)
diff --git a/test/testdraw2.c b/test/testdraw2.c
index 2ff9e4f842ef..06b5c2e46ac7 100644
--- a/test/testdraw2.c
+++ b/test/testdraw2.c
@@ -20,6 +20,7 @@
 #endif
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 
 #define NUM_OBJECTS 100
 
diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c
index 9e83381984c0..6ff158ba00dd 100644
--- a/test/testdrawchessboard.c
+++ b/test/testdrawchessboard.c
@@ -19,6 +19,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 SDL_Window *window;
 SDL_Renderer *renderer;
diff --git a/test/testdropfile.c b/test/testdropfile.c
index b1390d66bfa3..9884d88a4312 100644
--- a/test/testdropfile.c
+++ b/test/testdropfile.c
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 
 static SDLTest_CommonState *state;
 
diff --git a/test/testerror.c b/test/testerror.c
index e0f137423941..57834b65c8c0 100644
--- a/test/testerror.c
+++ b/test/testerror.c
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static int alive = 0;
 
diff --git a/test/testfile.c b/test/testfile.c
index ffef041b54fc..406f00307ecb 100644
--- a/test/testfile.c
+++ b/test/testfile.c
@@ -24,6 +24,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 /* WARNING ! those 2 files will be destroyed by this test program */
 
diff --git a/test/testfilesystem.c b/test/testfilesystem.c
index 9e099582b175..425f60fc3589 100644
--- a/test/testfilesystem.c
+++ b/test/testfilesystem.c
@@ -12,6 +12,7 @@
 /* Simple test of filesystem functions. */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 int main(int argc, char *argv[])
 {
diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c
index 421da8e89f3b..68352fdea380 100644
--- a/test/testgamecontroller.c
+++ b/test/testgamecontroller.c
@@ -13,6 +13,7 @@
 /* Simple program to test the SDL game controller routines */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 #ifdef __EMSCRIPTEN__
diff --git a/test/testgeometry.c b/test/testgeometry.c
index afe71740f969..1509888ee4d7 100644
--- a/test/testgeometry.c
+++ b/test/testgeometry.c
@@ -20,6 +20,7 @@
 #endif
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 static SDLTest_CommonState *state;
diff --git a/test/testgl2.c b/test/testgl2.c
index 238a1fef9d28..b5abb64915a2 100644
--- a/test/testgl2.c
+++ b/test/testgl2.c
@@ -10,6 +10,7 @@
   freely.
 */
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 
 #ifdef HAVE_OPENGL
 
diff --git a/test/testgles.c b/test/testgles.c
index cd96eac7d2f6..f9b48caf55fe 100644
--- a/test/testgles.c
+++ b/test/testgles.c
@@ -12,6 +12,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 
 #if defined(__IOS__) || defined(__ANDROID__)
 #define HAVE_OPENGLES
diff --git a/test/testgles2.c b/test/testgles2.c
index 7e047b21d624..ae49934c0a96 100644
--- a/test/testgles2.c
+++ b/test/testgles2.c
@@ -16,6 +16,7 @@
 #endif
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 
 #if defined(__IOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__WINDOWS__) || defined(__LINUX__)
 #define HAVE_OPENGLES2
diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c
index edae4ef7a3f6..bd0f51df16df 100644
--- a/test/testgles2_sdf.c
+++ b/test/testgles2_sdf.c
@@ -16,6 +16,7 @@
 #endif
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 #if defined(__IOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__WINDOWS__) || defined(__LINUX__)
diff --git a/test/testhaptic.c b/test/testhaptic.c
index 942495331a80..3f02466bc807 100644
--- a/test/testhaptic.c
+++ b/test/testhaptic.c
@@ -17,6 +17,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static SDL_Haptic *haptic;
 
diff --git a/test/testhittesting.c b/test/testhittesting.c
index a2646975abae..6c783f51c860 100644
--- a/test/testhittesting.c
+++ b/test/testhittesting.c
@@ -10,6 +10,7 @@
   freely.
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 /* !!! FIXME: rewrite this to be wired in to test framework. */
 
diff --git a/test/testhotplug.c b/test/testhotplug.c
index a26ae5da4b87..2b090b151043 100644
--- a/test/testhotplug.c
+++ b/test/testhotplug.c
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 int main(int argc, char *argv[])
 {
diff --git a/test/testiconv.c b/test/testiconv.c
index 00a506c0d5f9..f9903a11d140 100644
--- a/test/testiconv.c
+++ b/test/testiconv.c
@@ -18,6 +18,7 @@
 #include <stdio.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 static size_t
diff --git a/test/testime.c b/test/testime.c
index e742253441c6..000f7e8ee331 100644
--- a/test/testime.c
+++ b/test/testime.c
@@ -14,6 +14,7 @@
    Download at http://unifoundry.com/unifont.html */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #ifdef HAVE_SDL_TTF
 #include "SDL_ttf.h"
 #endif
diff --git a/test/testintersections.c b/test/testintersections.c
index 94966b2a36dd..d9eeef49f9d4 100644
--- a/test/testintersections.c
+++ b/test/testintersections.c
@@ -20,6 +20,7 @@
 #endif
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 
 #define SWAP(typ, a, b) \
     do {                \
diff --git a/test/testjoystick.c b/test/testjoystick.c
index 8b2552ee170d..0af97d616fde 100644
--- a/test/testjoystick.c
+++ b/test/testjoystick.c
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #ifdef __EMSCRIPTEN__
 #include <emscripten/emscripten.h>
diff --git a/test/testkeys.c b/test/testkeys.c
index 31221e96c299..5319daa8302c 100644
--- a/test/testkeys.c
+++ b/test/testkeys.c
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 int main(int argc, char *argv[])
 {
diff --git a/test/testloadso.c b/test/testloadso.c
index a1e5319395c7..8f91ddd33ae6 100644
--- a/test/testloadso.c
+++ b/test/testloadso.c
@@ -16,6 +16,7 @@
 #include <stdio.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 typedef int (*fntype)(const char *);
 
diff --git a/test/testlocale.c b/test/testlocale.c
index 714cc29810e6..7699ecac1172 100644
--- a/test/testlocale.c
+++ b/test/testlocale.c
@@ -10,6 +10,7 @@
   freely.
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 /* !!! FIXME: move this to the test framework */
 
diff --git a/test/testlock.c b/test/testlock.c
index 09a2c9843a44..88d35a9a8b41 100644
--- a/test/testlock.c
+++ b/test/testlock.c
@@ -18,6 +18,7 @@
 #include <stdlib.h> /* for atexit() */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static SDL_mutex *mutex = NULL;
 static SDL_threadID mainthread;
diff --git a/test/testmessage.c b/test/testmessage.c
index 3d3489b947bf..c538b851e277 100644
--- a/test/testmessage.c
+++ b/test/testmessage.c
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
 static void
diff --git a/test/testmouse.c b/test/testmouse.c
index 121972a863fa..51a03d98b5d8 100644
--- a/test/testmouse.c
+++ b/test/testmouse.c
@@ -11,6 +11,7 @@
 */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #ifdef __EMSCRIPTEN__
 #include <emscripten/emscripten.h>
diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c
index 3d0632826054..cb1d0bb6ee3c 100644
--- a/test/testmultiaudio.c
+++ b/test/testmultiaudio.c
@@ -10,6 +10,7 @@
   freely.
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #include <stdio.h> /* for fflush() and stdout */
 
diff --git a/test/testnative.c b/test/testnative.c
index acb316b05645..7ba65f3dd61e 100644
--- a/test/testnative.c
+++ b/test/testnative.c
@@ -17,6 +17,8 @@
 #include "testnative.h"
 #include "testutils.h"
 
+#include <SDL3/SDL_main.h>
+
 #define WINDOW_W    640
 #define WINDOW_H    480
 #define NUM_SPRITES 100
diff --git a/test/testoffscreen.c b/test/testoffscreen.c
index fed770b0b3d0..e7112e8c2e8c 100644
--- a/test/testoffscreen.c
+++ b/test/testoffscreen.c
@@ -20,6 +20,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include <SDL3/SDL_opengl.h>
 
 static SDL_Renderer *renderer = NULL;
diff --git a/test/testoverlay2.c b/test/testoverlay2.c
index 737fa10b8814..5f623cbd1ced 100644
--- a/test/testoverlay2.c
+++ b/test/testoverlay2.c
@@ -24,6 +24,7 @@
 
 #include <SDL3/SDL_test.h>
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 #define MOOSEPIC_W 64
diff --git a/test/testplatform.c b/test/testplatform.c
index 213e46295a98..db5ca095db96 100644
--- a/test/testplatform.c
+++ b/test/testplatform.c
@@ -10,6 +10,7 @@
   freely.
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 /*
  * Watcom C flags these as Warning 201: "Unreachable code" if you just
diff --git a/test/testpower.c b/test/testpower.c
index ed4c538ec45c..2277cbf47572 100644
--- a/test/testpower.c
+++ b/test/testpower.c
@@ -12,6 +12,7 @@
 /* Simple test of power subsystem. */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static void
 report_power(void)
diff --git a/test/testqsort.c b/test/testqsort.c
index b2503c1910f7..3d4ceda291e8 100644
--- a/test/testqsort.c
+++ b/test/testqsort.c
@@ -11,6 +11,7 @@
 */
 
 #include <SDL3/SDL_test.h>
+#include <SDL3/SDL_main.h>
 
 static int SDLCALL
 num_compare(const void *_a, const void *_b)
diff --git a/test/testrelative.c b/test/testrelative.c
index 871ab3503f1d..ad9a610b2e84 100644
--- a/test/testrelative.c
+++ b/test/testrelative.c
@@ -16,6 +16,7 @@
 #include <time.h>
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 
 #ifdef __EMSCRIPTEN__
 #include <emscripten/emscripten.h>
diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c
index a6f2ec9f35b1..170b111aae5b 100644
--- a/test/testrendercopyex.c
+++ b/test/testrendercopyex.c
@@ -18,6 +18,7 @@
 #endif
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 static SDLTest_CommonState *state;
diff --git a/test/testrendertarget.c b/test/testrendertarget.c
index 1e0adca488ac..2071decc6b7a 100644
--- a/test/testrendertarget.c
+++ b/test/testrendertarget.c
@@ -18,6 +18,7 @@
 #endif
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 static SDLTest_CommonState *state;
diff --git a/test/testresample.c b/test/testresample.c
index df2758d9a025..80fa7a935ca3 100644
--- a/test/testresample.c
+++ b/test/testresample.c
@@ -11,6 +11,7 @@
 */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 int main(int argc, char **argv)
 {
diff --git a/test/testrumble.c b/test/testrumble.c
index 8a88c62ef6ab..be7b718eab96 100644
--- a/test/testrumble.c
+++ b/test/testrumble.c
@@ -26,6 +26,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  * includes
  */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static SDL_Haptic *haptic;
 
diff --git a/test/testscale.c b/test/testscale.c
index 8398bdcfa05b..9e3d49d84d86 100644
--- a/test/testscale.c
+++ b/test/testscale.c
@@ -18,6 +18,7 @@
 #endif
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 #define WINDOW_WIDTH  640
diff --git a/test/testsem.c b/test/testsem.c
index 9b977ba1e5c3..5d3411d4ce6e 100644
--- a/test/testsem.c
+++ b/test/testsem.c
@@ -15,6 +15,7 @@
 #include <signal.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #define NUM_THREADS 10
 /* This value should be smaller than the maximum count of the */
diff --git a/test/testsensor.c b/test/testsensor.c
index 308e6a1a0bcd..203f21d83e17 100644
--- a/test/testsensor.c
+++ b/test/testsensor.c
@@ -13,6 +13,7 @@
 /* Simple test of the SDL sensor code */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static const char *GetSensorTypeString(SDL_SensorType type)
 {
diff --git a/test/testshader.c b/test/testshader.c
index a89fea928620..da1668c48d5c 100644
--- a/test/testshader.c
+++ b/test/testshader.c
@@ -12,6 +12,7 @@
 /* This is a simple example of using GLSL shaders with SDL */
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #include <stdlib.h>
 
diff --git a/test/testshape.c b/test/testshape.c
index 3f004bb70c61..605f072d80fe 100644
--- a/test/testshape.c
+++ b/test/testshape.c
@@ -12,6 +12,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #define SHAPED_WINDOW_X         150
 #define SHAPED_WINDOW_Y         150
diff --git a/test/testsprite2.c b/test/testsprite2.c
index a7414e742e14..4b59ce295fc5 100644
--- a/test/testsprite2.c
+++ b/test/testsprite2.c
@@ -20,6 +20,7 @@
 
 #include <SDL3/SDL_test.h>
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 #define NUM_SPRITES 100
diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c
index a58fccb043d0..41a14880e961 100644
--- a/test/testspriteminimal.c
+++ b/test/testspriteminimal.c
@@ -19,6 +19,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 #define WINDOW_WIDTH  640
diff --git a/test/teststreaming.c b/test/teststreaming.c
index ab9edfcb782f..7d7efe3c0f43 100644
--- a/test/teststreaming.c
+++ b/test/teststreaming.c
@@ -22,6 +22,7 @@
 #endif
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 #define MOOSEPIC_W 64
diff --git a/test/testsurround.c b/test/testsurround.c
index a6a8d0307451..dad9fb153cc1 100644
--- a/test/testsurround.c
+++ b/test/testsurround.c
@@ -12,6 +12,7 @@
 
 /* Program to test surround sound audio channels */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static int total_channels;
 static int active_channel;
diff --git a/test/testthread.c b/test/testthread.c
index facbdb850c15..011bf3983529 100644
--- a/test/testthread.c
+++ b/test/testthread.c
@@ -16,6 +16,7 @@
 #include <signal.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static SDL_TLSID tls;
 static int alive = 0;
diff --git a/test/testtimer.c b/test/testtimer.c
index baa34e2d3791..7f17c97af90f 100644
--- a/test/testtimer.c
+++ b/test/testtimer.c
@@ -14,6 +14,7 @@
    platform
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #define DEFAULT_RESOLUTION 1
 
diff --git a/test/testurl.c b/test/testurl.c
index c51e63bfc952..c9622567b710 100644
--- a/test/testurl.c
+++ b/test/testurl.c
@@ -10,6 +10,7 @@
   freely.
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 static void tryOpenURL(const char *url)
 {
diff --git a/test/testver.c b/test/testver.c
index cad5268ab988..b2a432c4beee 100644
--- a/test/testver.c
+++ b/test/testver.c
@@ -14,6 +14,7 @@
    version of SDL
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 int main(int argc, char *argv[])
 {
diff --git a/test/testviewport.c b/test/testviewport.c
index 6b9b29481ecc..1e250022bde2 100644
--- a/test/testviewport.c
+++ b/test/testviewport.c
@@ -19,6 +19,7 @@
 
 #include <SDL3/SDL_test.h>
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 #include "testutils.h"
 
 static SDLTest_CommonState *state;
diff --git a/test/testvulkan.c b/test/testvulkan.c
index 4a618d26d143..d9cfc7e884d6 100644
--- a/test/testvulkan.c
+++ b/test/testvulkan.c
@@ -12,6 +12,7 @@
 #include <stdlib.h>
 
 #include <SDL3/SDL_test_common.h>
+#include <SDL3/SDL_main.h>
 
 #if defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
 
diff --git a/test/testwm2.c b/test/testwm2.c
index a7c30bf64f77..0472cd8f0240 100644
--- a/test/testwm2.c
+++ b/test/testwm2.c
@@ -18,6 +18,7 @@
 
 #include <SDL3/SDL_test_common.h>
 #include <SDL3/SDL_test_font.h>
+#include <SDL3/SDL_main.h>
 
 static SDLTest_CommonState *state;
 int done;
diff --git a/test/testyuv.c b/test/testyuv.c
index 063f25162fb4..76228fac6b1d 100644
--- a/test/testyuv.c
+++ b/test/testyuv.c
@@ -10,6 +10,7 @@
   freely.
 */
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 #include <SDL3/SDL_test_font.h>
 #include "testyuv_cvt.h"
 
diff --git a/test/torturethread.c b/test/torturethread.c
index fb59993f0a1d..0ede9e7d2442 100644
--- a/test/torturethread.c
+++ b/test/torturethread.c
@@ -16,6 +16,7 @@
 #include <signal.h>
 
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #define NUMTHREADS 10