2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
20 #include "testautomation_suites.h"
22 static SDLTest_CommonState *state;
24 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
28 SDLTest_CommonQuit(state);
32 main(int argc, char *argv[])
34 SDL_Log("====In testautomation====");
36 int testIterations = 1;
37 Uint64 userExecKey = 0;
38 char *userRunSeed = NULL;
43 /* Initialize test framework */
44 state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
49 /* Parse commandline */
50 for (i = 1; i < argc;) {
53 consumed = SDLTest_CommonArg(state, i);
56 if (SDL_strcasecmp(argv[i], "--iterations") == 0) {
58 testIterations = SDL_atoi(argv[i + 1]);
59 if (testIterations < 1) testIterations = 1;
63 else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
65 SDL_sscanf(argv[i + 1], "%"SDL_PRIu64, (long long unsigned int *)&userExecKey);
69 else if (SDL_strcasecmp(argv[i], "--seed") == 0) {
71 userRunSeed = SDL_strdup(argv[i + 1]);
75 else if (SDL_strcasecmp(argv[i], "--filter") == 0) {
77 filter = SDL_strdup(argv[i + 1]);
83 SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
84 argv[0], SDLTest_CommonUsage(state));
91 /* Initialize common state */
92 if (!SDLTest_CommonInit(state)) {
96 /* Create the windows, initialize the renderers */
97 for (i = 0; i < state->num_windows; ++i) {
98 SDL_Renderer *renderer = state->renderers[i];
99 SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
100 SDL_RenderClear(renderer);
104 result = SDLTest_RunSuites(testSuites, (const char *)userRunSeed, userExecKey, (const char *)filter, testIterations);
106 /* Empty event queue */
108 for (i=0; i<100; i++) {
109 while (SDL_PollEvent(&event)) {
110 SDLTest_CommonEvent(state, &event, &done);
116 SDL_free(userRunSeed);
119 /* Shutdown everything */
123 /* vi: set ts=4 sw=4 expandtab: */