/[pcsx2_0.9.7]/trunk/3rdparty/SDL-1.3.0-5387/test/automated/testsdl.c
ViewVC logotype

Contents of /trunk/3rdparty/SDL-1.3.0-5387/test/automated/testsdl.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 401 - (show annotations) (download)
Fri Feb 25 17:31:09 2011 UTC (9 years, 11 months ago) by william
File MIME type: text/plain
File size: 4732 byte(s)
Auto Commited Import of: pcsx2-0.9.7-DEBUG (upstream: v0.9.7.4358 local: v0.9.7.313-latest) in ./trunk
1 /*
2 * SDL test suite framework code.
3 *
4 * Written by Edgar Simo "bobbens"
5 *
6 * Released under Public Domain.
7 */
8
9 #include "SDL.h"
10 #include "SDL_at.h"
11
12 #include "platform/platform.h"
13 #include "rwops/rwops.h"
14 #include "rect/rect.h"
15 #include "surface/surface.h"
16 #include "render/render.h"
17 #include "audio/audio.h"
18
19 #if defined(WIN32)
20 #define NO_GETOPT
21 #endif
22 #if defined(__QNXNTO__)
23 #define NO_GETOPT_LONG 1
24 #endif /* __QNXNTO__ */
25
26 #include <stdio.h> /* printf */
27 #include <stdlib.h> /* exit */
28 #ifndef NO_GETOPT
29 #include <unistd.h> /* getopt */
30 #if !defined(NO_GETOPT_LONG)
31 #include <getopt.h> /* getopt_long */
32 #endif /* !NO_GETOPT_LONG */
33 #endif /* !NO_GETOPT */
34
35
36 /*
37 * Tests to run.
38 */
39 static int run_manual = 0; /**< Run manual tests. */
40 /* Manual. */
41 /* Automatic. */
42 static int run_platform = 1; /**< Run platform tests. */
43 static int run_rwops = 1; /**< Run RWops tests. */
44 static int run_rect = 1; /**< Run rect tests. */
45 static int run_surface = 1; /**< Run surface tests. */
46 static int run_render = 1; /**< Run render tests. */
47 static int run_audio = 1; /**< Run audio tests. */
48
49 /*
50 * Prototypes.
51 */
52 static void print_usage( const char *name );
53 static void parse_options( int argc, char *argv[] );
54
55
56 /**
57 * @brief Displays program usage.
58 */
59 static void print_usage( const char *name )
60 {
61 printf("Usage: %s [OPTIONS]\n", name);
62 printf("Options are:\n");
63 printf(" -m, --manual enables tests that require user interaction\n");
64 printf(" --noplatform do not run the platform tests\n");
65 printf(" --norwops do not run the rwops tests\n");
66 printf(" --norect do not run the rect tests\n");
67 printf(" --nosurface do not run the surface tests\n");
68 printf(" --norender do not run the render tests\n");
69 printf(" --noaudio do not run the audio tests\n");
70 printf(" -v, --verbose increases verbosity level by 1 for each -v\n");
71 printf(" -q, --quiet only displays errors\n");
72 printf(" -h, --help display this message and exit\n");
73 }
74
75 /**
76 * @brief Handles the options.
77 */
78 static void parse_options( int argc, char *argv[] )
79 {
80 int i;
81
82 for (i = 1; i < argc; ++i) {
83 const char *arg = argv[i];
84 if (SDL_strcmp(arg, "-m") == 0 || SDL_strcmp(arg, "--manual") == 0) {
85 run_manual = 1;
86 continue;
87 }
88 if (SDL_strcmp(arg, "-v") == 0 || SDL_strcmp(arg, "--verbose") == 0) {
89 int level;
90 SDL_ATgeti( SDL_AT_VERBOSE, &level );
91 SDL_ATseti( SDL_AT_VERBOSE, level+1 );
92 continue;
93 }
94 if (SDL_strcmp(arg, "-q") == 0 || SDL_strcmp(arg, "--quiet") == 0) {
95 SDL_ATseti( SDL_AT_QUIET, 1 );
96 SDL_setenv("SDL_ASSERT", "abort", 0);
97 continue;
98 }
99 if (SDL_strcmp(arg, "--noplatform") == 0) {
100 run_platform = 0;
101 continue;
102 }
103 if (SDL_strcmp(arg, "--norwops") == 0) {
104 run_rwops = 0;
105 continue;
106 }
107 if (SDL_strcmp(arg, "--norect") == 0) {
108 run_rect = 0;
109 continue;
110 }
111 if (SDL_strcmp(arg, "--nosurface") == 0) {
112 run_surface = 0;
113 continue;
114 }
115 if (SDL_strcmp(arg, "--norender") == 0) {
116 run_render = 0;
117 continue;
118 }
119 if (SDL_strcmp(arg, "--noaudio") == 0) {
120 run_audio = 0;
121 continue;
122 }
123
124 /* Print help and exit! */
125 print_usage( argv[0] );
126 exit(EXIT_FAILURE);
127 }
128 }
129
130 /**
131 * @brief Main entry point.
132 */
133 int main( int argc, char *argv[] )
134 {
135 int failed;
136 const char *rev;
137 SDL_version ver;
138
139 /* Get options. */
140 parse_options( argc, argv );
141
142 /* Defaults. */
143 failed = 0;
144
145 /* Print some text if verbose. */
146 SDL_GetVersion( &ver );
147 rev = SDL_GetRevision();
148 SDL_ATprintVerbose( 1, "Running tests with SDL %d.%d.%d revision %s\n",
149 ver.major, ver.minor, ver.patch, rev );
150
151 /* Automatic tests. */
152 if (run_platform)
153 failed += test_platform();
154 if (run_rwops)
155 failed += test_rwops();
156 if (run_rect)
157 failed += test_rect();
158 if (run_surface)
159 failed += test_surface();
160 if (run_render)
161 failed += test_render();
162 if (run_audio)
163 failed += test_audio();
164
165 /* Manual tests. */
166 if (run_manual) {
167 }
168
169 /* Display more information if failed. */
170 if (failed > 0) {
171 SDL_ATprintErr( "Tests run with SDL %d.%d.%d revision %d\n",
172 ver.major, ver.minor, ver.patch, rev );
173 SDL_ATprintErr( "System is running %s and is %s endian\n",
174 SDL_GetPlatform(),
175 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
176 "little"
177 #else
178 "big"
179 #endif
180 );
181 }
182
183 return failed;
184 }
185

  ViewVC Help
Powered by ViewVC 1.1.22