Skip to content

Commit

Permalink
testprogram: let main() return normally, don't exit for platform (eg …
Browse files Browse the repository at this point in the history
…Android) where there is some cleanup afterward.
  • Loading branch information
1bsyl committed Apr 12, 2023
1 parent ec053ec commit c101e71
Show file tree
Hide file tree
Showing 31 changed files with 123 additions and 41 deletions.
5 changes: 4 additions & 1 deletion test/checkkeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ static void
quit(int rc)
{
SDL_Quit();
exit(rc);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}

static void
Expand Down
5 changes: 4 additions & 1 deletion test/checkkeysthreads.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ static void
quit(int rc)
{
SDL_Quit();
exit(rc);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}

static void
Expand Down
5 changes: 4 additions & 1 deletion test/loopwave.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ static void
quit(int rc)
{
SDL_Quit();
exit(rc);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}

static void
Expand Down
5 changes: 4 additions & 1 deletion test/loopwavequeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion test/testaudiohotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/testautomation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[])
Expand Down
5 changes: 4 additions & 1 deletion test/testcustomcursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion test/testdropfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[])
Expand Down
5 changes: 4 additions & 1 deletion test/testerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/testgeometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion test/testgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion test/testgles.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ quit(int rc)
}

SDLTest_CommonQuit(state);
exit(rc);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}

static void
Expand Down
5 changes: 4 additions & 1 deletion test/testgles2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
5 changes: 4 additions & 1 deletion test/testgles2_sdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
7 changes: 5 additions & 2 deletions test/testlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion test/testmessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/testnative.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/testoverlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ quit(int rc)

SDLTest_CommonQuit(state);


/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
exit(rc);
}
}

Expand Down
13 changes: 8 additions & 5 deletions test/testpopup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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;

Expand All @@ -135,7 +138,7 @@ static void close_popups()
}
}

static void loop()
static void loop(void)
{
int i;
char fmt_str[128];
Expand Down
5 changes: 4 additions & 1 deletion test/testrendercopyex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion test/testrendertarget.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/testscale.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/testsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 1 addition & 3 deletions test/testsprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 4 additions & 1 deletion test/testspriteminimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions test/teststreaming.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions test/testthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
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
quit(int rc)
{
SDLTest_CommonDestroyState(state);
SDL_Quit();
exit(rc);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}

static const char *
Expand Down
5 changes: 4 additions & 1 deletion test/testviewport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion test/testvulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit c101e71

Please sign in to comment.