test: use SDL_test for parsing arguments in all non-interactive tests
This commit is contained in:
parent
47a525610c
commit
2ae8b4c651
21 changed files with 408 additions and 93 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_test.h"
|
||||
|
||||
/*
|
||||
* Watcom C flags these as Warning 201: "Unreachable code" if you just
|
||||
|
@ -445,13 +446,42 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
SDL_bool verbose = SDL_TRUE;
|
||||
int status = 0;
|
||||
int i;
|
||||
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 (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) {
|
||||
verbose = SDL_FALSE;
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (SDL_strcmp("-q", argv[i]) == 0) {
|
||||
verbose = SDL_FALSE;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[-q]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
if (!SDLTest_CommonInit(state)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
SDL_Log("This system is running %s\n", SDL_GetPlatform());
|
||||
}
|
||||
|
@ -462,5 +492,6 @@ int main(int argc, char *argv[])
|
|||
status += TestCPUInfo(verbose);
|
||||
status += TestAssertions(verbose);
|
||||
|
||||
SDLTest_CommonQuit(state);
|
||||
return status;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue