SDL: Restore the previously initialized subsystems after the Init/Quit test

From f62d1220ac63b4a7291e1d2a8797bd7392063717 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 8 Jan 2024 14:32:52 -0800
Subject: [PATCH] Restore the previously initialized subsystems after the
 Init/Quit test

Fixes https://github.com/libsdl-org/SDL/issues/8796
---
 test/testautomation_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/testautomation_main.c b/test/testautomation_main.c
index ed72e0d950b6..1f5af93b4b7d 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
 }