test/testautomation.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Fri, 14 Dec 2012 23:05:34 -0800
changeset 6756 398073b195bb
child 6757 9935f71c8c81
permissions -rw-r--r--
Refactor/fix test lib harness, assert and log component; add harness driver; port platform suite from GSOC code
     1 /*
     2   Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     3 
     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.
     7 
     8   Permission is granted to anyone to use this software for any purpose,
     9   including commercial applications, and to alter it and redistribute it
    10   freely.
    11 */
    12 
    13 #include <stdlib.h>
    14 #include <stdio.h>
    15 #include <time.h>
    16 
    17 #include "SDL.h"
    18 #include "SDL_test.h"
    19 
    20 #include "tests/testsuites.h"
    21 
    22 static SDLTest_CommonState *state;
    23 
    24 
    25 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    26 static void
    27 quit(int rc)
    28 {
    29     SDLTest_CommonQuit(state);
    30     exit(rc);
    31 }
    32 
    33 int
    34 main(int argc, char *argv[])
    35 {
    36     int result;
    37     int i;
    38 
    39     /* Initialize test framework */
    40     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
    41     if (!state) {
    42         return 1;
    43     }
    44 
    45     // Needed?
    46     // state->window_flags |= SDL_WINDOW_RESIZABLE;
    47 
    48     /* Parse commandline */
    49     for (i = 1; i < argc;) {
    50         int consumed;
    51 
    52         consumed = SDLTest_CommonArg(state, i);
    53         if (consumed == 0) {
    54             consumed = -1;
    55 /* Parse additional parameters
    56 
    57             if (SDL_strcasecmp(argv[i], "--BLAH") == 0) {
    58                 if (argv[i + 1]) {
    59                     if (SDL_strcasecmp(argv[i + 1], "BLUB") == 0) {
    60                         blah = blub;
    61                         consumed = 2;
    62                     }
    63                 }
    64             } else if (SDL_strcasecmp(argv[i], "--BINGO") == 0) {
    65                 bingo = SDL_TRUE;
    66                 consumed = 1;
    67             }
    68 */
    69         }
    70         if (consumed < 0) {
    71             fprintf(stderr,
    72                     "Usage: %s %s [--BLAH BLUB --BINGO]\n",
    73                     argv[0], SDLTest_CommonUsage(state));
    74             quit(1);
    75         }
    76         i += consumed;
    77     }
    78 
    79     /* Initialize common state */    
    80     if (!SDLTest_CommonInit(state)) {
    81         quit(2);
    82     }
    83 
    84     /* Create the windows, initialize the renderers */
    85     for (i = 0; i < state->num_windows; ++i) {
    86         SDL_Renderer *renderer = state->renderers[i];
    87         SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
    88         SDL_RenderClear(renderer);
    89     }
    90 
    91     /* Call Harness */
    92     // TODO: pass custom parameters
    93     result = SDLTest_RunSuites(testSuites, NULL, 0, 1);
    94 //int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites, char *userRunSeed, Uint64 userExecKey, int testIterations);
    95     
    96     /* Shutdown everything */
    97     quit(result);        
    98     return(result);
    99 }
   100 
   101 /* vi: set ts=4 sw=4 expandtab: */