SDL  2.0
testautomation.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "SDL.h"
#include "SDL_test.h"
#include "testautomation_suites.h"
+ Include dependency graph for testautomation.c:

Go to the source code of this file.

Functions

static void quit (int rc)
 
int main (int argc, char *argv[])
 

Variables

static SDLTest_CommonStatestate
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 33 of file testautomation.c.

34 {
35  int result;
36  int testIterations = 1;
37  Uint64 userExecKey = 0;
38  char *userRunSeed = NULL;
39  char *filter = NULL;
40  int i, done;
42 
43  /* Initialize test framework */
45  if (!state) {
46  return 1;
47  }
48 
49  /* Parse commandline */
50  for (i = 1; i < argc;) {
51  int consumed;
52 
53  consumed = SDLTest_CommonArg(state, i);
54  if (consumed == 0) {
55  consumed = -1;
56  if (SDL_strcasecmp(argv[i], "--iterations") == 0) {
57  if (argv[i + 1]) {
58  testIterations = SDL_atoi(argv[i + 1]);
59  if (testIterations < 1) testIterations = 1;
60  consumed = 2;
61  }
62  }
63  else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
64  if (argv[i + 1]) {
65  SDL_sscanf(argv[i + 1], "%"SDL_PRIu64, (long long unsigned int *)&userExecKey);
66  consumed = 2;
67  }
68  }
69  else if (SDL_strcasecmp(argv[i], "--seed") == 0) {
70  if (argv[i + 1]) {
71  userRunSeed = SDL_strdup(argv[i + 1]);
72  consumed = 2;
73  }
74  }
75  else if (SDL_strcasecmp(argv[i], "--filter") == 0) {
76  if (argv[i + 1]) {
77  filter = SDL_strdup(argv[i + 1]);
78  consumed = 2;
79  }
80  }
81  }
82  if (consumed < 0) {
83  static const char *options[] = { "[--iterations #]", "[--execKey #]", "[--seed string]", "[--filter suite_name|test_name]", NULL };
84  SDLTest_CommonLogUsage(state, argv[0], options);
85  quit(1);
86  }
87 
88  i += consumed;
89  }
90 
91  /* Initialize common state */
92  if (!SDLTest_CommonInit(state)) {
93  quit(2);
94  }
95 
96  /* Create the windows, initialize the renderers */
97  for (i = 0; i < state->num_windows; ++i) {
99  SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
101  }
102 
103  /* Call Harness */
104  result = SDLTest_RunSuites(testSuites, (const char *)userRunSeed, userExecKey, (const char *)filter, testIterations);
105 
106  /* Empty event queue */
107  done = 0;
108  for (i=0; i<100; i++) {
109  while (SDL_PollEvent(&event)) {
111  }
112  SDL_Delay(10);
113  }
114 
115  /* Clean up */
116  SDL_free(userRunSeed);
117  SDL_free(filter);
118 
119  /* Shutdown everything */
120  quit(result);
121  return(result);
122 }

References done, i, NULL, SDLTest_CommonState::num_windows, quit(), renderer, SDLTest_CommonState::renderers, SDL_atoi, SDL_Delay, SDL_free, SDL_INIT_VIDEO, SDL_PollEvent, SDL_PRIu64, SDL_RenderClear, SDL_SetRenderDrawColor, SDL_sscanf, SDL_strcasecmp, SDL_strdup, SDLTest_CommonArg(), SDLTest_CommonCreateState(), SDLTest_CommonEvent(), SDLTest_CommonInit(), SDLTest_CommonLogUsage(), SDLTest_RunSuites(), state, and testSuites.

◆ quit()

static void quit ( int  rc)
static

Definition at line 26 of file testautomation.c.

27 {
29  exit(rc);
30 }

References SDLTest_CommonQuit(), and state.

Referenced by main().

Variable Documentation

◆ state

SDLTest_CommonState* state
static

Definition at line 22 of file testautomation.c.

Referenced by main(), and quit().

SDL_PollEvent
#define SDL_PollEvent
Definition: SDL_dynapi_overrides.h:122
NULL
#define NULL
Definition: begin_code.h:167
state
static SDLTest_CommonState * state
Definition: testautomation.c:22
SDL_PRIu64
#define SDL_PRIu64
Definition: SDL_stdinc.h:238
SDLTest_RunSuites
int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations)
Execute a test suite using the given run seed and execution key.
Definition: SDL_test_harness.c:370
SDLTest_CommonState::renderers
SDL_Renderer ** renderers
Definition: SDL_test_common.h:84
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9435
SDLTest_CommonCreateState
SDLTest_CommonState * SDLTest_CommonCreateState(char **argv, Uint32 flags)
Parse command line parameters and create common state.
Definition: SDL_test_common.c:59
filter
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: SDL_opengl_glext.h:1187
SDL_strcasecmp
#define SDL_strcasecmp
Definition: SDL_dynapi_overrides.h:419
SDLTest_CommonQuit
void SDLTest_CommonQuit(SDLTest_CommonState *state)
Close test window.
Definition: SDL_test_common.c:1910
SDLTest_CommonState::num_windows
int num_windows
Definition: SDL_test_common.h:77
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2652
SDL_Renderer
Definition: SDL_sysrender.h:110
done
int done
Definition: checkkeys.c:28
testSuites
SDLTest_TestSuiteReference * testSuites[]
Definition: testautomation_suites.h:32
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDLTest_CommonArg
int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
Process one common argument.
Definition: SDL_test_common.c:117
SDLTest_CommonLogUsage
void SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const char **options)
Logs command line usage info.
Definition: SDL_test_common.c:498
quit
static void quit(int rc)
Definition: testautomation.c:26
SDL_Delay
#define SDL_Delay
Definition: SDL_dynapi_overrides.h:486
SDL_sscanf
#define SDL_sscanf
Definition: SDL_dynapi_overrides.h:39
SDL_atoi
#define SDL_atoi
Definition: SDL_dynapi_overrides.h:410
SDLTest_CommonInit
SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
Open test window.
Definition: SDL_test_common.c:835
SDL_INIT_VIDEO
#define SDL_INIT_VIDEO
Definition: SDL.h:80
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
Uint64
uint64_t Uint64
Definition: SDL_stdinc.h:216
SDL_RenderClear
#define SDL_RenderClear
Definition: SDL_dynapi_overrides.h:334
SDL_SetRenderDrawColor
#define SDL_SetRenderDrawColor
Definition: SDL_dynapi_overrides.h:330
SDL_strdup
#define SDL_strdup
Definition: SDL_dynapi_overrides.h:397
SDL_Event
General event structure.
Definition: SDL_events.h:559
SDLTest_CommonEvent
void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done)
Common event handler for test windows.
Definition: SDL_test_common.c:1579
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50