Skip to content

Commit

Permalink
test: use SDL_test for parsing arguments in all non-interactive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Aug 31, 2024
1 parent 47a5256 commit 2ae8b4c
Show file tree
Hide file tree
Showing 21 changed files with 408 additions and 93 deletions.
6 changes: 6 additions & 0 deletions VisualC/tests/testatomic/testatomic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\SDLtest\SDLtest.vcxproj">
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
<Private>false</Private>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\SDLmain\SDLmain.vcxproj">
<Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
<Private>false</Private>
Expand Down
6 changes: 6 additions & 0 deletions VisualC/tests/testplatform/testplatform.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\SDLtest\SDLtest.vcxproj">
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
<Private>false</Private>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\SDLmain\SDLmain.vcxproj">
<Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
<Private>false</Private>
Expand Down
6 changes: 6 additions & 0 deletions VisualC/tests/testpower/testpower.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\SDLtest\SDLtest.vcxproj">
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
<Private>false</Private>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\SDLmain\SDLmain.vcxproj">
<Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
<Private>false</Private>
Expand Down
6 changes: 6 additions & 0 deletions VisualC/tests/testsurround/testsurround.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\SDLtest\SDLtest.vcxproj">
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
<Private>false</Private>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\SDLmain\SDLmain.vcxproj">
<Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
<Private>false</Private>
Expand Down
32 changes: 16 additions & 16 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,23 @@ add_sdl_test_executable(checkkeys checkkeys.c)
add_sdl_test_executable(checkkeysthreads checkkeysthreads.c)
add_sdl_test_executable(loopwave NEEDS_RESOURCES loopwave.c testutils.c)
add_sdl_test_executable(loopwavequeue NEEDS_RESOURCES loopwavequeue.c testutils.c)
add_sdl_test_executable(testsurround NOTRACKMEM testsurround.c)
add_sdl_test_executable(testsurround testsurround.c)
add_sdl_test_executable(testresample NEEDS_RESOURCES testresample.c)
add_sdl_test_executable(testaudioinfo NOTRACKMEM testaudioinfo.c)
add_sdl_test_executable(testaudioinfo testaudioinfo.c)

file(GLOB TESTAUTOMATION_SOURCE_FILES testautomation*.c)
add_sdl_test_executable(testautomation NONINTERACTIVE NEEDS_RESOURCES ${TESTAUTOMATION_SOURCE_FILES})
add_sdl_test_executable(testmultiaudio NEEDS_RESOURCES testmultiaudio.c testutils.c)
add_sdl_test_executable(testaudiohotplug NEEDS_RESOURCES testaudiohotplug.c testutils.c)
add_sdl_test_executable(testaudiocapture testaudiocapture.c)
add_sdl_test_executable(testatomic NOTRACKMEM NONINTERACTIVE testatomic.c)
add_sdl_test_executable(testatomic NONINTERACTIVE testatomic.c)
add_sdl_test_executable(testintersections testintersections.c)
add_sdl_test_executable(testrelative testrelative.c)
add_sdl_test_executable(testhittesting testhittesting.c)
add_sdl_test_executable(testdraw2 testdraw2.c)
add_sdl_test_executable(testdrawchessboard testdrawchessboard.c)
add_sdl_test_executable(testdropfile testdropfile.c)
add_sdl_test_executable(testerror NOTRACKMEM NONINTERACTIVE testerror.c)
add_sdl_test_executable(testerror NONINTERACTIVE testerror.c)

if(LINUX)
add_sdl_test_executable(testevdev NOTRACKMEM NONINTERACTIVE testevdev.c)
Expand All @@ -148,13 +148,13 @@ endif()
add_sdl_test_executable(testhaptic testhaptic.c)
add_sdl_test_executable(testhotplug testhotplug.c)
add_sdl_test_executable(testrumble testrumble.c)
add_sdl_test_executable(testthread NOTRACKMEM NONINTERACTIVE testthread.c)
add_sdl_test_executable(testthread NONINTERACTIVE testthread.c)
add_sdl_test_executable(testiconv NEEDS_RESOURCES testiconv.c testutils.c)
add_sdl_test_executable(testime NEEDS_RESOURCES testime.c testutils.c)
add_sdl_test_executable(testjoystick testjoystick.c)
add_sdl_test_executable(testkeys NOTRACKMEM testkeys.c)
add_sdl_test_executable(testkeys testkeys.c)
add_sdl_test_executable(testloadso testloadso.c)
add_sdl_test_executable(testlocale NOTRACKMEM NONINTERACTIVE testlocale.c)
add_sdl_test_executable(testlocale NONINTERACTIVE testlocale.c)
add_sdl_test_executable(testlock testlock.c)
add_sdl_test_executable(testmouse testmouse.c)

Expand Down Expand Up @@ -182,11 +182,11 @@ elseif(OS2)
endif()

add_sdl_test_executable(testoverlay2 NEEDS_RESOURCES testoverlay2.c testyuv_cvt.c testutils.c)
add_sdl_test_executable(testplatform NOTRACKMEM NONINTERACTIVE testplatform.c)
add_sdl_test_executable(testpower NOTRACKMEM NONINTERACTIVE testpower.c)
add_sdl_test_executable(testfilesystem NOTRACKMEM NONINTERACTIVE testfilesystem.c)
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 NOTRACKMEM NONINTERACTIVE testfilesystem_pre.c)
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)
Expand All @@ -197,18 +197,18 @@ add_sdl_test_executable(testshape NEEDS_RESOURCES testshape.c)
add_sdl_test_executable(testsprite2 NEEDS_RESOURCES testsprite2.c testutils.c)
add_sdl_test_executable(testspriteminimal NEEDS_RESOURCES testspriteminimal.c testutils.c)
add_sdl_test_executable(teststreaming NEEDS_RESOURCES teststreaming.c testutils.c)
add_sdl_test_executable(testtimer NOTRACKMEM NONINTERACTIVE testtimer.c)
add_sdl_test_executable(testtimer NONINTERACTIVE testtimer.c)
add_sdl_test_executable(testurl testurl.c)
add_sdl_test_executable(testver NOTRACKMEM NONINTERACTIVE testver.c)
add_sdl_test_executable(testver NONINTERACTIVE testver.c)
add_sdl_test_executable(testviewport NEEDS_RESOURCES testviewport.c testutils.c)
add_sdl_test_executable(testwm2 testwm2.c)
add_sdl_test_executable(testyuv NEEDS_RESOURCES testyuv.c testyuv_cvt.c)
add_sdl_test_executable(torturethread torturethread.c)
add_sdl_test_executable(testrendercopyex NEEDS_RESOURCES testrendercopyex.c testutils.c)
add_sdl_test_executable(testmessage testmessage.c)
add_sdl_test_executable(testdisplayinfo NOTRACKMEM testdisplayinfo.c)
add_sdl_test_executable(testqsort NOTRACKMEM NONINTERACTIVE testqsort.c)
add_sdl_test_executable(testbounds NOTRACKMEM testbounds.c)
add_sdl_test_executable(testdisplayinfo testdisplayinfo.c)
add_sdl_test_executable(testqsort NONINTERACTIVE testqsort.c)
add_sdl_test_executable(testbounds testbounds.c)
add_sdl_test_executable(testcustomcursor testcustomcursor.c)
add_sdl_test_executable(controllermap NEEDS_RESOURCES controllermap.c testutils.c)
add_sdl_test_executable(testvulkan testvulkan.c)
Expand Down
19 changes: 19 additions & 0 deletions test/testatomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <stdio.h>

#include "SDL.h"
#include "SDL_test.h"

/*
Absolutely basic tests just to see if we get the expected value
Expand Down Expand Up @@ -699,9 +700,26 @@ static void RunFIFOTest(SDL_bool lock_free)

int main(int argc, char *argv[])
{
SDLTest_CommonState *state;

state = SDLTest_CommonCreateState(argv, 0);
if (!state) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDLTest_CommonCreateState failed: %s\n", SDL_GetError());
return 1;
}

/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1;
}

if (!SDLTest_CommonInit(state)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}

RunBasicTest();

if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
Expand All @@ -715,6 +733,7 @@ int main(int argc, char *argv[])
RunFIFOTest(SDL_FALSE);
#endif
RunFIFOTest(SDL_TRUE);
SDLTest_CommonQuit(state);
return 0;
}

Expand Down
17 changes: 14 additions & 3 deletions test/testaudioinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
#include <stdio.h>
#include "SDL.h"
#include "SDL_test.h"

static void
print_devices(int iscapture)
Expand Down Expand Up @@ -50,12 +51,22 @@ int main(int argc, char **argv)
char *deviceName = NULL;
SDL_AudioSpec spec;
int n;
SDLTest_CommonState *state;

state = SDLTest_CommonCreateState(argv, SDL_INIT_AUDIO);
if (!state) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDLTest_CommonCreateState failed: %s\n", SDL_GetError());
return 1;
}

/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1;
}

if (!SDLTest_CommonInit(state)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
Expand Down Expand Up @@ -98,6 +109,6 @@ int main(int argc, char **argv)
SDL_Log("SDL_AudioFormat: %X\n", spec.format);
}

SDL_Quit();
SDLTest_CommonQuit(state);
return 0;
}
19 changes: 17 additions & 2 deletions test/testbounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,27 @@
*/

#include "SDL.h"
#include "SDL_test.h"

int main(int argc, char **argv)
{
int total, i;
SDLTest_CommonState *state;

if (SDL_Init(SDL_INIT_VIDEO) < 0) {
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDLTest_CommonCreateState failed: %s\n", SDL_GetError());
return 1;
}

/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1;
}

if (!SDLTest_CommonInit(state)) {
SDL_Log("SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError());
return 1;
}
Expand All @@ -32,7 +47,7 @@ int main(int argc, char **argv)
usable.x, usable.y, usable.w, usable.h);
}

SDL_Quit();
SDLTest_CommonQuit(state);
return 0;
}

Expand Down
17 changes: 14 additions & 3 deletions test/testdisplayinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/* Program to test querying of display info */

#include "SDL.h"
#include "SDL_test.h"

#include <stdio.h>
#include <stdlib.h>
Expand All @@ -33,12 +34,22 @@ int main(int argc, char *argv[])
{
SDL_DisplayMode mode;
int num_displays, dpy;
SDLTest_CommonState *state;

state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDLTest_CommonCreateState failed: %s\n", SDL_GetError());
return 1;
}

/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

/* Load the SDL library */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1;
}

if (!SDLTest_CommonInit(state)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
Expand Down Expand Up @@ -88,7 +99,7 @@ int main(int argc, char *argv[])
SDL_Log("\n");
}

SDL_Quit();
SDLTest_CommonQuit(state);
return 0;
}

Expand Down
17 changes: 14 additions & 3 deletions test/testerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <stdlib.h>

#include "SDL.h"
#include "SDL_test.h"

static int alive = 0;

Expand Down Expand Up @@ -44,12 +45,22 @@ ThreadFunc(void *data)
int main(int argc, char *argv[])
{
SDL_Thread *thread;
SDLTest_CommonState *state;

state = SDLTest_CommonCreateState(argv, 0);
if (!state) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDLTest_CommonCreateState failed: %s\n", SDL_GetError());
return 1;
}

/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

/* Load the SDL library */
if (SDL_Init(0) < 0) {
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1;
}

if (!SDLTest_CommonInit(state)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
Expand All @@ -76,6 +87,6 @@ int main(int argc, char *argv[])

SDL_Log("Main thread error string: %s\n", SDL_GetError());

SDL_Quit();
SDLTest_CommonQuit(state);
return 0;
}
18 changes: 15 additions & 3 deletions test/testfilesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,29 @@

#include <stdio.h>
#include "SDL.h"
#include "SDL_test.h"

int main(int argc, char *argv[])
{
char *base_path;
char *pref_path;
SDLTest_CommonState *state;

state = SDLTest_CommonCreateState(argv, 0);
if (!state) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDLTest_CommonCreateState failed: %s\n", SDL_GetError());
return 1;
}

/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

if (SDL_Init(0) == -1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1;
}

if (!SDLTest_CommonInit(state)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}

Expand Down Expand Up @@ -54,6 +66,6 @@ int main(int argc, char *argv[])
SDL_free(pref_path);
}

SDL_Quit();
SDLTest_CommonQuit(state);
return 0;
}
Loading

0 comments on commit 2ae8b4c

Please sign in to comment.