mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-21 04:35:23 +08:00
test: Add some common code to load test resources
As well as reducing duplication, this lets the tests load their resources from the SDL_GetBasePath() on platforms that support it, which is useful if the tests are compiled along with the rest of SDL and installed below /usr as manual tests, similar to GNOME's installed-tests convention. Thanks to Ozkan Sezer for the OS/2 build glue. Co-authored-by: Ozkan Sezer <sezeroz@gmail.com> Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
committed by
Sam Lantinga
parent
ecf1e15fec
commit
76a7b629bf
@@ -17,6 +17,8 @@
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
static SDL_AudioSpec spec;
|
||||
static Uint8 *sound = NULL; /* Pointer to wave data */
|
||||
static Uint32 soundlen = 0; /* Length of wave data */
|
||||
@@ -180,7 +182,7 @@ main(int argc, char **argv)
|
||||
if (devcount < 1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
|
||||
} else {
|
||||
const char *file = (argc < 2) ? "sample.wav" : argv[1];
|
||||
char *file = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(file, &spec, &sound, &soundlen) == NULL) {
|
||||
@@ -190,6 +192,8 @@ main(int argc, char **argv)
|
||||
test_multi_audio(devcount);
|
||||
SDL_FreeWAV(sound);
|
||||
}
|
||||
|
||||
SDL_free(file);
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
Reference in New Issue
Block a user