Mercurial > sdl-ios-xcode
annotate test/automated/SDL_at.c @ 3744:216e258f2842 gsoc2009_unit_tests
Added more verbosity for platform test.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Mon, 03 Aug 2009 18:28:01 +0000 |
parents | 808fad5fb593 |
children | be037e51f080 |
rev | line source |
---|---|
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1 /* |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
2 * Common code for automated test suite. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
3 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
4 * Written by Edgar Simo "bobbens" |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
5 * |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
6 * Released under Public Domain. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
7 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
8 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
9 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
10 #include "SDL_at.h" |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
11 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
12 #include <stdio.h> |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
13 #include <stdarg.h> |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
14 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
15 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
16 /* |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
17 * Internal usage SDL_AT variables. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
18 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
19 static const char *at_suite_msg = NULL; /**< Testsuite message. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
20 static const char *at_test_msg = NULL; /**< Testcase message. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
21 static int at_success = 0; /**< Number of successful testcases. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
22 static int at_failure = 0; /**< Number of failed testcases. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
23 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
24 |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
25 /* |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
26 * Global properties. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
27 */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
28 static int at_verbose = 0; /**< Verbosity. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
29 static int at_quiet = 0; /**< Quietness. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
30 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
31 |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
32 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
33 * @brief Cleans up the automated testsuite state. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
34 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
35 static void SDL_ATcleanup (void) |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
36 { |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
37 at_suite_msg = NULL; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
38 at_test_msg = NULL; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
39 at_success = 0; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
40 at_failure = 0; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
41 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
42 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
43 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
44 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
45 * @brief Begin testsuite. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
46 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
47 void SDL_ATinit( const char *suite ) |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
48 { |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
49 /* Do not open twice. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
50 if (at_suite_msg) { |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
51 SDL_ATprintErr( "AT suite '%s' not closed before opening suite '%s'\n", |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
52 at_suite_msg, suite ); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
53 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
54 /* Must have a name. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
55 if (suite == NULL) { |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
56 SDL_ATprintErr( "AT testsuite does not have a name.\n"); |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
57 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
58 SDL_ATcleanup(); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
59 at_suite_msg = suite; |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
60 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
61 /* Verbose message. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
62 SDL_ATprintVerbose( 2, "--+---> Started Test Suite '%s'\n", suite ); |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
63 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
64 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
65 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
66 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
67 * @brief Finish testsuite. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
68 */ |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
69 int SDL_ATfinish (void) |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
70 { |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
71 int failed; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
72 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
73 /* Make sure initialized. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
74 if (at_suite_msg == NULL) { |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
75 SDL_ATprintErr("Ended testcase without initializing.\n"); |
3722
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3713
diff
changeset
|
76 return 1; |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
77 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
78 |
3725
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
79 /* Finished without closing testcase. */ |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
80 if (at_test_msg) { |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
81 SDL_ATprintErr( "AT suite '%s' finished without closing testcase '%s'\n", |
3727
51900b161948
Fixed accidentle broken compile.
Edgar Simo <bobbens@gmail.com>
parents:
3725
diff
changeset
|
82 at_suite_msg, at_test_msg ); |
3725
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
83 } |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
84 |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
85 /* Verbose message. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
86 SDL_ATprintVerbose( 2, "<-+---- Finished Test Suite '%s'\n", at_suite_msg ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
87 |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
88 /* Display message if verbose on failed. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
89 failed = at_failure; |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
90 if (at_failure > 0) { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
91 SDL_ATprintErr( "%s : Failed %d out of %d testcases!\n", |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
92 at_suite_msg, at_failure, at_failure+at_success ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
93 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
94 else { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
95 SDL_ATprint( "%s : All tests successful (%d)\n", |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
96 at_suite_msg, at_success ); |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
97 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
98 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
99 /* Clean up. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
100 SDL_ATcleanup(); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
101 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
102 /* Return failed. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
103 return failed; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
104 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
105 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
106 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
107 /** |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
108 * @brief Sets a property. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
109 */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
110 void SDL_ATseti( int property, int value ) |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
111 { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
112 switch (property) { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
113 case SDL_AT_VERBOSE: |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
114 at_verbose = value; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
115 break; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
116 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
117 case SDL_AT_QUIET: |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
118 at_quiet = value; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
119 break; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
120 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
121 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
122 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
123 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
124 /** |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
125 * @brief Gets a property. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
126 */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
127 void SDL_ATgeti( int property, int *value ) |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
128 { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
129 switch (property) { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
130 case SDL_AT_VERBOSE: |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
131 *value = at_verbose; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
132 break; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
133 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
134 case SDL_AT_QUIET: |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
135 *value = at_quiet; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
136 break; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
137 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
138 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
139 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
140 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
141 /** |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
142 * @brief Begin testcase. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
143 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
144 void SDL_ATbegin( const char *testcase ) |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
145 { |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
146 /* Do not open twice. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
147 if (at_test_msg) { |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
148 SDL_ATprintErr( "AT testcase '%s' not closed before opening testcase '%s'\n", |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
149 at_test_msg, testcase ); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
150 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
151 /* Must have a name. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
152 if (testcase == NULL) { |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
153 SDL_ATprintErr( "AT testcase does not have a name.\n"); |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
154 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
155 at_test_msg = testcase; |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
156 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
157 /* Verbose message. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
158 SDL_ATprintVerbose( 2, " +---> StartedTest Case '%s'\n", testcase ); |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
159 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
160 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
161 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
162 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
163 * @brief Ends the testcase with a succes or failure. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
164 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
165 static void SDL_ATendWith( int success ) |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
166 { |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
167 /* Make sure initialized. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
168 if (at_test_msg == NULL) { |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
169 SDL_ATprintErr("Ended testcase without initializing.\n"); |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
170 return; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
171 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
172 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
173 /* Mark as success or failure. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
174 if (success) |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
175 at_success++; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
176 else |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
177 at_failure++; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
178 |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
179 /* Verbose message. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
180 SDL_ATprintVerbose( 2, " +---- Finished Test Case '%s'\n", at_test_msg ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
181 |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
182 /* Clean up. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
183 at_test_msg = NULL; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
184 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
185 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
186 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
187 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
188 * @brief Testcase test. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
189 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
190 int SDL_ATassert( const char *msg, int condition ) |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
191 { |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
192 /* Condition failed. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
193 if (!condition) { |
3725
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
194 /* Print. */ |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
195 SDL_ATprintErr( "%s [%s] : %s\n", at_suite_msg, at_test_msg, msg ); |
3725
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
196 /* End. */ |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
197 SDL_ATendWith(0); |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
198 } |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
199 return !condition; |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
200 } |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
201 |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
202 |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
203 /** |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
204 * @brief Testcase test. |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
205 */ |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
206 int SDL_ATvassert( int condition, const char *msg, ... ) |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
207 { |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
208 va_list args; |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
209 char buf[256]; |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
210 |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
211 /* Condition failed. */ |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
212 if (!condition) { |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
213 /* Get message. */ |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
214 va_start( args, msg ); |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
215 vsnprintf( buf, sizeof(buf), msg, args ); |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
216 va_end( args ); |
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
217 /* Print. */ |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
218 SDL_ATprintErr( "%s [%s] : %s\n", at_suite_msg, at_test_msg, buf ); |
3725
6eca2af6a86b
Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents:
3722
diff
changeset
|
219 /* End. */ |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
220 SDL_ATendWith(0); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
221 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
222 return !condition; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
223 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
224 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
225 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
226 /** |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
227 * @brief End testcase. |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
228 */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
229 void SDL_ATend (void) |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
230 { |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
231 SDL_ATendWith(1); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
232 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
233 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
234 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
235 /** |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
236 * @brief Displays an error. |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
237 */ |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
238 int SDL_ATprintErr( const char *msg, ... ) |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
239 { |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
240 va_list ap; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
241 int ret; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
242 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
243 /* Make sure there is something to print. */ |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
244 if (msg == NULL) |
3722
d8772964e402
Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents:
3713
diff
changeset
|
245 return 0; |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
246 else { |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
247 va_start(ap, msg); |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
248 ret = vfprintf( stderr, msg, ap ); |
3711
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
249 va_end(ap); |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
250 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
251 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
252 return ret; |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
253 } |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
254 |
80839fc6b8e1
First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
255 |
3741
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
256 /** |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
257 * @brief Displays a message. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
258 */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
259 int SDL_ATprint( const char *msg, ... ) |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
260 { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
261 va_list ap; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
262 int ret; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
263 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
264 /* Only print if not quiet. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
265 if (at_quiet) |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
266 return 0; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
267 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
268 /* Make sure there is something to print. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
269 if (msg == NULL) |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
270 return 0; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
271 else { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
272 va_start(ap, msg); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
273 ret = vfprintf( stdout, msg, ap ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
274 va_end(ap); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
275 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
276 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
277 return ret; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
278 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
279 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
280 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
281 /** |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
282 * @brief Displays a verbose message. |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
283 */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
284 int SDL_ATprintVerbose( int level, const char *msg, ... ) |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
285 { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
286 va_list ap; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
287 int ret; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
288 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
289 /* Only print if not quiet. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
290 if (at_quiet || (at_verbose < level)) |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
291 return 0; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
292 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
293 /* Make sure there is something to print. */ |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
294 if (msg == NULL) |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
295 return 0; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
296 else { |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
297 va_start(ap, msg); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
298 ret = vfprintf( stdout, msg, ap ); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
299 va_end(ap); |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
300 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
301 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
302 return ret; |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
303 } |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
304 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
305 |
808fad5fb593
Added command line options.
Edgar Simo <bobbens@gmail.com>
parents:
3727
diff
changeset
|
306 |