annotate test/automated/testsdl.c @ 3741:808fad5fb593 gsoc2009_unit_tests

Added command line options. Added verbosity levels.
author Edgar Simo <bobbens@gmail.com>
date Sun, 02 Aug 2009 18:58:03 +0000
parents e451d5d288e9
children f0b89cf4bffc
rev   line source
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1 /*
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
2 * SDL test suite framework code.
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
3 *
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
4 * Written by Edgar Simo "bobbens"
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
5 *
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
6 * Released under Public Domain.
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
7 */
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
8
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
9
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
10 #include "SDL_at.h"
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
11
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
12 #include "platform/platform.h"
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
13 #include "rwops/rwops.h"
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
14 #include "surface/surface.h"
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
15 #include "render/render.h"
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
16
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
17 #include <stdio.h> /* printf */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
18 #include <stdlib.h> /* exit */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
19 #include <unistd.h> /* getopt */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
20 #include <getopt.h> /* getopt_long */
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
21
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
22
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
23 /*
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
24 * Prototypes.
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
25 */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
26 static void print_usage( const char *name );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
27 static void parse_options( int argc, char *argv[] );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
28
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
29
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
30 /**
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
31 * @brief Displays program usage.
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
32 */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
33 static void print_usage( const char *name )
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
34 {
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
35 printf("Usage: %s [OPTIONS]\n", name);
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
36 printf("Options are:\n");
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
37 printf(" -v, --verbose increases verbosity level by 1 for each -v\n");
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
38 printf(" -q, --quiet only displays errors\n");
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
39 printf(" -h, --help display this message and exit\n");
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
40 }
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
41
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
42
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
43 /**
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
44 * @brief Handles the options.
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
45 */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
46 static void parse_options( int argc, char *argv[] )
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
47 {
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
48 static struct option long_options[] = {
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
49 { "verbose", no_argument, 0, 'v' },
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
50 { "quiet", no_argument, 0, 'q' },
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
51 { "help", no_argument, 0, 'h' },
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
52 {NULL,0,0,0}
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
53 };
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
54 int option_index = 0;
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
55 int c = 0;
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
56 int i;
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
57
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
58 /* Iterate over options. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
59 while ((c = getopt_long( argc, argv,
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
60 "vqh",
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
61 long_options, &option_index)) != -1) {
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
62
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
63 /* Handle options. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
64 switch (c) {
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
65
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
66 /* Verbosity. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
67 case 'v':
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
68 SDL_ATgeti( SDL_AT_VERBOSE, &i );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
69 SDL_ATseti( SDL_AT_VERBOSE, i+1 );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
70 break;
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
71
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
72 /* Quiet. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
73 case 'q':
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
74 SDL_ATseti( SDL_AT_QUIET, 1 );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
75 break;
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
76
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
77 /* Help. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
78 case 'h':
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
79 print_usage( argv[0] );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
80 exit(EXIT_SUCCESS);
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
81 }
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
82 }
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
83
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
84 }
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
85
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
86
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
87 /**
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
88 * @brief Main entry point.
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
89 */
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
90 int main( int argc, char *argv[] )
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
91 {
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
92 parse_options( argc, argv );
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
93
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
94 test_platform();
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
95 test_rwops();
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
96 test_surface();
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
97 test_render();
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
98
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
99 return 0;
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
100 }
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
101