test/automated/testsdl.c
branchgsoc2009_unit_tests
changeset 3745 f0b89cf4bffc
parent 3741 808fad5fb593
child 3749 1e277c40babe
     1.1 --- a/test/automated/testsdl.c	Mon Aug 03 18:28:01 2009 +0000
     1.2 +++ b/test/automated/testsdl.c	Tue Aug 04 16:26:43 2009 +0000
     1.3 @@ -18,9 +18,18 @@
     1.4  #include <stdlib.h> /* exit */
     1.5  #include <unistd.h> /* getopt */
     1.6  #include <getopt.h> /* getopt_long */
     1.7 +#include <string.h> /* strcmp */
     1.8  
     1.9  
    1.10  /*
    1.11 + * Tests to run.
    1.12 + */
    1.13 +static int run_platform    = 1;
    1.14 +static int run_rwops       = 1;
    1.15 +static int run_surface     = 1;
    1.16 +static int run_render      = 1;
    1.17 +
    1.18 +/*
    1.19   * Prototypes.
    1.20   */
    1.21  static void print_usage( const char *name );
    1.22 @@ -34,6 +43,10 @@
    1.23  {
    1.24     printf("Usage: %s [OPTIONS]\n", name);
    1.25     printf("Options are:\n");
    1.26 +   printf("   --noplatform    do not run the platform tests\n");
    1.27 +   printf("   --norwops       do not run the rwops tests\n");
    1.28 +   printf("   --nosurface     do not run the surface tests\n");
    1.29 +   printf("   --norender      do not run the render tests\n");
    1.30     printf("   -v, --verbose   increases verbosity level by 1 for each -v\n");
    1.31     printf("   -q, --quiet     only displays errors\n");
    1.32     printf("   -h, --help      display this message and exit\n");
    1.33 @@ -46,6 +59,10 @@
    1.34  static void parse_options( int argc, char *argv[] )
    1.35  {
    1.36     static struct option long_options[] = {
    1.37 +      { "noplatform", no_argument, 0, 0 },
    1.38 +      { "norwops", no_argument, 0, 0 },
    1.39 +      { "nosurface", no_argument, 0, 0 },
    1.40 +      { "norender", no_argument, 0, 0 },
    1.41        { "verbose", no_argument, 0, 'v' },
    1.42        { "quiet", no_argument, 0, 'q' },
    1.43        { "help", no_argument, 0, 'h' },
    1.44 @@ -54,6 +71,7 @@
    1.45     int option_index = 0;
    1.46     int c = 0;
    1.47     int i;
    1.48 +   const char *str;
    1.49  
    1.50     /* Iterate over options. */
    1.51     while ((c = getopt_long( argc, argv,
    1.52 @@ -62,6 +80,18 @@
    1.53  
    1.54        /* Handle options. */
    1.55        switch (c) {
    1.56 +         case 0:
    1.57 +            str = long_options[option_index].name;
    1.58 +            if (strcmp(str,"noplatform")==0)
    1.59 +               run_platform = 0;
    1.60 +            else if (strcmp(str,"norwops")==0)
    1.61 +               run_rwops = 0;
    1.62 +            else if (strcmp(str,"nosurface")==0)
    1.63 +               run_surface = 0;
    1.64 +            else if (strcmp(str,"norender")==0)
    1.65 +               run_render = 0;
    1.66 +            break;
    1.67 +
    1.68  
    1.69           /* Verbosity. */
    1.70           case 'v':
    1.71 @@ -91,10 +121,14 @@
    1.72  {
    1.73     parse_options( argc, argv );
    1.74  
    1.75 -   test_platform();
    1.76 -   test_rwops();
    1.77 -   test_surface();
    1.78 -   test_render();
    1.79 +   if (run_platform)
    1.80 +      test_platform();
    1.81 +   if (run_rwops)
    1.82 +      test_rwops();
    1.83 +   if (run_surface)
    1.84 +      test_surface();
    1.85 +   if (run_render)
    1.86 +      test_render();
    1.87  
    1.88     return 0;
    1.89  }