mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-24 21:49:10 +00:00
testprogram: let main() return normally, don't exit for platform (eg Android) where there is some cleanup afterward.
This commit is contained in:
parent
ec053ec4f8
commit
c101e719fd
31 changed files with 123 additions and 41 deletions
|
@ -35,7 +35,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -33,7 +33,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -41,7 +41,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -40,7 +40,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int done = 0;
|
static int done = 0;
|
||||||
|
|
|
@ -42,7 +42,10 @@ quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
SDLTest_CommonDestroyState(state);
|
SDLTest_CommonDestroyState(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL
|
static void SDLCALL
|
||||||
|
|
|
@ -52,7 +52,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|
|
@ -144,7 +144,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loop(void)
|
static void loop(void)
|
||||||
|
|
|
@ -22,7 +22,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|
|
@ -25,7 +25,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDLCALL
|
static int SDLCALL
|
||||||
|
|
|
@ -38,7 +38,10 @@ quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_free(sprites);
|
SDL_free(sprites);
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int LoadSprite(const char *file)
|
static int LoadSprite(const char *file)
|
||||||
|
|
|
@ -65,7 +65,10 @@ static void quit(int rc)
|
||||||
SDL_GL_DeleteContext(context);
|
SDL_GL_DeleteContext(context);
|
||||||
}
|
}
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Render(void)
|
static void Render(void)
|
||||||
|
|
|
@ -43,7 +43,10 @@ quit(int rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -100,7 +100,10 @@ quit(int rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GL_CHECK(x) \
|
#define GL_CHECK(x) \
|
||||||
|
|
|
@ -102,7 +102,10 @@ quit(int rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GL_CHECK(x) \
|
#define GL_CHECK(x) \
|
||||||
|
|
|
@ -65,7 +65,10 @@ static void closemutex(int sig)
|
||||||
threads = NULL;
|
threads = NULL;
|
||||||
}
|
}
|
||||||
SDL_DestroyMutex(mutex);
|
SDL_DestroyMutex(mutex);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (sig != 0) {
|
||||||
exit(sig);
|
exit(sig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDLCALL
|
static int SDLCALL
|
||||||
|
@ -100,7 +103,7 @@ Run(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
Uint32 hit_timeout(Uint32 interval, void *param) {
|
static Uint32 hit_timeout(Uint32 interval, void *param) {
|
||||||
SDL_Log("Hit timeout! Sending SIGINT!");
|
SDL_Log("Hit timeout! Sending SIGINT!");
|
||||||
kill(0, SIGINT);
|
kill(0, SIGINT);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -23,7 +23,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDLCALL
|
static int SDLCALL
|
||||||
|
|
|
@ -52,7 +52,10 @@ quit(int rc)
|
||||||
factory->DestroyNativeWindow(native_window);
|
factory->DestroyNativeWindow(native_window);
|
||||||
}
|
}
|
||||||
SDLTest_CommonDestroyState(state);
|
SDLTest_CommonDestroyState(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite)
|
static void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite)
|
||||||
|
|
|
@ -176,7 +176,7 @@ quit(int rc)
|
||||||
|
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
|
||||||
|
/* Let 'main()' return normally */
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ struct PopupWindow
|
||||||
int idx;
|
int idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PopupWindow *menus;
|
static struct PopupWindow *menus;
|
||||||
struct PopupWindow tooltip;
|
static struct PopupWindow tooltip;
|
||||||
|
|
||||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||||
static void quit(int rc)
|
static void quit(int rc)
|
||||||
|
@ -57,7 +57,10 @@ static void quit(int rc)
|
||||||
menus = NULL;
|
menus = NULL;
|
||||||
|
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_menu_index_by_window(SDL_Window *window)
|
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;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_popups()
|
static void close_popups(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -135,7 +138,7 @@ static void close_popups()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loop()
|
static void loop(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char fmt_str[128];
|
char fmt_str[128];
|
||||||
|
|
|
@ -41,7 +41,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Draw(DrawState *s)
|
static void Draw(DrawState *s)
|
||||||
|
|
|
@ -42,7 +42,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool
|
static SDL_bool
|
||||||
|
|
|
@ -41,7 +41,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Draw(DrawState *s)
|
static void Draw(DrawState *s)
|
||||||
|
|
|
@ -256,7 +256,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int arg_count = 0;
|
int arg_count = 0;
|
||||||
int i;
|
int i;
|
||||||
int init_sem;
|
int init_sem = 0;
|
||||||
SDLTest_CommonState *state;
|
SDLTest_CommonState *state;
|
||||||
|
|
||||||
/* Initialize test framework */
|
/* Initialize test framework */
|
||||||
|
|
|
@ -57,9 +57,7 @@ quit(int rc)
|
||||||
SDL_free(positions);
|
SDL_free(positions);
|
||||||
SDL_free(velocities);
|
SDL_free(velocities);
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
/* If rc is 0, just let main return normally rather than calling exit.
|
/* Let 'main()' return normally */
|
||||||
* This allows testing of platforms where SDL_main is required and does meaningful cleanup.
|
|
||||||
*/
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MoveSprites(void)
|
static void MoveSprites(void)
|
||||||
|
|
|
@ -64,13 +64,16 @@ static SDL_Renderer *renderer;
|
||||||
static int frame;
|
static int frame;
|
||||||
static SDL_Texture *MooseTexture;
|
static SDL_Texture *MooseTexture;
|
||||||
static SDL_bool done = SDL_FALSE;
|
static SDL_bool done = SDL_FALSE;
|
||||||
SDLTest_CommonState *state;
|
static SDLTest_CommonState *state;
|
||||||
|
|
||||||
static void quit(int rc)
|
static void quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
SDLTest_CommonDestroyState(state);
|
SDLTest_CommonDestroyState(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateTexture(SDL_Texture *texture)
|
static void UpdateTexture(SDL_Texture *texture)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
static SDL_TLSID tls;
|
static SDL_TLSID tls;
|
||||||
static int alive = 0;
|
static int alive = 0;
|
||||||
static int testprio = 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. */
|
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||||
static void
|
static void
|
||||||
|
@ -30,7 +30,10 @@ quit(int rc)
|
||||||
{
|
{
|
||||||
SDLTest_CommonDestroyState(state);
|
SDLTest_CommonDestroyState(state);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
|
|
@ -38,7 +38,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawOnViewport(SDL_Renderer *renderer)
|
static void DrawOnViewport(SDL_Renderer *renderer)
|
||||||
|
|
|
@ -187,7 +187,10 @@ static void quit(int rc)
|
||||||
{
|
{
|
||||||
shutdownVulkan(SDL_TRUE);
|
shutdownVulkan(SDL_TRUE);
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadGlobalFunctions(void)
|
static void loadGlobalFunctions(void)
|
||||||
|
|
|
@ -47,7 +47,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draws the modes menu, and stores the mode index under the mouse in highlighted_mode */
|
/* Draws the modes menu, and stores the mode index under the mouse in highlighted_mode */
|
||||||
|
|
|
@ -28,7 +28,10 @@ static void
|
||||||
quit(int rc)
|
quit(int rc)
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
/* Let 'main()' return normally */
|
||||||
|
if (rc != 0) {
|
||||||
exit(rc);
|
exit(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDLCALL
|
static int SDLCALL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue