summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/SDL2/test/testautomation.c
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-02-27 16:28:05 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2016-02-27 16:53:49 +0100
commitcf6dc7d370407914020f3e623719f09c8668c692 (patch)
tree46b3416d091b4c09b50fba7ffcbd310aed032cc8 /3rdparty/SDL2/test/testautomation.c
parent64135e73f973d9b95beb0c60b65feb34fbfec64a (diff)
Placed SDL2 source since we need it on some platforms (nw)
Diffstat (limited to '3rdparty/SDL2/test/testautomation.c')
-rw-r--r--3rdparty/SDL2/test/testautomation.c124
1 files changed, 124 insertions, 0 deletions
diff --git a/3rdparty/SDL2/test/testautomation.c b/3rdparty/SDL2/test/testautomation.c
new file mode 100644
index 00000000000..eea74b3b864
--- /dev/null
+++ b/3rdparty/SDL2/test/testautomation.c
@@ -0,0 +1,124 @@
+/*
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+
+#include "SDL.h"
+#include "SDL_test.h"
+
+#include "testautomation_suites.h"
+
+static SDLTest_CommonState *state;
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void
+quit(int rc)
+{
+ SDLTest_CommonQuit(state);
+ exit(rc);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int result;
+ int testIterations = 1;
+ Uint64 userExecKey = 0;
+ char *userRunSeed = NULL;
+ char *filter = NULL;
+ int i, done;
+ SDL_Event event;
+
+ /* Initialize test framework */
+ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+ if (!state) {
+ return 1;
+ }
+
+ /* Parse commandline */
+ for (i = 1; i < argc;) {
+ int consumed;
+
+ consumed = SDLTest_CommonArg(state, i);
+ if (consumed == 0) {
+ consumed = -1;
+ if (SDL_strcasecmp(argv[i], "--iterations") == 0) {
+ if (argv[i + 1]) {
+ testIterations = SDL_atoi(argv[i + 1]);
+ if (testIterations < 1) testIterations = 1;
+ consumed = 2;
+ }
+ }
+ else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
+ if (argv[i + 1]) {
+ SDL_sscanf(argv[i + 1], "%"SDL_PRIu64, (long long unsigned int *)&userExecKey);
+ consumed = 2;
+ }
+ }
+ else if (SDL_strcasecmp(argv[i], "--seed") == 0) {
+ if (argv[i + 1]) {
+ userRunSeed = SDL_strdup(argv[i + 1]);
+ consumed = 2;
+ }
+ }
+ else if (SDL_strcasecmp(argv[i], "--filter") == 0) {
+ if (argv[i + 1]) {
+ filter = SDL_strdup(argv[i + 1]);
+ consumed = 2;
+ }
+ }
+ }
+ if (consumed < 0) {
+ SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
+ argv[0], SDLTest_CommonUsage(state));
+ quit(1);
+ }
+
+ i += consumed;
+ }
+
+ /* Initialize common state */
+ if (!SDLTest_CommonInit(state)) {
+ quit(2);
+ }
+
+ /* Create the windows, initialize the renderers */
+ for (i = 0; i < state->num_windows; ++i) {
+ SDL_Renderer *renderer = state->renderers[i];
+ SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
+ SDL_RenderClear(renderer);
+ }
+
+ /* Call Harness */
+ result = SDLTest_RunSuites(testSuites, (const char *)userRunSeed, userExecKey, (const char *)filter, testIterations);
+
+ /* Empty event queue */
+ done = 0;
+ for (i=0; i<100; i++) {
+ while (SDL_PollEvent(&event)) {
+ SDLTest_CommonEvent(state, &event, &done);
+ }
+ SDL_Delay(10);
+ }
+
+ /* Clean up */
+ SDL_free(userRunSeed);
+ SDL_free(filter);
+
+ /* Shutdown everything */
+ quit(result);
+ return(result);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */