IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38407


Ignore:
Timestamp:
Jun 6, 2015, 10:04:22 AM (11 years ago)
Author:
eugene
Message:

tap-ify typetest

Location:
branches/eam_branches/ohana.20150429/src/libohana
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/libohana/Makefile

    r38377 r38407  
    6666$(TESTPROG) : % : $(TESTBIN)/% $(OBJS)
    6767test: $(TESTPROG)
    68         for i in $(TESTPROG); do $(TESTBIN)/$$i; done
    69 
     68        for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done
     69test.verbose: $(TESTPROG)
     70        for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 |& $(TESTHARNESS) -v; done
  • branches/eam_branches/ohana.20150429/src/libohana/test/typetest.c

    r31663 r38407  
    11# include "ohana.h"
     2# include "tap_ohana.h"
    23
    34enum
    4 {
     5  {
    56    OHANA_LITTLE_ENDIAN = 0x03020100ul,
    67    OHANA_BIG_ENDIAN    = 0x00010203ul,
    7 };
     8  };
    89
    910static const union {
    10     unsigned char bytes[4];
    11     int value;
     11  unsigned char bytes[4];
     12  int value;
    1213} ohana_host_order = { { 0, 1, 2, 3 } };
    1314
     
    1516
    1617// we need to verify some type-related issues:
    17 int main (int argc, char **argv) {
     18int main (void) {
    1819
    19     int status;
     20  plan_tests (4);
    2021
    21     status = 0;
     22  diag ("libohana typetest.c tests");
    2223
    23     // 1) have we defined BYTE_SWAP correctly?
     24  int status = 0;
     25
     26  // 1) have we defined BYTE_SWAP correctly?
    2427
    2528# ifdef BYTE_SWAP
    26     if (OHANA_HOST_ORDER == OHANA_BIG_ENDIAN) {
    27         fprintf (stderr, "ERROR: BYTE_SWAP is defined on a big endian machine\n");
    28         fprintf (stderr, "(see libohana/include/ohana.h)\n");
    29         status = 1;
    30     } else {
    31         fprintf (stderr, "BYTE_SWAP is small endian\n");
    32     }   
     29  ok (OHANA_HOST_ORDER == OHANA_LITTLE_ENDIAN, "BYTE_SWAP defined on small endian hardware (see libohana/include/ohana.h)");
    3330# else
    34     if (OHANA_HOST_ORDER == OHANA_BIG_ENDIAN) {
    35         fprintf (stderr, "NOT_BYTE_SWAP is big endian\n");
    36     } else {
    37         fprintf (stderr, "ERROR: BYTE_SWAP not defined on a small endian machine\n");
    38         fprintf (stderr, "(see libohana/include/ohana.h)\n");
    39         status = 1;
    40     }   
     31  ok (OHANA_HOST_ORDER == OHANA_BIG_ENDIAN, "BYTE_SWAP NOT defined on big endian hardware (see libohana/include/ohana.h)");
    4132# endif
    4233
    43     // 2) have we defined NAN correctly?
    44     {
    45         float fvalue;
    46         double dvalue;
     34  // 2) have we defined NAN correctly?
     35  {
     36    float fvalue;
     37    double dvalue;
    4738   
    48         fvalue = NAN;
    49         dvalue = NAN;
     39    fvalue = NAN;
     40    dvalue = NAN;
    5041
    51         if (isfinite(fvalue)) {
    52             fprintf (stderr, "ERROR: NAN definition fails for float\n");
    53             fprintf (stderr, "fvalue: %e\n", fvalue);
    54             status = 1;
    55         }
    56         if (isfinite(dvalue)) {
    57             fprintf (stderr, "ERROR: NAN definition fails for double\n");
    58             fprintf (stderr, "dvalue: %e\n", dvalue);
    59             status = 1;
    60         }
    61 
    62         fprintf (stderr, "fvalue: %e (isfinite: %d)\n", fvalue, isfinite(fvalue));
    63         fprintf (stderr, "dvalue: %e (isfinite: %d)\n", dvalue, isfinite(dvalue));
     42    ok (isnan(fvalue), "float  NAN correctly defined");
     43    ok (isnan(dvalue), "double NAN correctly defined");
    6444
    6545# ifdef __STDC_VERSION__
    66         fprintf (stderr, "STDC_VERSION: %ld\n", __STDC_VERSION__);
     46    diag ("STDC_VERSION: %ld\n", __STDC_VERSION__);
    6747# else
    68         fprintf (stderr, "STDC_VERSION is not set\n");
     48    diag ("STDC_VERSION is not set");
    6949# endif
    70     }
     50  }
    7151
    72     // 3) have we defined OFF_T_FMT correctly?
    73     off_t big_value;
     52  // 3) have we defined OFF_T_FMT correctly?  this test should actually raise a compile-time error
     53  off_t big_value = 10;
    7454
    75     big_value = 10;
    76     fprintf (stderr, "this is a big int: "OFF_T_FMT" n'est pas?\n", big_value);
     55  char line[80];
     56  status = snprintf (line, 80, "this is a big int: "OFF_T_FMT" n'est pas?", big_value);
     57  //                            1234567890123456789         0123456789012
     58  ok (status == 32, "correctly formatted an off_t int with %d chars", status);
    7759
    78     // we could move the % out of the FMT and allow constructions like this:
    79     // # define OFF_T_FMT "jd"
    80     // fprintf (stderr, "this is a big int: %06"OFF_T_FMT_ALT" n'est pas?\n", big_value);
    81     // still kind of ugly...
     60  // we could move the % out of the FMT and allow constructions like this:
     61  // # define OFF_T_FMT "jd"
     62  // fprintf (stderr, "this is a big int: %06"OFF_T_FMT_ALT" n'est pas?\n", big_value);
     63  // still kind of ugly...
    8264
    83     exit (status);
     65  fprintf (stderr, "max float:  %e\n", FLT_MAX);
     66  fprintf (stderr, "max double: %e\n", DBL_MAX);
     67  fprintf (stderr, "min float:  %e\n", FLT_MIN);
     68  fprintf (stderr, "min double: %e\n", DBL_MIN);
     69
     70  return exit_status();
    8471}
Note: See TracChangeset for help on using the changeset viewer.