annotate test/automated/testsdl.c @ 3750:cb75359d29bb gsoc2009_unit_tests

Missed a few things in the last patch.
author Edgar Simo <bobbens@gmail.com>
date Tue, 04 Aug 2009 18:23:54 +0000
parents 1e277c40babe
children 5b48a529fd8a
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 */
3745
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
21 #include <string.h> /* strcmp */
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
22
3741
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 /*
3745
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
25 * Tests to run.
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
26 */
3749
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
27 static int run_manual = 0; /**< Run manual tests. */
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
28 /* Manual. */
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
29 /* Automatic. */
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
30 static int run_platform = 1; /**< Run platform tests. */
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
31 static int run_rwops = 1; /**< Run RWops tests. */
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
32 static int run_surface = 1; /**< Run surface tests. */
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
33 static int run_render = 1; /**< Run render tests. */
3745
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
34
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
35 /*
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
36 * Prototypes.
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
37 */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
38 static void print_usage( const char *name );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
39 static void parse_options( int argc, char *argv[] );
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 * @brief Displays program usage.
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
44 */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
45 static void print_usage( const char *name )
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
46 {
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
47 printf("Usage: %s [OPTIONS]\n", name);
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
48 printf("Options are:\n");
3750
cb75359d29bb Missed a few things in the last patch.
Edgar Simo <bobbens@gmail.com>
parents: 3749
diff changeset
49 printf(" -m, --manual enables tests that require user interaction\n");
3745
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
50 printf(" --noplatform do not run the platform tests\n");
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
51 printf(" --norwops do not run the rwops tests\n");
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
52 printf(" --nosurface do not run the surface tests\n");
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
53 printf(" --norender do not run the render tests\n");
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
54 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
55 printf(" -q, --quiet only displays errors\n");
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
56 printf(" -h, --help display this message and exit\n");
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
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
59
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
60 /**
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
61 * @brief Handles the options.
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 static void parse_options( int argc, char *argv[] )
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
64 {
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
65 static struct option long_options[] = {
3750
cb75359d29bb Missed a few things in the last patch.
Edgar Simo <bobbens@gmail.com>
parents: 3749
diff changeset
66 { "manual", no_argument, 0, 'm' },
3745
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
67 { "noplatform", no_argument, 0, 0 },
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
68 { "norwops", no_argument, 0, 0 },
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
69 { "nosurface", no_argument, 0, 0 },
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
70 { "norender", no_argument, 0, 0 },
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
71 { "verbose", no_argument, 0, 'v' },
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
72 { "quiet", no_argument, 0, 'q' },
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
73 { "help", no_argument, 0, 'h' },
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
74 {NULL,0,0,0}
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
75 };
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
76 int option_index = 0;
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
77 int c = 0;
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
78 int i;
3745
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
79 const char *str;
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
80
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
81 /* Iterate over options. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
82 while ((c = getopt_long( argc, argv,
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
83 "vqh",
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
84 long_options, &option_index)) != -1) {
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 /* Handle options. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
87 switch (c) {
3745
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
88 case 0:
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
89 str = long_options[option_index].name;
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
90 if (strcmp(str,"noplatform")==0)
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
91 run_platform = 0;
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
92 else if (strcmp(str,"norwops")==0)
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
93 run_rwops = 0;
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
94 else if (strcmp(str,"nosurface")==0)
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
95 run_surface = 0;
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
96 else if (strcmp(str,"norender")==0)
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
97 run_render = 0;
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
98 break;
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
99
3750
cb75359d29bb Missed a few things in the last patch.
Edgar Simo <bobbens@gmail.com>
parents: 3749
diff changeset
100 /* Manual. */
cb75359d29bb Missed a few things in the last patch.
Edgar Simo <bobbens@gmail.com>
parents: 3749
diff changeset
101 case 'm':
cb75359d29bb Missed a few things in the last patch.
Edgar Simo <bobbens@gmail.com>
parents: 3749
diff changeset
102 run_manual = 1;
cb75359d29bb Missed a few things in the last patch.
Edgar Simo <bobbens@gmail.com>
parents: 3749
diff changeset
103 break;
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
104
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
105 /* Verbosity. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
106 case 'v':
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
107 SDL_ATgeti( SDL_AT_VERBOSE, &i );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
108 SDL_ATseti( SDL_AT_VERBOSE, i+1 );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
109 break;
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
110
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
111 /* Quiet. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
112 case 'q':
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
113 SDL_ATseti( SDL_AT_QUIET, 1 );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
114 break;
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
115
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
116 /* Help. */
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
117 case 'h':
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
118 print_usage( argv[0] );
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
119 exit(EXIT_SUCCESS);
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
120 }
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
121 }
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
122
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
123 }
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
124
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
125
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
126 /**
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
127 * @brief Main entry point.
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
128 */
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
129 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
130 {
3741
808fad5fb593 Added command line options.
Edgar Simo <bobbens@gmail.com>
parents: 3740
diff changeset
131 parse_options( argc, argv );
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
132
3749
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
133 /* Automatic tests. */
3745
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
134 if (run_platform)
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
135 test_platform();
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
136 if (run_rwops)
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
137 test_rwops();
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
138 if (run_surface)
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
139 test_surface();
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
140 if (run_render)
f0b89cf4bffc You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
141 test_render();
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
142
3749
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
143 /* Manual tests. */
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
144 if (run_manual) {
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
145 }
1e277c40babe Added placeholder for manual tests.
Edgar Simo <bobbens@gmail.com>
parents: 3745
diff changeset
146
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
147 return 0;
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
148 }
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
149