cmake: make sure SDL_GetPrefPath is run before testfilesystem 60 seconds timeout ought to be sufficient.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1f65b75..52a2685 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -168,6 +168,9 @@ add_sdl_test_executable(testoverlay2 NEEDS_RESOURCES testoverlay2.c testyuv_cvt.
add_sdl_test_executable(testplatform NONINTERACTIVE testplatform.c)
add_sdl_test_executable(testpower NONINTERACTIVE testpower.c)
add_sdl_test_executable(testfilesystem NONINTERACTIVE testfilesystem.c)
+if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
+ add_sdl_test_executable(testfilesystem_pre NONINTERACTIVE testfilesystem_pre.c)
+endif()
add_sdl_test_executable(testrendertarget NEEDS_RESOURCES testrendertarget.c testutils.c)
add_sdl_test_executable(testscale NEEDS_RESOURCES testscale.c testutils.c)
add_sdl_test_executable(testsem testsem.c)
@@ -426,6 +429,10 @@ endforeach()
set_tests_properties(testthread PROPERTIES TIMEOUT 40)
set_tests_properties(testtimer PROPERTIES TIMEOUT 60)
+if(TARGET testfilesystem_pre)
+ set_property(TEST testfilesystem_pre PROPERTY TIMEOUT 60)
+ set_property(TEST testfilesystem APPEND PROPERTY DEPENDS testfilesystem_pre)
+endif()
if(SDL_INSTALL_TESTS)
if(RISCOS)
diff --git a/test/testfilesystem_pre.c b/test/testfilesystem_pre.c
new file mode 100644
index 0000000..dba8b51
--- /dev/null
+++ b/test/testfilesystem_pre.c
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely.
+*/
+/* Call SDL_GetPrefPath to warm the SHGetFolderPathW cache */
+
+/**
+ * We noticed frequent ci timeouts running testfilesystem on 32-bit Windows.
+ * Internally, this functions calls Shell32.SHGetFolderPathW.
+ */
+
+#include "SDL.h"
+
+int main(int argc, char *argv[])
+{
+ Uint64 start;
+ (void)argc;
+ (void)argv;
+ SDL_Init(0);
+ start = SDL_GetTicks();
+ SDL_GetPrefPath("libsdl", "test_filesystem");
+ SDL_Log("SDL_GetPrefPath took %" SDL_PRIu64 "ms", SDL_GetTicks() - start);
+ SDL_Quit();
+ return 0;
+}