Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
185 lines (163 loc) · 4.57 KB

File metadata and controls

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