Changeset 8958
- Timestamp:
- Sep 25, 2006, 1:52:41 PM (20 years ago)
- Location:
- trunk/psLib/test
- Files:
-
- 13 edited
-
astro/Makefile.am (modified) (1 diff)
-
db/Makefile.am (modified) (1 diff)
-
fft/Makefile.am (modified) (1 diff)
-
fits/Makefile.am (modified) (1 diff)
-
imageops/Makefile.am (modified) (1 diff)
-
jpeg/Makefile.am (modified) (1 diff)
-
math/Makefile.am (modified) (1 diff)
-
mathtypes/Makefile.am (modified) (1 diff)
-
sys/Makefile.am (modified) (1 diff)
-
tap/configure.in (modified) (2 diffs)
-
tap/src/tap.c (modified) (13 diffs)
-
types/Makefile.am (modified) (1 diff)
-
xml/Makefile.am (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astro/Makefile.am
r8841 r8958 17 17 if BUILD_TESTS 18 18 bin_PROGRAMS = $(TEST_PROGS) 19 TESTS = $(TEST_PROGS) 19 20 else 20 21 check_PROGRAMS = $(TEST_PROGS) 21 22 endif 22 TESTS = $(TEST_PROGS)23 23 24 24 CLEANFILES = $(check_DATA) temp/* core core.* *~ *.bb *.bbg *.da gmon.out -
trunk/psLib/test/db/Makefile.am
r8841 r8958 9 9 if BUILD_TESTS 10 10 bin_PROGRAMS = $(TEST_PROGS) 11 TESTS = $(TEST_PROGS) 11 12 else 12 13 check_PROGRAMS = $(TEST_PROGS) 13 14 endif 14 TESTS = $(TEST_PROGS)15 15 16 16 CLEANFILES = $(check_DATA) temp/* core core.* *~ *.bb *.bbg *.da gmon.out -
trunk/psLib/test/fft/Makefile.am
r8841 r8958 9 9 if BUILD_TESTS 10 10 bin_PROGRAMS = $(TEST_PROGS) 11 TESTS = $(TEST_PROGS) 11 12 else 12 13 check_PROGRAMS = $(TEST_PROGS) 13 14 endif 14 TESTS = $(TEST_PROGS)15 15 16 16 CLEANFILES = $(check_DATA) temp/* core core.* *~ *.bb *.bbg *.da gmon.out -
trunk/psLib/test/fits/Makefile.am
r8841 r8958 9 9 if BUILD_TESTS 10 10 bin_PROGRAMS = $(TEST_PROGS) 11 TESTS = $(TEST_PROGS) 11 12 else 12 13 check_PROGRAMS = $(TEST_PROGS) 13 14 endif 14 TESTS = $(TEST_PROGS)15 15 16 16 CLEANFILES = $(check_DATA) temp/* multi.fits table.fits tmpImages/* core core.* *~ \ -
trunk/psLib/test/imageops/Makefile.am
r8841 r8958 9 9 if BUILD_TESTS 10 10 bin_PROGRAMS = $(TEST_PROGS) 11 TESTS = $(TEST_PROGS) 11 12 else 12 13 check_PROGRAMS = $(TEST_PROGS) 13 14 endif 14 TESTS = $(TEST_PROGS)15 15 16 16 CLEANFILES = $(check_DATA) temp/* fOut.fits sOut.fits fBiOut.fits sBiOut.fits \ -
trunk/psLib/test/jpeg/Makefile.am
r8841 r8958 9 9 if BUILD_TESTS 10 10 bin_PROGRAMS = $(TEST_PROGS) 11 TESTS = $(TEST_PROGS) 11 12 else 12 13 check_PROGRAMS = $(TEST_PROGS) 13 14 endif 14 TESTS = $(TEST_PROGS)15 15 16 16 CLEANFILES = $(check_DATA) core core.* *~ *.bb *.bbg *.da gmon.out -
trunk/psLib/test/math/Makefile.am
r8841 r8958 9 9 if BUILD_TESTS 10 10 bin_PROGRAMS = $(TEST_PROGS) 11 TESTS = $(TEST_PROGS) 11 12 else 12 13 check_PROGRAMS = $(TEST_PROGS) 13 14 endif 14 TESTS = $(TEST_PROGS)15 15 16 16 CLEANFILES = $(check_DATA) temp/* seed_msglog1.txt core core.* *~ *.bb *.bbg *.da gmon.out -
trunk/psLib/test/mathtypes/Makefile.am
r8841 r8958 15 15 if BUILD_TESTS 16 16 bin_PROGRAMS = $(TEST_PROGS) 17 TESTS = $(TEST_PROGS) 17 18 else 18 19 check_PROGRAMS = $(TEST_PROGS) 19 20 endif 20 TESTS = $(TEST_PROGS)21 21 22 22 CLEANFILES = $(check_DATA) temp/* core core.* *~ *.bb *.bbg *.da gmon.out -
trunk/psLib/test/sys/Makefile.am
r8841 r8958 15 15 if BUILD_TESTS 16 16 bin_PROGRAMS = $(TEST_PROGS) 17 TESTS = $(TEST_PROGS) 17 18 else 18 19 check_PROGRAMS = $(TEST_PROGS) 19 20 endif 20 TESTS = $(TEST_PROGS)21 21 22 22 CLEANFILES = $(check_DATA) temp/* log.txt log2.txt test.fits tst_psTrace02_OUT \ -
trunk/psLib/test/tap/configure.in
r8841 r8958 3 3 AM_INIT_AUTOMAKE([foreign]) 4 4 AC_CONFIG_HEADERS([src/config.h]) 5 AC_GNU_SOURCE 5 6 AC_PROG_CC 6 7 AC_PROG_LIBTOOL … … 40 41 AC_CONFIG_FILES([Makefile 41 42 src/Makefile 42 tests/Makefile43 tests/diag/Makefile44 tests/fail/Makefile45 tests/ok/Makefile46 tests/ok/ok-hash/Makefile47 tests/ok/ok-numeric/Makefile48 tests/ok/ok/Makefile49 tests/pass/Makefile50 tests/plan/Makefile51 tests/plan/no-tests/Makefile52 tests/plan/no_plan/Makefile53 tests/plan/not-enough-tests/Makefile54 tests/plan/sane/Makefile55 tests/plan/skip_all/Makefile56 tests/plan/too-many-plans/Makefile57 tests/plan/too-many-tests/Makefile58 tests/skip/Makefile59 tests/todo/Makefile60 43 ]) 61 44 AC_OUTPUT -
trunk/psLib/test/tap/src/tap.c
r7775 r8958 25 25 */ 26 26 27 #ifdef HAVE_CONFIG_H 28 #include <config.h> 29 #endif 30 27 31 #include <ctype.h> 28 32 #include <stdarg.h> … … 67 71 */ 68 72 unsigned int 69 _gen_result(int ok, const char *func, char *file, unsigned int line, 70 char *test_name, ...)71 { 72 va_list ap;73 char *local_test_name = NULL;74 char *c;75 int name_is_digits;76 77 LOCK;78 79 test_count++;80 81 /* Start by taking the test name and performing any printf()82 expansions on it */83 if(test_name != NULL) {84 va_start(ap, test_name);85 vasprintf(&local_test_name, test_name, ap);86 va_end(ap);87 88 /* Make sure the test name contains more than digits89 and spaces. Emit an error message and exit if it90 does */91 if(local_test_name) {92 name_is_digits = 1;93 for(c = local_test_name; *c != '\0'; c++) {94 if(!isdigit(*c) && !isspace(*c)) {95 name_is_digits = 0;96 break;97 }98 }99 100 if(name_is_digits) {101 diag(" You named your test '%s'. You shouldn't use numbers for your test names.", local_test_name);102 diag(" Very confusing.");103 }104 }105 }106 107 if(!ok) {108 printf("not ");109 failures++;110 }111 112 printf("ok %d", test_count);113 114 if(test_name != NULL) {115 printf(" - ");116 117 /* Print the test name, escaping any '#' characters it118 might contain */119 if(local_test_name != NULL) {120 flockfile(stdout);121 for(c = local_test_name; *c != '\0'; c++) {122 if(*c == '#')123 fputc('\\', stdout);124 fputc((int)*c, stdout);125 }126 funlockfile(stdout);127 } else {/* vasprintf() failed, use a fixed message */128 printf("%s", todo_msg_fixed);129 }130 }131 132 /* If we're in a todo_start() block then flag the test as being133 TODO. todo_msg should contain the message to print at this134 point. If it's NULL then asprintf() failed, and we should135 use the fixed message.136 137 This is not counted as a failure, so decrement the counter if138 the test failed. */139 if(todo) {140 printf(" # TODO %s", todo_msg ? todo_msg : todo_msg_fixed);141 if(!ok)142 failures--;143 }144 145 printf("\n");146 147 if(!ok) {148 if(getenv("HARNESS_ACTIVE") != NULL)149 fputs("\n", stderr);150 151 diag(" Failed %stest (%s:%s() at line %d)", 152 todo ? "(TODO) " : "", file, func, line);153 }154 free(local_test_name);155 156 UNLOCK;157 158 /* We only care (when testing) that ok is positive, but here we159 specifically only want to return 1 or 0 */160 return ok ? 1 : 0;73 _gen_result(int ok, const char *func, char *file, unsigned int line, 74 char *test_name, ...) 75 { 76 va_list ap; 77 char *local_test_name = NULL; 78 char *c; 79 int name_is_digits; 80 81 LOCK; 82 83 test_count++; 84 85 /* Start by taking the test name and performing any printf() 86 expansions on it */ 87 if(test_name != NULL) { 88 va_start(ap, test_name); 89 vasprintf(&local_test_name, test_name, ap); 90 va_end(ap); 91 92 /* Make sure the test name contains more than digits 93 and spaces. Emit an error message and exit if it 94 does */ 95 if(local_test_name) { 96 name_is_digits = 1; 97 for(c = local_test_name; *c != '\0'; c++) { 98 if(!isdigit(*c) && !isspace(*c)) { 99 name_is_digits = 0; 100 break; 101 } 102 } 103 104 if(name_is_digits) { 105 diag(" You named your test '%s'. You shouldn't use numbers for your test names.", local_test_name); 106 diag(" Very confusing."); 107 } 108 } 109 } 110 111 if(!ok) { 112 printf("not "); 113 failures++; 114 } 115 116 printf("ok %d", test_count); 117 118 if(test_name != NULL) { 119 printf(" - "); 120 121 /* Print the test name, escaping any '#' characters it 122 might contain */ 123 if(local_test_name != NULL) { 124 flockfile(stdout); 125 for(c = local_test_name; *c != '\0'; c++) { 126 if(*c == '#') 127 fputc('\\', stdout); 128 fputc((int)*c, stdout); 129 } 130 funlockfile(stdout); 131 } else { /* vasprintf() failed, use a fixed message */ 132 printf("%s", todo_msg_fixed); 133 } 134 } 135 136 /* If we're in a todo_start() block then flag the test as being 137 TODO. todo_msg should contain the message to print at this 138 point. If it's NULL then asprintf() failed, and we should 139 use the fixed message. 140 141 This is not counted as a failure, so decrement the counter if 142 the test failed. */ 143 if(todo) { 144 printf(" # TODO %s", todo_msg ? todo_msg : todo_msg_fixed); 145 if(!ok) 146 failures--; 147 } 148 149 printf("\n"); 150 151 if(!ok) { 152 if(getenv("HARNESS_ACTIVE") != NULL) 153 fputs("\n", stderr); 154 155 diag(" Failed %stest (%s:%s() at line %d)", 156 todo ? "(TODO) " : "", file, func, line); 157 } 158 free(local_test_name); 159 160 UNLOCK; 161 162 /* We only care (when testing) that ok is positive, but here we 163 specifically only want to return 1 or 0 */ 164 return ok ? 1 : 0; 161 165 } 162 166 … … 168 172 _tap_init(void) 169 173 { 170 static int run_once = 0;171 172 if(!run_once) {173 atexit(_cleanup);174 175 /* stdout needs to be unbuffered so that the output appears176 in the same place relative to stderr output as it does177 with Test::Harness */178 setbuf(stdout, 0);179 run_once = 1;180 }174 static int run_once = 0; 175 176 if(!run_once) { 177 atexit(_cleanup); 178 179 /* stdout needs to be unbuffered so that the output appears 180 in the same place relative to stderr output as it does 181 with Test::Harness */ 182 setbuf(stdout, 0); 183 run_once = 1; 184 } 181 185 } 182 186 … … 188 192 { 189 193 190 LOCK;191 192 _tap_init();193 194 if(have_plan != 0) {195 fprintf(stderr, "You tried to plan twice!\n");196 test_died = 1;197 UNLOCK;198 exit(255);199 }200 201 have_plan = 1;202 no_plan = 1;203 204 UNLOCK;205 206 return 1;194 LOCK; 195 196 _tap_init(); 197 198 if(have_plan != 0) { 199 fprintf(stderr, "You tried to plan twice!\n"); 200 test_died = 1; 201 UNLOCK; 202 exit(255); 203 } 204 205 have_plan = 1; 206 no_plan = 1; 207 208 UNLOCK; 209 210 return 1; 207 211 } 208 212 … … 214 218 { 215 219 216 LOCK;217 218 _tap_init();219 220 skip_all = 1;221 222 printf("1..0");223 224 if(reason != NULL)225 printf(" # Skip %s", reason);226 227 printf("\n");228 229 UNLOCK;230 231 exit(0);220 LOCK; 221 222 _tap_init(); 223 224 skip_all = 1; 225 226 printf("1..0"); 227 228 if(reason != NULL) 229 printf(" # Skip %s", reason); 230 231 printf("\n"); 232 233 UNLOCK; 234 235 exit(0); 232 236 } 233 237 … … 239 243 { 240 244 241 LOCK;242 243 _tap_init();244 245 if(have_plan != 0) {246 fprintf(stderr, "You tried to plan twice!\n");247 test_died = 1;248 UNLOCK;249 exit(255);250 }251 252 if(tests == 0) {253 fprintf(stderr, "You said to run 0 tests! You've got to run something.\n");254 test_died = 1;255 UNLOCK;256 exit(255);257 }258 259 have_plan = 1;260 261 _expected_tests(tests);262 263 UNLOCK;264 265 return e_tests;245 LOCK; 246 247 _tap_init(); 248 249 if(have_plan != 0) { 250 fprintf(stderr, "You tried to plan twice!\n"); 251 test_died = 1; 252 UNLOCK; 253 exit(255); 254 } 255 256 if(tests == 0) { 257 fprintf(stderr, "You said to run 0 tests! You've got to run something.\n"); 258 test_died = 1; 259 UNLOCK; 260 exit(255); 261 } 262 263 have_plan = 1; 264 265 _expected_tests(tests); 266 267 UNLOCK; 268 269 return e_tests; 266 270 } 267 271 … … 269 273 diag(char *fmt, ...) 270 274 { 271 va_list ap;272 273 fputs("# ", stderr);274 275 va_start(ap, fmt);276 vfprintf(stderr, fmt, ap);277 va_end(ap);278 279 fputs("\n", stderr);280 281 return 0;275 va_list ap; 276 277 fputs("# ", stderr); 278 279 va_start(ap, fmt); 280 vfprintf(stderr, fmt, ap); 281 va_end(ap); 282 283 fputs("\n", stderr); 284 285 return 0; 282 286 } 283 287 … … 286 290 { 287 291 288 printf("1..%d\n", tests);289 e_tests = tests;292 printf("1..%d\n", tests); 293 e_tests = tests; 290 294 } 291 295 … … 293 297 skip(unsigned int n, char *fmt, ...) 294 298 { 295 va_list ap;296 char *skip_msg;297 298 LOCK;299 300 va_start(ap, fmt);301 asprintf(&skip_msg, fmt, ap);302 va_end(ap);303 304 while(n-- > 0) {305 test_count++;306 printf("ok %d # skip %s\n", test_count, 307 skip_msg != NULL ? 308 skip_msg : "libtap():malloc() failed");309 }310 311 free(skip_msg);312 313 UNLOCK;314 315 return 1;299 va_list ap; 300 char *skip_msg; 301 302 LOCK; 303 304 va_start(ap, fmt); 305 asprintf(&skip_msg, fmt, ap); 306 va_end(ap); 307 308 while(n-- > 0) { 309 test_count++; 310 printf("ok %d # skip %s\n", test_count, 311 skip_msg != NULL ? 312 skip_msg : "libtap():malloc() failed"); 313 } 314 315 free(skip_msg); 316 317 UNLOCK; 318 319 return 1; 316 320 } 317 321 … … 319 323 todo_start(char *fmt, ...) 320 324 { 321 va_list ap;322 323 LOCK;324 325 va_start(ap, fmt);326 vasprintf(&todo_msg, fmt, ap);327 va_end(ap);328 329 todo = 1;330 331 UNLOCK;325 va_list ap; 326 327 LOCK; 328 329 va_start(ap, fmt); 330 vasprintf(&todo_msg, fmt, ap); 331 va_end(ap); 332 333 todo = 1; 334 335 UNLOCK; 332 336 } 333 337 … … 336 340 { 337 341 338 LOCK;339 340 todo = 0;341 free(todo_msg);342 343 UNLOCK;342 LOCK; 343 344 todo = 0; 345 free(todo_msg); 346 347 UNLOCK; 344 348 } 345 349 … … 347 351 exit_status(void) 348 352 { 349 int r;350 351 LOCK;352 353 /* If there's no plan, just return the number of failures */354 if(no_plan || !have_plan) {355 UNLOCK;356 return failures;357 }358 359 /* Ran too many tests? Return the number of tests that were run360 that shouldn't have been */361 if(e_tests < test_count) {362 r = test_count - e_tests;363 UNLOCK;364 return r;365 }366 367 /* Return the number of tests that failed + the number of tests 368 that weren't run */369 r = failures + e_tests - test_count;370 UNLOCK;371 372 return r;353 int r; 354 355 LOCK; 356 357 /* If there's no plan, just return the number of failures */ 358 if(no_plan || !have_plan) { 359 UNLOCK; 360 return failures; 361 } 362 363 /* Ran too many tests? Return the number of tests that were run 364 that shouldn't have been */ 365 if(e_tests < test_count) { 366 r = test_count - e_tests; 367 UNLOCK; 368 return r; 369 } 370 371 /* Return the number of tests that failed + the number of tests 372 that weren't run */ 373 r = failures + e_tests - test_count; 374 UNLOCK; 375 376 return r; 373 377 } 374 378 … … 381 385 { 382 386 383 LOCK;384 385 /* If plan_no_plan() wasn't called, and we don't have a plan,386 and we're not skipping everything, then something happened387 before we could produce any output */388 if(!no_plan && !have_plan && !skip_all) {389 diag("Looks like your test died before it could output anything.");390 UNLOCK;391 return;392 }393 394 if(test_died) {395 diag("Looks like your test died just after %d.", test_count);396 UNLOCK;397 return;398 }399 400 401 /* No plan provided, but now we know how many tests were run, and can402 print the header at the end */403 if(!skip_all && (no_plan || !have_plan)) {404 printf("1..%d\n", test_count);405 }406 407 if((have_plan && !no_plan) && e_tests < test_count) {408 diag("Looks like you planned %d %s but ran %d extra.",409 e_tests, e_tests == 1 ? "test" : "tests", test_count - e_tests);410 UNLOCK;411 return;412 }413 414 if((have_plan || !no_plan) && e_tests > test_count) {415 diag("Looks like you planned %d %s but only ran %d.",416 e_tests, e_tests == 1 ? "test" : "tests", test_count);417 UNLOCK;418 return;419 }420 421 if(failures)422 diag("Looks like you failed %d %s of %d.", 423 failures, failures == 1 ? "test" : "tests", test_count);424 425 UNLOCK;426 } 387 LOCK; 388 389 /* If plan_no_plan() wasn't called, and we don't have a plan, 390 and we're not skipping everything, then something happened 391 before we could produce any output */ 392 if(!no_plan && !have_plan && !skip_all) { 393 diag("Looks like your test died before it could output anything."); 394 UNLOCK; 395 return; 396 } 397 398 if(test_died) { 399 diag("Looks like your test died just after %d.", test_count); 400 UNLOCK; 401 return; 402 } 403 404 405 /* No plan provided, but now we know how many tests were run, and can 406 print the header at the end */ 407 if(!skip_all && (no_plan || !have_plan)) { 408 printf("1..%d\n", test_count); 409 } 410 411 if((have_plan && !no_plan) && e_tests < test_count) { 412 diag("Looks like you planned %d %s but ran %d extra.", 413 e_tests, e_tests == 1 ? "test" : "tests", test_count - e_tests); 414 UNLOCK; 415 return; 416 } 417 418 if((have_plan || !no_plan) && e_tests > test_count) { 419 diag("Looks like you planned %d %s but only ran %d.", 420 e_tests, e_tests == 1 ? "test" : "tests", test_count); 421 UNLOCK; 422 return; 423 } 424 425 if(failures) 426 diag("Looks like you failed %d %s of %d.", 427 failures, failures == 1 ? "test" : "tests", test_count); 428 429 UNLOCK; 430 } -
trunk/psLib/test/types/Makefile.am
r8841 r8958 28 28 if BUILD_TESTS 29 29 bin_PROGRAMS = $(TEST_PROGS) 30 TESTS = $(TEST_PROGS) 30 31 else 31 32 check_PROGRAMS = $(TEST_PROGS) 32 33 endif 33 TESTS = $(TEST_PROGS)34 34 35 35 check_DATA = \ -
trunk/psLib/test/xml/Makefile.am
r8841 r8958 9 9 if BUILD_TESTS 10 10 bin_PROGRAMS = $(TEST_PROGS) 11 TESTS = $(TEST_PROGS) 11 12 else 12 13 check_PROGRAMS = $(TEST_PROGS) 13 14 endif 14 TESTS = $(TEST_PROGS)15 15 16 16 EXTRA_DIST = psTime.xml psTime2.xml psTime3.xml psTime4.xml
Note:
See TracChangeset
for help on using the changeset viewer.
