test/testautomation.c
changeset 6756 398073b195bb
child 6757 9935f71c8c81
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/testautomation.c	Fri Dec 14 23:05:34 2012 -0800
     1.3 @@ -0,0 +1,101 @@
     1.4 +/*
     1.5 +  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     1.6 +
     1.7 +  This software is provided 'as-is', without any express or implied
     1.8 +  warranty.  In no event will the authors be held liable for any damages
     1.9 +  arising from the use of this software.
    1.10 +
    1.11 +  Permission is granted to anyone to use this software for any purpose,
    1.12 +  including commercial applications, and to alter it and redistribute it
    1.13 +  freely.
    1.14 +*/
    1.15 +
    1.16 +#include <stdlib.h>
    1.17 +#include <stdio.h>
    1.18 +#include <time.h>
    1.19 +
    1.20 +#include "SDL.h"
    1.21 +#include "SDL_test.h"
    1.22 +
    1.23 +#include "tests/testsuites.h"
    1.24 +
    1.25 +static SDLTest_CommonState *state;
    1.26 +
    1.27 +
    1.28 +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    1.29 +static void
    1.30 +quit(int rc)
    1.31 +{
    1.32 +    SDLTest_CommonQuit(state);
    1.33 +    exit(rc);
    1.34 +}
    1.35 +
    1.36 +int
    1.37 +main(int argc, char *argv[])
    1.38 +{
    1.39 +    int result;
    1.40 +    int i;
    1.41 +
    1.42 +    /* Initialize test framework */
    1.43 +    state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
    1.44 +    if (!state) {
    1.45 +        return 1;
    1.46 +    }
    1.47 +
    1.48 +    // Needed?
    1.49 +    // state->window_flags |= SDL_WINDOW_RESIZABLE;
    1.50 +
    1.51 +    /* Parse commandline */
    1.52 +    for (i = 1; i < argc;) {
    1.53 +        int consumed;
    1.54 +
    1.55 +        consumed = SDLTest_CommonArg(state, i);
    1.56 +        if (consumed == 0) {
    1.57 +            consumed = -1;
    1.58 +/* Parse additional parameters
    1.59 +
    1.60 +            if (SDL_strcasecmp(argv[i], "--BLAH") == 0) {
    1.61 +                if (argv[i + 1]) {
    1.62 +                    if (SDL_strcasecmp(argv[i + 1], "BLUB") == 0) {
    1.63 +                        blah = blub;
    1.64 +                        consumed = 2;
    1.65 +                    }
    1.66 +                }
    1.67 +            } else if (SDL_strcasecmp(argv[i], "--BINGO") == 0) {
    1.68 +                bingo = SDL_TRUE;
    1.69 +                consumed = 1;
    1.70 +            }
    1.71 +*/
    1.72 +        }
    1.73 +        if (consumed < 0) {
    1.74 +            fprintf(stderr,
    1.75 +                    "Usage: %s %s [--BLAH BLUB --BINGO]\n",
    1.76 +                    argv[0], SDLTest_CommonUsage(state));
    1.77 +            quit(1);
    1.78 +        }
    1.79 +        i += consumed;
    1.80 +    }
    1.81 +
    1.82 +    /* Initialize common state */    
    1.83 +    if (!SDLTest_CommonInit(state)) {
    1.84 +        quit(2);
    1.85 +    }
    1.86 +
    1.87 +    /* Create the windows, initialize the renderers */
    1.88 +    for (i = 0; i < state->num_windows; ++i) {
    1.89 +        SDL_Renderer *renderer = state->renderers[i];
    1.90 +        SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
    1.91 +        SDL_RenderClear(renderer);
    1.92 +    }
    1.93 +
    1.94 +    /* Call Harness */
    1.95 +    // TODO: pass custom parameters
    1.96 +    result = SDLTest_RunSuites(testSuites, NULL, 0, 1);
    1.97 +//int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites, char *userRunSeed, Uint64 userExecKey, int testIterations);
    1.98 +    
    1.99 +    /* Shutdown everything */
   1.100 +    quit(result);        
   1.101 +    return(result);
   1.102 +}
   1.103 +
   1.104 +/* vi: set ts=4 sw=4 expandtab: */