sdl2-compat: update testlib from latest SDL2

From 76ab1f9f40d468ebd69898c6d089c3b2fba2345d Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 9 Jan 2024 01:56:50 +0300
Subject: [PATCH] update testlib from latest SDL2

---
 test/testautomation_audio.c | 15 +++++++++++++++
 test/testautomation_main.c  |  3 +++
 2 files changed, 18 insertions(+)

diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c
index bd58631..0e75e19 100644
--- a/test/testautomation_audio.c
+++ b/test/testautomation_audio.c
@@ -83,6 +83,7 @@ int audio_initQuitAudio()
     int result;
     int i, iMax;
     const char *audioDriver;
+    const char *hint = SDL_GetHint(SDL_HINT_AUDIODRIVER);
 
     /* Stop SDL audio subsystem */
     SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -98,6 +99,10 @@ int audio_initQuitAudio()
         SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
         SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
 
+        if (hint && SDL_strcmp(audioDriver, hint) != 0) {
+            continue;
+        }
+
         /* Call Init */
         result = SDL_AudioInit(audioDriver);
         SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
@@ -140,6 +145,7 @@ int audio_initOpenCloseQuitAudio()
     int i, iMax, j, k;
     const char *audioDriver;
     SDL_AudioSpec desired;
+    const char *hint = SDL_GetHint(SDL_HINT_AUDIODRIVER);
 
     /* Stop SDL audio subsystem */
     SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -155,6 +161,10 @@ int audio_initOpenCloseQuitAudio()
         SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
         SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
 
+        if (hint && SDL_strcmp(audioDriver, hint) != 0) {
+            continue;
+        }
+
         /* Change specs */
         for (j = 0; j < 2; j++) {
 
@@ -229,6 +239,7 @@ int audio_pauseUnpauseAudio()
     int originalCounter;
     const char *audioDriver;
     SDL_AudioSpec desired;
+    const char *hint = SDL_GetHint(SDL_HINT_AUDIODRIVER);
 
     /* Stop SDL audio subsystem */
     SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -244,6 +255,10 @@ int audio_pauseUnpauseAudio()
         SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
         SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
 
+        if (hint && SDL_strcmp(audioDriver, hint) != 0) {
+            continue;
+        }
+
         /* Change specs */
         for (j = 0; j < 2; j++) {
 
diff --git a/test/testautomation_main.c b/test/testautomation_main.c
index ed72e0d..1f5af93 100644
--- a/test/testautomation_main.c
+++ b/test/testautomation_main.c
@@ -21,6 +21,7 @@ static int main_testInitQuitJoystickHaptic(void *arg)
     return TEST_SKIPPED;
 #else
     int enabled_subsystems;
+    int previous_subsystems = SDL_WasInit(SDL_INIT_EVERYTHING);
     int initialized_subsystems = SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC;
 
     SDLTest_AssertCheck(SDL_Init(initialized_subsystems) == 0, "SDL_Init multiple systems.");
@@ -33,6 +34,8 @@ static int main_testInitQuitJoystickHaptic(void *arg)
     enabled_subsystems = SDL_WasInit(initialized_subsystems);
     SDLTest_AssertCheck(enabled_subsystems == 0, "SDL_Quit should shut down everything (%i)", enabled_subsystems);
 
+    SDL_Init(previous_subsystems);
+
     return TEST_COMPLETED;
 #endif
 }