Browse Source

testprogram: let main() return normally, don't exit for platform (eg Android) where there is some cleanup afterward.

Sylvain 2 years ago
parent
commit
c101e719fd

+ 4 - 1
test/checkkeys.c

@@ -35,7 +35,10 @@ static void
 quit(int rc)
 {
     SDL_Quit();
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void

+ 4 - 1
test/checkkeysthreads.c

@@ -33,7 +33,10 @@ static void
 quit(int rc)
 {
     SDL_Quit();
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void

+ 4 - 1
test/loopwave.c

@@ -41,7 +41,10 @@ static void
 quit(int rc)
 {
     SDL_Quit();
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void

+ 4 - 1
test/loopwavequeue.c

@@ -40,7 +40,10 @@ static void
 quit(int rc)
 {
     SDL_Quit();
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static int done = 0;

+ 4 - 1
test/testaudiohotplug.c

@@ -42,7 +42,10 @@ quit(int rc)
 {
     SDL_Quit();
     SDLTest_CommonDestroyState(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void SDLCALL

+ 4 - 1
test/testautomation.c

@@ -52,7 +52,10 @@ static void
 quit(int rc)
 {
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 int main(int argc, char *argv[])

+ 4 - 1
test/testcustomcursor.c

@@ -144,7 +144,10 @@ static void
 quit(int rc)
 {
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void loop(void)

+ 4 - 1
test/testdropfile.c

@@ -22,7 +22,10 @@ static void
 quit(int rc)
 {
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 int main(int argc, char *argv[])

+ 4 - 1
test/testerror.c

@@ -25,7 +25,10 @@ static void
 quit(int rc)
 {
     SDL_Quit();
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static int SDLCALL

+ 4 - 1
test/testgeometry.c

@@ -38,7 +38,10 @@ quit(int rc)
 {
     SDL_free(sprites);
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static int LoadSprite(const char *file)

+ 4 - 1
test/testgl.c

@@ -65,7 +65,10 @@ static void quit(int rc)
         SDL_GL_DeleteContext(context);
     }
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void Render(void)

+ 4 - 1
test/testgles.c

@@ -43,7 +43,10 @@ quit(int rc)
     }
 
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void

+ 4 - 1
test/testgles2.c

@@ -100,7 +100,10 @@ quit(int rc)
     }
 
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 #define GL_CHECK(x)                                                                         \

+ 4 - 1
test/testgles2_sdf.c

@@ -102,7 +102,10 @@ quit(int rc)
     }
 
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 #define GL_CHECK(x)                                                                         \

+ 5 - 2
test/testlock.c

@@ -65,7 +65,10 @@ static void closemutex(int sig)
         threads = NULL;
     }
     SDL_DestroyMutex(mutex);
-    exit(sig);
+    /* Let 'main()' return normally */
+    if (sig != 0) {
+        exit(sig);
+    }
 }
 
 static int SDLCALL
@@ -100,7 +103,7 @@ Run(void *data)
 }
 
 #ifndef _WIN32
-Uint32 hit_timeout(Uint32 interval, void *param) {
+static Uint32 hit_timeout(Uint32 interval, void *param) {
     SDL_Log("Hit timeout! Sending SIGINT!");
     kill(0, SIGINT);
     return 0;

+ 4 - 1
test/testmessage.c

@@ -23,7 +23,10 @@ static void
 quit(int rc)
 {
     SDL_Quit();
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static int SDLCALL

+ 4 - 1
test/testnative.c

@@ -52,7 +52,10 @@ quit(int rc)
         factory->DestroyNativeWindow(native_window);
     }
     SDLTest_CommonDestroyState(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite)

+ 2 - 2
test/testoverlay.c

@@ -176,9 +176,9 @@ quit(int rc)
 
     SDLTest_CommonQuit(state);
 
-
+    /* Let 'main()' return normally */
     if (rc != 0) {
-        exit(rc);
+         exit(rc);
     }
 }
 

+ 8 - 5
test/testpopup.c

@@ -47,8 +47,8 @@ struct PopupWindow
     int idx;
 };
 
-struct PopupWindow *menus;
-struct PopupWindow tooltip;
+static struct PopupWindow *menus;
+static struct PopupWindow tooltip;
 
 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
 static void quit(int rc)
@@ -57,7 +57,10 @@ static void quit(int rc)
     menus = NULL;
 
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static int get_menu_index_by_window(SDL_Window *window)
@@ -115,7 +118,7 @@ static SDL_bool create_popup(struct PopupWindow *new_popup, SDL_bool is_menu)
     return SDL_FALSE;
 }
 
-static void close_popups()
+static void close_popups(void)
 {
     int i;
 
@@ -135,7 +138,7 @@ static void close_popups()
     }
 }
 
-static void loop()
+static void loop(void)
 {
     int i;
     char fmt_str[128];

+ 4 - 1
test/testrendercopyex.c

@@ -41,7 +41,10 @@ static void
 quit(int rc)
 {
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void Draw(DrawState *s)

+ 4 - 1
test/testrendertarget.c

@@ -42,7 +42,10 @@ static void
 quit(int rc)
 {
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static SDL_bool

+ 4 - 1
test/testscale.c

@@ -41,7 +41,10 @@ static void
 quit(int rc)
 {
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void Draw(DrawState *s)

+ 1 - 1
test/testsem.c

@@ -256,7 +256,7 @@ int main(int argc, char **argv)
 {
     int arg_count = 0;
     int i;
-    int init_sem;
+    int init_sem = 0;
     SDLTest_CommonState *state;
 
     /* Initialize test framework */

+ 1 - 3
test/testsprite.c

@@ -57,9 +57,7 @@ quit(int rc)
     SDL_free(positions);
     SDL_free(velocities);
     SDLTest_CommonQuit(state);
-    /* If rc is 0, just let main return normally rather than calling exit.
-     * This allows testing of platforms where SDL_main is required and does meaningful cleanup.
-     */
+    /* Let 'main()' return normally */
     if (rc != 0) {
         exit(rc);
     }

+ 4 - 1
test/testspriteminimal.c

@@ -40,7 +40,10 @@ static void
 quit(int rc)
 {
     SDL_Quit();
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void MoveSprites(void)

+ 5 - 2
test/teststreaming.c

@@ -64,13 +64,16 @@ static SDL_Renderer *renderer;
 static int frame;
 static SDL_Texture *MooseTexture;
 static SDL_bool done = SDL_FALSE;
-SDLTest_CommonState *state;
+static SDLTest_CommonState *state;
 
 static void quit(int rc)
 {
     SDL_Quit();
     SDLTest_CommonDestroyState(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void UpdateTexture(SDL_Texture *texture)

+ 5 - 2
test/testthread.c

@@ -22,7 +22,7 @@
 static SDL_TLSID tls;
 static int alive = 0;
 static int testprio = 0;
-SDLTest_CommonState *state;
+static SDLTest_CommonState *state;
 
 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
 static void
@@ -30,7 +30,10 @@ quit(int rc)
 {
     SDLTest_CommonDestroyState(state);
     SDL_Quit();
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static const char *

+ 4 - 1
test/testviewport.c

@@ -38,7 +38,10 @@ static void
 quit(int rc)
 {
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void DrawOnViewport(SDL_Renderer *renderer)

+ 4 - 1
test/testvulkan.c

@@ -187,7 +187,10 @@ static void quit(int rc)
 {
     shutdownVulkan(SDL_TRUE);
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static void loadGlobalFunctions(void)

+ 4 - 1
test/testwm.c

@@ -47,7 +47,10 @@ static void
 quit(int rc)
 {
     SDLTest_CommonQuit(state);
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 /* Draws the modes menu, and stores the mode index under the mouse in highlighted_mode */

+ 4 - 1
test/torturethread.c

@@ -28,7 +28,10 @@ static void
 quit(int rc)
 {
     SDL_Quit();
-    exit(rc);
+    /* Let 'main()' return normally */
+    if (rc != 0) {
+        exit(rc);
+    }
 }
 
 static int SDLCALL