IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8958


Ignore:
Timestamp:
Sep 25, 2006, 1:52:41 PM (20 years ago)
Author:
jhoblitt
Message:

only use TESTS if BUILD_TESTS is set

Location:
trunk/psLib/test
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astro/Makefile.am

    r8841 r8958  
    1717if BUILD_TESTS
    1818bin_PROGRAMS = $(TEST_PROGS)
     19TESTS = $(TEST_PROGS)
    1920else
    2021check_PROGRAMS = $(TEST_PROGS)
    2122endif
    22 TESTS = $(TEST_PROGS)
    2323
    2424CLEANFILES = $(check_DATA) temp/* core core.* *~ *.bb *.bbg *.da gmon.out
  • trunk/psLib/test/db/Makefile.am

    r8841 r8958  
    99if BUILD_TESTS
    1010bin_PROGRAMS = $(TEST_PROGS)
     11TESTS = $(TEST_PROGS)
    1112else
    1213check_PROGRAMS = $(TEST_PROGS)
    1314endif
    14 TESTS = $(TEST_PROGS)
    1515
    1616CLEANFILES = $(check_DATA) temp/* core core.* *~ *.bb *.bbg *.da gmon.out
  • trunk/psLib/test/fft/Makefile.am

    r8841 r8958  
    99if BUILD_TESTS
    1010bin_PROGRAMS = $(TEST_PROGS)
     11TESTS = $(TEST_PROGS)
    1112else
    1213check_PROGRAMS = $(TEST_PROGS)
    1314endif
    14 TESTS = $(TEST_PROGS)
    1515
    1616CLEANFILES = $(check_DATA) temp/* core core.* *~ *.bb *.bbg *.da gmon.out
  • trunk/psLib/test/fits/Makefile.am

    r8841 r8958  
    99if BUILD_TESTS
    1010bin_PROGRAMS = $(TEST_PROGS)
     11TESTS = $(TEST_PROGS)
    1112else
    1213check_PROGRAMS = $(TEST_PROGS)
    1314endif
    14 TESTS = $(TEST_PROGS)
    1515
    1616CLEANFILES = $(check_DATA) temp/* multi.fits table.fits tmpImages/* core core.* *~ \
  • trunk/psLib/test/imageops/Makefile.am

    r8841 r8958  
    99if BUILD_TESTS
    1010bin_PROGRAMS = $(TEST_PROGS)
     11TESTS = $(TEST_PROGS)
    1112else
    1213check_PROGRAMS = $(TEST_PROGS)
    1314endif
    14 TESTS = $(TEST_PROGS)
    1515
    1616CLEANFILES = $(check_DATA) temp/* fOut.fits sOut.fits fBiOut.fits sBiOut.fits \
  • trunk/psLib/test/jpeg/Makefile.am

    r8841 r8958  
    99if BUILD_TESTS
    1010bin_PROGRAMS = $(TEST_PROGS)
     11TESTS = $(TEST_PROGS)
    1112else
    1213check_PROGRAMS = $(TEST_PROGS)
    1314endif
    14 TESTS = $(TEST_PROGS)
    1515
    1616CLEANFILES = $(check_DATA) core core.* *~ *.bb *.bbg *.da gmon.out
  • trunk/psLib/test/math/Makefile.am

    r8841 r8958  
    99if BUILD_TESTS
    1010bin_PROGRAMS = $(TEST_PROGS)
     11TESTS = $(TEST_PROGS)
    1112else
    1213check_PROGRAMS = $(TEST_PROGS)
    1314endif
    14 TESTS = $(TEST_PROGS)
    1515
    1616CLEANFILES = $(check_DATA) temp/* seed_msglog1.txt core core.* *~ *.bb *.bbg *.da gmon.out
  • trunk/psLib/test/mathtypes/Makefile.am

    r8841 r8958  
    1515if BUILD_TESTS
    1616bin_PROGRAMS = $(TEST_PROGS)
     17TESTS = $(TEST_PROGS)
    1718else
    1819check_PROGRAMS = $(TEST_PROGS)
    1920endif
    20 TESTS = $(TEST_PROGS)
    2121
    2222CLEANFILES = $(check_DATA) temp/* core core.* *~ *.bb *.bbg *.da gmon.out
  • trunk/psLib/test/sys/Makefile.am

    r8841 r8958  
    1515if BUILD_TESTS
    1616bin_PROGRAMS = $(TEST_PROGS)
     17TESTS = $(TEST_PROGS)
    1718else
    1819check_PROGRAMS = $(TEST_PROGS)
    1920endif
    20 TESTS = $(TEST_PROGS)
    2121
    2222CLEANFILES = $(check_DATA) temp/* log.txt log2.txt test.fits tst_psTrace02_OUT \
  • trunk/psLib/test/tap/configure.in

    r8841 r8958  
    33AM_INIT_AUTOMAKE([foreign])
    44AC_CONFIG_HEADERS([src/config.h])
     5AC_GNU_SOURCE
    56AC_PROG_CC
    67AC_PROG_LIBTOOL
     
    4041AC_CONFIG_FILES([Makefile
    4142                 src/Makefile
    42                  tests/Makefile
    43                  tests/diag/Makefile
    44                  tests/fail/Makefile
    45                  tests/ok/Makefile
    46                  tests/ok/ok-hash/Makefile
    47                  tests/ok/ok-numeric/Makefile
    48                  tests/ok/ok/Makefile
    49                  tests/pass/Makefile
    50                  tests/plan/Makefile
    51                  tests/plan/no-tests/Makefile
    52                  tests/plan/no_plan/Makefile
    53                  tests/plan/not-enough-tests/Makefile
    54                  tests/plan/sane/Makefile
    55                  tests/plan/skip_all/Makefile
    56                  tests/plan/too-many-plans/Makefile
    57                  tests/plan/too-many-tests/Makefile
    58                  tests/skip/Makefile
    59                  tests/todo/Makefile
    6043                ])
    6144AC_OUTPUT
  • trunk/psLib/test/tap/src/tap.c

    r7775 r8958  
    2525 */
    2626
     27#ifdef HAVE_CONFIG_H
     28#include <config.h>
     29#endif
     30
    2731#include <ctype.h>
    2832#include <stdarg.h>
     
    6771 */
    6872unsigned 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 digits
    89                    and spaces.  Emit an error message and exit if it
    90                    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 it
    118                    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 being
    133            TODO.  todo_msg should contain the message to print at this
    134            point.  If it's NULL then asprintf() failed, and we should
    135            use the fixed message.
    136 
    137            This is not counted as a failure, so decrement the counter if
    138            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 we
    159            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;
    161165}
    162166
     
    168172_tap_init(void)
    169173{
    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 appears
    176                    in the same place relative to stderr output as it does
    177                    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    }
    181185}
    182186
     
    188192{
    189193
    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;
    207211}
    208212
     
    214218{
    215219
    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);
    232236}
    233237
     
    239243{
    240244
    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;
    266270}
    267271
     
    269273diag(char *fmt, ...)
    270274{
    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;
    282286}
    283287
     
    286290{
    287291
    288         printf("1..%d\n", tests);
    289         e_tests = tests;
     292    printf("1..%d\n", tests);
     293    e_tests = tests;
    290294}
    291295
     
    293297skip(unsigned int n, char *fmt, ...)
    294298{
    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;
    316320}
    317321
     
    319323todo_start(char *fmt, ...)
    320324{
    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;
    332336}
    333337
     
    336340{
    337341
    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;
    344348}
    345349
     
    347351exit_status(void)
    348352{
    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 run
    360            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;
    373377}
    374378
     
    381385{
    382386
    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 happened
    387            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 can
    402            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  
    2828if BUILD_TESTS
    2929bin_PROGRAMS = $(TEST_PROGS)
     30TESTS = $(TEST_PROGS)
    3031else
    3132check_PROGRAMS = $(TEST_PROGS)
    3233endif
    33 TESTS = $(TEST_PROGS)
    3434
    3535check_DATA = \
  • trunk/psLib/test/xml/Makefile.am

    r8841 r8958  
    99if BUILD_TESTS
    1010bin_PROGRAMS = $(TEST_PROGS)
     11TESTS = $(TEST_PROGS)
    1112else
    1213check_PROGRAMS = $(TEST_PROGS)
    1314endif
    14 TESTS = $(TEST_PROGS)
    1515
    1616EXTRA_DIST = psTime.xml psTime2.xml psTime3.xml psTime4.xml
Note: See TracChangeset for help on using the changeset viewer.