test/automated/testsdl.c
changeset 3460 ba48701b0534
parent 3319 63d4517fc4ac
child 3482 78db4f7ae2f3
     1.1 --- a/test/automated/testsdl.c	Thu Nov 19 08:44:07 2009 +0000
     1.2 +++ b/test/automated/testsdl.c	Thu Nov 19 09:07:09 2009 +0000
     1.3 @@ -16,11 +16,17 @@
     1.4  #include "render/render.h"
     1.5  #include "audio/audio.h"
     1.6  
     1.7 +#if defined(__QNXNTO__)
     1.8 +#define NO_GETOPT_LONG 1
     1.9 +#endif /* __QNXNTO__ */
    1.10 +
    1.11  #include <stdio.h> /* printf */
    1.12  #include <stdlib.h> /* exit */
    1.13  #include <unistd.h> /* getopt */
    1.14 +#include <string.h> /* strcmp */
    1.15 +#if !defined(NO_GETOPT_LONG)
    1.16  #include <getopt.h> /* getopt_long */
    1.17 -#include <string.h> /* strcmp */
    1.18 +#endif /* !NO_GETOPT_LONG */
    1.19  
    1.20  
    1.21  /*
    1.22 @@ -45,34 +51,53 @@
    1.23  /**
    1.24   * @brief Displays program usage.
    1.25   */
    1.26 +#if !defined(NO_GETOPT_LONG)
    1.27  static void print_usage( const char *name )
    1.28  {
    1.29     printf("Usage: %s [OPTIONS]\n", name);
    1.30     printf("Options are:\n");
    1.31 -   printf("   -m, --manual    enables tests that require user interaction\n");
    1.32 -   printf("   --noplatform    do not run the platform tests\n");
    1.33 -   printf("   --norwops       do not run the rwops tests\n");
    1.34 -   printf("   --nosurface     do not run the surface tests\n");
    1.35 -   printf("   --norender      do not run the render tests\n");
    1.36 -   printf("   --noaudio       do not run the audio tests\n");
    1.37 -   printf("   -v, --verbose   increases verbosity level by 1 for each -v\n");
    1.38 -   printf("   -q, --quiet     only displays errors\n");
    1.39 -   printf("   -h, --help      display this message and exit\n");
    1.40 +   printf("   -m, --manual        enables tests that require user interaction\n");
    1.41 +   printf("   -p, --noplatform    do not run the platform tests\n");
    1.42 +   printf("   -o, --norwops       do not run the rwops tests\n");
    1.43 +   printf("   -s, --nosurface     do not run the surface tests\n");
    1.44 +   printf("   -r, --norender      do not run the render tests\n");
    1.45 +   printf("   -a, --noaudio       do not run the audio tests\n");
    1.46 +   printf("   -v, --verbose       increases verbosity level by 1 for each -v\n");
    1.47 +   printf("   -q, --quiet         only displays errors\n");
    1.48 +   printf("   -h, --help          display this message and exit\n");
    1.49  }
    1.50 +#endif /* !NO_GETOPT_LONG */
    1.51  
    1.52 +#if defined(NO_GETOPT_LONG)
    1.53 +static void print_usage( const char *name )
    1.54 +{
    1.55 +   printf("Usage: %s [OPTIONS]\n", name);
    1.56 +   printf("Options are:\n");
    1.57 +   printf("   -m,     enables tests that require user interaction\n");
    1.58 +   printf("   -p,     do not run the platform tests\n");
    1.59 +   printf("   -o,     do not run the rwops tests\n");
    1.60 +   printf("   -s,     do not run the surface tests\n");
    1.61 +   printf("   -r,     do not run the render tests\n");
    1.62 +   printf("   -a,     do not run the audio tests\n");
    1.63 +   printf("   -v,     increases verbosity level by 1 for each -v\n");
    1.64 +   printf("   -q,     only displays errors\n");
    1.65 +   printf("   -h,     display this message and exit\n");
    1.66 +}
    1.67 +#endif /* NO_GETOPT_LONG */
    1.68  
    1.69  /**
    1.70   * @brief Handles the options.
    1.71   */
    1.72 +#if !defined(NO_GETOPT_LONG)
    1.73  static void parse_options( int argc, char *argv[] )
    1.74  {
    1.75     static struct option long_options[] = {
    1.76        { "manual", no_argument, 0, 'm' },
    1.77 -      { "noplatform", no_argument, 0, 0 },
    1.78 -      { "norwops", no_argument, 0, 0 },
    1.79 -      { "nosurface", no_argument, 0, 0 },
    1.80 -      { "norender", no_argument, 0, 0 },
    1.81 -      { "noaudio", no_argument, 0, 0 },
    1.82 +      { "noplatform", no_argument, 0, 'p' },
    1.83 +      { "norwops", no_argument, 0, 'o' },
    1.84 +      { "nosurface", no_argument, 0, 's' },
    1.85 +      { "norender", no_argument, 0, 'r' },
    1.86 +      { "noaudio", no_argument, 0, 'a' },
    1.87        { "verbose", no_argument, 0, 'v' },
    1.88        { "quiet", no_argument, 0, 'q' },
    1.89        { "help", no_argument, 0, 'h' },
    1.90 @@ -85,7 +110,7 @@
    1.91  
    1.92     /* Iterate over options. */
    1.93     while ((c = getopt_long( argc, argv,
    1.94 -               "vqh",
    1.95 +               "mposravqh",
    1.96                 long_options, &option_index)) != -1) {
    1.97  
    1.98        /* Handle options. */
    1.99 @@ -109,6 +134,31 @@
   1.100              run_manual = 1;
   1.101              break;
   1.102  
   1.103 +         /* No platform. */
   1.104 +         case 'p':
   1.105 +            run_platform = 0;
   1.106 +            break;
   1.107 +
   1.108 +         /* No rwops. */
   1.109 +         case 'o':
   1.110 +            run_rwops = 0;
   1.111 +            break;
   1.112 +
   1.113 +         /* No surface. */
   1.114 +         case 's':
   1.115 +            run_surface = 0;
   1.116 +            break;
   1.117 +
   1.118 +         /* No render. */
   1.119 +         case 'r':
   1.120 +            run_render = 0;
   1.121 +            break;
   1.122 +
   1.123 +         /* No audio. */
   1.124 +         case 'a':
   1.125 +            run_audio = 0;
   1.126 +            break;
   1.127 +
   1.128           /* Verbosity. */
   1.129           case 'v':
   1.130              SDL_ATgeti( SDL_AT_VERBOSE, &i );
   1.131 @@ -126,9 +176,69 @@
   1.132              exit(EXIT_SUCCESS);
   1.133        }
   1.134     }
   1.135 +}
   1.136 +#endif /* !NO_GETOPT_LONG */
   1.137  
   1.138 +#if defined(NO_GETOPT_LONG)
   1.139 +static void parse_options( int argc, char *argv[] )
   1.140 +{
   1.141 +   static char* short_options="mposravqh";
   1.142 +   int c = 0;
   1.143 +   int i;
   1.144 +
   1.145 +   /* Iterate over options. */
   1.146 +   while ((c = getopt(argc, argv, short_options)) != -1) {
   1.147 +      /* Handle options. */
   1.148 +      switch (c) {
   1.149 +         /* Manual. */
   1.150 +         case 'm':
   1.151 +            run_manual = 1;
   1.152 +            break;
   1.153 +
   1.154 +         /* No platform. */
   1.155 +         case 'p':
   1.156 +            run_platform = 0;
   1.157 +            break;
   1.158 +
   1.159 +         /* No rwops. */
   1.160 +         case 'o':
   1.161 +            run_rwops = 0;
   1.162 +            break;
   1.163 +
   1.164 +         /* No surface. */
   1.165 +         case 's':
   1.166 +            run_surface = 0;
   1.167 +            break;
   1.168 +
   1.169 +         /* No render. */
   1.170 +         case 'r':
   1.171 +            run_render = 0;
   1.172 +            break;
   1.173 +
   1.174 +         /* No audio. */
   1.175 +         case 'a':
   1.176 +            run_audio = 0;
   1.177 +            break;
   1.178 +
   1.179 +         /* Verbosity. */
   1.180 +         case 'v':
   1.181 +            SDL_ATgeti( SDL_AT_VERBOSE, &i );
   1.182 +            SDL_ATseti( SDL_AT_VERBOSE, i+1 );
   1.183 +            break;
   1.184 +
   1.185 +         /* Quiet. */
   1.186 +         case 'q':
   1.187 +            SDL_ATseti( SDL_AT_QUIET, 1 );
   1.188 +            break;
   1.189 +
   1.190 +         /* Help. */
   1.191 +         case 'h':
   1.192 +            print_usage( argv[0] );
   1.193 +            exit(EXIT_SUCCESS);
   1.194 +      }
   1.195 +   }
   1.196  }
   1.197 -
   1.198 +#endif /* NO_GETOPT_LONG */
   1.199  
   1.200  /**
   1.201   * @brief Main entry point.