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

This commit is contained in:
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,8 +35,11 @@ static void
quit(int rc)
{
SDL_Quit();
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}
static void
print_string(char **text, size_t *maxlen, const char *fmt, ...)

View file

@ -33,8 +33,11 @@ static void
quit(int rc)
{
SDL_Quit();
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}
static void
print_string(char **text, size_t *maxlen, const char *fmt, ...)

View file

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

View file

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

View file

@ -42,8 +42,11 @@ quit(int rc)
{
SDL_Quit();
SDLTest_CommonDestroyState(state);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}
static void SDLCALL
fillerup(void *_pos, Uint8 *stream, int len)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -65,8 +65,11 @@ static void closemutex(int sig)
threads = NULL;
}
SDL_DestroyMutex(mutex);
/* Let 'main()' return normally */
if (sig != 0) {
exit(sig);
}
}
static int SDLCALL
Run(void *data)
@ -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,8 +23,11 @@ static void
quit(int rc)
{
SDL_Quit();
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}
static int SDLCALL
button_messagebox(void *eventNumber)

View file

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

View file

@ -176,7 +176,7 @@ quit(int rc)
SDLTest_CommonQuit(state);
/* Let 'main()' return normally */
if (rc != 0) {
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,8 +57,11 @@ static void quit(int rc)
menus = NULL;
SDLTest_CommonQuit(state);
/* 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,8 +41,11 @@ static void
quit(int rc)
{
SDLTest_CommonQuit(state);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}
static void Draw(DrawState *s)
{

View file

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

View file

@ -41,8 +41,11 @@ static void
quit(int rc)
{
SDLTest_CommonQuit(state);
/* 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,8 +40,11 @@ static void
quit(int rc)
{
SDL_Quit();
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}
static void MoveSprites(void)
{

View file

@ -64,14 +64,17 @@ 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);
/* 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,8 +30,11 @@ quit(int rc)
{
SDLTest_CommonDestroyState(state);
SDL_Quit();
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}
static const char *
getprioritystr(SDL_ThreadPriority priority)

View file

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

View file

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

View file

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

View file

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