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

main
Sylvain 2023-04-12 11:07:28 +02:00 committed by Sylvain Becker
parent ec053ec4f8
commit c101e719fd
31 changed files with 123 additions and 41 deletions

View File

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

View File

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

View File

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

View File

@ -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;

View File

@ -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

View File

@ -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[])

View File

@ -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)

View File

@ -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[])

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

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

View File

@ -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) \

View File

@ -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) \

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

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

View File

@ -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];

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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 */

View File

@ -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);
}

View File

@ -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)

View File

@ -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)

View File

@ -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 *

View File

@ -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)

View File

@ -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)

View File

@ -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 */

View File

@ -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