Mercurial > sdl-ios-xcode
annotate test/automated/testsdl.c @ 3745:f0b89cf4bffc gsoc2009_unit_tests
You can now disable any of the testsuites.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Tue, 04 Aug 2009 16:26:43 +0000 |
parents | 808fad5fb593 |
children | 1e277c40babe |
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 */ |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
27 static int run_platform = 1; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
28 static int run_rwops = 1; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
29 static int run_surface = 1; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
30 static int run_render = 1; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
31 |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
32 /* |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
33 * Prototypes. |
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 static void print_usage( const char *name ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
36 static void parse_options( int argc, char *argv[] ); |
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 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
39 /** |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
40 * @brief Displays program usage. |
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 static void print_usage( const char *name ) |
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 printf("Usage: %s [OPTIONS]\n", name); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
45 printf("Options are:\n"); |
3745
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 printf(" --norender do not run the render tests\n"); |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
50 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
|
51 printf(" -q, --quiet only displays errors\n"); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
52 printf(" -h, --help display this message and exit\n"); |
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 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
55 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
56 /** |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
57 * @brief Handles the options. |
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 static void parse_options( int argc, char *argv[] ) |
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 static struct option long_options[] = { |
3745
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
62 { "noplatform", no_argument, 0, 0 }, |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
63 { "norwops", no_argument, 0, 0 }, |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
64 { "nosurface", no_argument, 0, 0 }, |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
65 { "norender", no_argument, 0, 0 }, |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
66 { "verbose", no_argument, 0, 'v' }, |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
67 { "quiet", no_argument, 0, 'q' }, |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
68 { "help", no_argument, 0, 'h' }, |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
69 {NULL,0,0,0} |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
70 }; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
71 int option_index = 0; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
72 int c = 0; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
73 int i; |
3745
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
74 const char *str; |
3741
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 /* Iterate over options. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
77 while ((c = getopt_long( argc, argv, |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
78 "vqh", |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
79 long_options, &option_index)) != -1) { |
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 /* Handle options. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
82 switch (c) { |
3745
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
83 case 0: |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
84 str = long_options[option_index].name; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
85 if (strcmp(str,"noplatform")==0) |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
86 run_platform = 0; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
87 else if (strcmp(str,"norwops")==0) |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
88 run_rwops = 0; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
89 else if (strcmp(str,"nosurface")==0) |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
90 run_surface = 0; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
91 else if (strcmp(str,"norender")==0) |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
92 run_render = 0; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
93 break; |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
94 |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
95 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
96 /* Verbosity. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
97 case 'v': |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
98 SDL_ATgeti( SDL_AT_VERBOSE, &i ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
99 SDL_ATseti( SDL_AT_VERBOSE, i+1 ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
100 break; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
101 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
102 /* Quiet. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
103 case 'q': |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
104 SDL_ATseti( SDL_AT_QUIET, 1 ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
105 break; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
106 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
107 /* Help. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
108 case 'h': |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
109 print_usage( argv[0] ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
110 exit(EXIT_SUCCESS); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
111 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
112 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
113 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
114 } |
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 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
117 /** |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
118 * @brief Main entry point. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
119 */ |
3740
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
120 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
|
121 { |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3740
diff
changeset
|
122 parse_options( argc, argv ); |
3740
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
123 |
3745
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
124 if (run_platform) |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
125 test_platform(); |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
126 if (run_rwops) |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
127 test_rwops(); |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
128 if (run_surface) |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
129 test_surface(); |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
130 if (run_render) |
f0b89cf4bffc
You can now disable any of the testsuites.
Edgar Simo <bobbens@gmail.com>
parents:
3741
diff
changeset
|
131 test_render(); |
3740
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
132 |
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
133 return 0; |
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
134 } |
e451d5d288e9
Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
135 |