IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38427


Ignore:
Timestamp:
Jun 8, 2015, 11:01:33 AM (11 years ago)
Author:
eugene
Message:

tap-ify zlib test code; fix windowBits problem (make libfits compatible with older <= 1.2.3.4 versions of zlib); pass catcompress to subcatalogs; force compress and format updates for catalogs even if they already exist

Location:
branches/eam_branches/ohana.20150429/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/dvomerge/src/dvomergeUpdate_catalogs.c

    r38421 r38427  
    176176
    177177      // if no catalog already exists, use the input catalog to define the format or the specified format
    178       if (outcatalog.Naverage_disk == 0) {
    179         if (UPDATE_CATFORMAT) {
    180           outcatalog.catformat = dvo_catalog_catformat (UPDATE_CATFORMAT);
    181         } else {
    182           outcatalog.catformat = incatalog.catformat;
    183         }
    184         if (UPDATE_CATCOMPRESS) {
    185           outcatalog.catcompress = dvo_catalog_catcompress (UPDATE_CATCOMPRESS);
    186         } else {
    187           outcatalog.catcompress = incatalog.catcompress;
    188         }
     178      if (UPDATE_CATFORMAT) {
     179        outcatalog.catformat = dvo_catalog_catformat (UPDATE_CATFORMAT);
     180      } else {
     181        outcatalog.catformat = incatalog.catformat;
     182      }
     183      if (UPDATE_CATCOMPRESS) {
     184        outcatalog.catcompress = dvo_catalog_catcompress (UPDATE_CATCOMPRESS);
     185      } else {
     186        outcatalog.catcompress = incatalog.catcompress;
    189187      }
    190188
  • branches/eam_branches/ohana.20150429/src/libdvo/src/dvo_catalog_split.c

    r38422 r38427  
    884884
    885885    // write out Measure table
     886    catalog->measure_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api
    886887    if (!dvo_catalog_save_subcat (catalog[0].measure_catalog, &ftable, start, Nrows, catalog[0].Nmeasure_disk, Nmeasure_disk_new)) {
    887888      fprintf (stderr, "trouble writing Measure table\n");
     
    910911
    911912    // write out Missing table (must write out entire table)
     913    catalog->missing_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api
    912914    if (!dvo_catalog_save_subcat (catalog[0].missing_catalog, &ftable, 0, catalog[0].Nmissing, catalog[0].Nmissing, catalog[0].Nmissing)) {
    913915      fprintf (stderr, "trouble writing Missing Table\n");
     
    942944
    943945    // write out SecFilt table
     946    catalog->secfilt_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api
    944947    if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecfilt_disk, Nsecfilt_disk_new)) {
    945948      fprintf (stderr, "failure writing SecFilt table\n");
     
    972975
    973976    // write out Lensing table
     977    catalog->lensing_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api
    974978    if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) {
    975979      fprintf (stderr, "trouble writing Lensing table\n");
     
    10021006
    10031007    // write out Lensobj table
     1008    catalog->lensobj_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api
    10041009    if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) {
    10051010      fprintf (stderr, "trouble writing Lensobj table\n");
     
    10321037
    10331038    // write out StarPar table
     1039    catalog->starpar_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api
    10341040    if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) {
    10351041      fprintf (stderr, "trouble writing StarPar table\n");
     
    10621068
    10631069    // write out GalPhot table
     1070    catalog->galphot_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api
    10641071    if (!dvo_catalog_save_subcat (catalog[0].galphot_catalog, &ftable, start, Nrows, catalog[0].Ngalphot_disk, Ngalphot_disk_new)) {
    10651072      fprintf (stderr, "trouble writing GalPhot table\n");
  • branches/eam_branches/ohana.20150429/src/libfits/Makefile

    r38426 r38427  
    2727
    2828
    29 TESTXTRA = zlib tcomptiming
    30 TESTPROG = imagecomp tablecomp ricetest
     29TESTXTRA = tcomptiming
     30TESTPROG = zlib ricetest imagecomp tablecomp
    3131$(TESTPROG) : % : $(TESTBIN)/%
    3232$(TESTXTRA) : % : $(TESTBIN)/%
  • branches/eam_branches/ohana.20150429/src/libfits/extern/gzip.c

    r38342 r38427  
    119119# define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); }
    120120
    121 // NOTE: CFITSIO uses gzip format, not just zlib
    122 int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
    123 {
     121int gfits_compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) {
     122
    124123  z_stream stream;
    125124  int i, err;
     
    130129  /* Check for source > 64K on 16-bit machine: */
    131130  if ((uLong)stream.avail_in != sourceLen) ESCAPE (Z_BUF_ERROR);
    132  
     131
    133132  stream.next_out = dest;
    134   stream.avail_out = (uInt)*destLen;
     133  stream.avail_out = (uInt)*destLen; // allocated space
    135134  if ((uLong)stream.avail_out != *destLen) ESCAPE (Z_BUF_ERROR);
    136  
     135
    137136  stream.zalloc = Z_NULL;
    138137  stream.zfree  = Z_NULL;
    139138  stream.opaque = Z_NULL;
    140  
    141   if (EXTRA_VERBOSE) {
    142     fprintf (stderr, "inp unc: ");
    143     for (i = 0; i < sourceLen; i++) {
    144       fprintf (stderr, "0x%02hhx ", source[i]);
    145     }
    146     fprintf (stderr, "\n");
    147   }
    148  
    149   // a value of 32 tells inflate to use the window size used in the compression AND to look for both zlib and gzip headers
    150   err = inflateInit2(&stream, 32);
    151   if (err != Z_OK) ESCAPE (err);
    152  
    153   err = inflate(&stream, Z_FINISH);
    154   if (err != Z_STREAM_END) {
    155     inflateEnd(&stream);
    156     if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) ESCAPE (Z_DATA_ERROR);
    157     ESCAPE(err);
    158   }
    159  
    160   if (EXTRA_VERBOSE) {
    161     fprintf (stderr, "out unc: ");
    162     for (i = 0; i < stream.total_out; i++) {
    163       fprintf (stderr, "0x%02hhx ", dest[i]);
    164     }
    165     fprintf (stderr, "\n");
    166   }
    167 
    168   assert (stream.total_out <= *destLen);
    169   *destLen = stream.total_out;
    170 
    171   err = inflateEnd(&stream);
    172   return err;
    173 }
    174 
    175 int gfits_compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
    176 {
    177   z_stream stream;
    178   int i, err;
    179  
    180   stream.next_in = (Bytef*)source;
    181   stream.avail_in = (uInt)sourceLen;
    182 
    183   /* Check for source > 64K on 16-bit machine: */
    184   if ((uLong)stream.avail_in != sourceLen) ESCAPE (Z_BUF_ERROR);
    185 
    186   stream.next_out = dest;
    187   stream.avail_out = (uInt)*destLen; // allocated space
    188   if ((uLong)stream.avail_out != *destLen) ESCAPE (Z_BUF_ERROR);
    189 
    190   stream.zalloc = Z_NULL;
    191   stream.zfree  = Z_NULL;
    192   stream.opaque = Z_NULL;
    193139
    194140  if (EXTRA_VERBOSE) {
     
    203149  // NOTE: cfitsio uses a fixed value of 1
    204150  // I am using deflateInit2 because cfitsio expects gzip, not just zlib
     151  // windowBits = 31 = (15 + 16) = (2^15 window bits) + (create a gzip stream)
    205152  err = deflateInit2(&stream, 1, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY);
    206153  if (0) fprintf (stderr, "inp buffers cmp 0: %d => %d => %d\n", stream.avail_in, stream.avail_out, (int) stream.total_out);
     
    230177  return err;
    231178}
     179
     180// NOTE: CFITSIO uses gzip format, not just zlib
     181int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) {
     182
     183  z_stream stream;
     184  int i, err;
     185 
     186  stream.next_in = (Bytef*)source;
     187  stream.avail_in = (uInt)sourceLen;
     188
     189  /* Check for source > 64K on 16-bit machine: */
     190  if ((uLong)stream.avail_in != sourceLen) ESCAPE (Z_BUF_ERROR);
     191 
     192  stream.next_out = dest;
     193  stream.avail_out = (uInt)*destLen;
     194  if ((uLong)stream.avail_out != *destLen) ESCAPE (Z_BUF_ERROR);
     195 
     196  stream.zalloc = Z_NULL;
     197  stream.zfree  = Z_NULL;
     198  stream.opaque = Z_NULL;
     199 
     200  if (EXTRA_VERBOSE) {
     201    fprintf (stderr, "inp unc: ");
     202    for (i = 0; i < sourceLen; i++) {
     203      fprintf (stderr, "0x%02hhx ", source[i]);
     204    }
     205    fprintf (stderr, "\n");
     206  }
     207 
     208  // windowBits = 47 = (15 + 32) = (2^15 window bits) + (test for either gzip or zlib
     209  // streams).  NOTE: modern versions of zlib (version > 1.2.3.4) allow for windowBits = 0
     210  // (or 16 or 32) to use the compressed stream windowBits value.  IPP cluster still has
     211  // zlib version = 1.2.3, so we cannot use this feature.
     212  err = inflateInit2(&stream, 47);
     213  if (err != Z_OK) ESCAPE (err);
     214 
     215  err = inflate(&stream, Z_FINISH);
     216  if (err != Z_STREAM_END) {
     217    inflateEnd(&stream);
     218    if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) ESCAPE (Z_DATA_ERROR);
     219    ESCAPE(err);
     220  }
     221 
     222  if (EXTRA_VERBOSE) {
     223    fprintf (stderr, "out unc: ");
     224    for (i = 0; i < stream.total_out; i++) {
     225      fprintf (stderr, "0x%02hhx ", dest[i]);
     226    }
     227    fprintf (stderr, "\n");
     228  }
     229
     230  assert (stream.total_out <= *destLen);
     231  *destLen = stream.total_out;
     232
     233  err = inflateEnd(&stream);
     234  return err;
     235}
     236
  • branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c

    r38418 r38427  
    1111int bitpix[] = {8, 16, 32, -32, -64, 0};
    1212
    13 // char *cmptype[] = {"NONE_2", NULL};
    14 // int bitpix[] = {16, 0};
     13//char *cmptype[] = {"GZIP_1", NULL};
     14//int bitpix[] = {16, 0};
    1515
    1616static int NX = 10;
  • branches/eam_branches/ohana.20150429/src/libfits/test/zlib.c

    r38404 r38427  
    1 # include <stdio.h>
    2 # include <stdlib.h>
    3 # include <string.h>
    4 # include <assert.h>
     1# include <ohana.h>
     2# include <gfitsio.h>
    53# include <zlib.h>
    6 
     4# include "tap_ohana.h"
     5
     6# define VERBOSE 0
    77# define NSRC 10
    88# define NTGT 20
     
    1818int main (int argc, char **argv) {
    1919 
     20  plan_tests (7);
     21
     22  diag ("libfits zlib.c tests");
     23
     24  diag ("zlib version: %s", ZLIB_VERSION);
     25  diag ("zlib vernum:  %x", ZLIB_VERNUM);
     26
    2027  int i, err;
    2128  double srcbuf[NSRC], tgtbuf[NTGT], outbuf[NOUT];
     
    4148    }
    4249
    43 # ifdef VERBOSE
    4450    char *rawdata = (char *) srcbuf;
    45     fprintf (stderr, "inp: ");
    46     for (i = 0; i < NSRC*8; i++) {
     51    if (VERBOSE) fprintf (stderr, "inp: ");
     52    for (i = 0; VERBOSE && (i < NSRC*8); i++) {
    4753      fprintf (stderr, "0x%02hhx ", rawdata[i]);
    4854    }
    49     fprintf (stderr, "\n");
    50 # endif
     55    if (VERBOSE) fprintf (stderr, "\n");
    5156
    5257    // the '5' is the compression level: make this a user argument
    5358    err = deflateInit(&zdn, 5);
    54     // fprintf (stderr, "inp buffers cmp 0: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
    55     if (err != Z_OK) { fprintf (stdout, "not ok: error 1: %d vs %d\n", err, Z_OK); exit (1); }
     59    if (VERBOSE) fprintf (stderr, "inp buffers cmp 0: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
     60    ok (err == Z_OK, "result is Z_OK: %d vs %d", err, Z_OK);
    5661 
    5762    err = deflate(&zdn, Z_FINISH);
    58     // fprintf (stderr, "out buffers cmp 1: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
    59     if (err != Z_STREAM_END) { fprintf (stdout, "not ok: error 2: %d vs %d\n", err, Z_STREAM_END); exit (2); }
    60     // fprintf (stderr, "out buffers cmp 2: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
     63    if (VERBOSE) fprintf (stderr, "out buffers cmp 1: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
     64    ok (err == Z_STREAM_END, "result is Z_STREAM_END: %d vs %d", err, Z_STREAM_END);
    6165
    6266    // dump out the data which failed to uncompress (and the input data)
    63 # ifdef VERBOSE
    6467    char *cmpdata = (char *) tgtbuf;
    65     fprintf (stderr, "out: ");
    66     for (i = 0; i < zdn.total_out; i++) {
     68    if (VERBOSE) fprintf (stderr, "out: ");
     69    for (i = 0; VERBOSE && (i < zdn.total_out); i++) {
    6770      fprintf (stderr, "0x%02hhx ", cmpdata[i]);
    6871    }
    69     fprintf (stderr, "\n");
    70 # endif
    71 
    72     assert (zdn.total_out <= NTGT*sizeof(double));
    73 
    74     // fprintf (stderr, "result: %d bytes\n", (int) zdn.total_out);
    75     // for (i = 0; i < zdn.total_out / sizeof(double); i++) {
    76     //   fprintf (stderr, "%d : 0x%02hhx\n", i, tgtbuf[i]);
    77     // }
     72    if (VERBOSE) fprintf (stderr, "\n");
     73
     74    ok (zdn.total_out <= NTGT*sizeof(double), "output compressed size is good");
     75
     76    if (VERBOSE) fprintf (stderr, "result: %d bytes\n", (int) zdn.total_out);
     77    for (i = 0; VERBOSE && (i < zdn.total_out / sizeof(double)); i++) {
     78      fprintf (stderr, "%d : 0x%02hhx\n", i, tgtbuf[i]);
     79    }
    7880  }
    7981
     
    9193    // the '5' is the compression level: make this a user argument
    9294    err = inflateInit(&zup);
    93     // fprintf (stderr, "out buffers unc 0: %d => %d => %d\n", zup.avail_in, zup.avail_out, (int) zup.total_out);
    94     if (err != Z_OK) { fprintf (stdout, "not ok: error 1: %d vs %d\n", err, Z_OK); exit (1); }
     95    if (VERBOSE) fprintf (stderr, "out buffers unc 0: %d => %d => %d\n", zup.avail_in, zup.avail_out, (int) zup.total_out);
     96    ok (err == Z_OK, "result is Z_OK: %d vs %d", err, Z_OK);
    9597 
    9698    err = inflate(&zup, Z_FINISH);
    97     // fprintf (stderr, "out buffers unc 1: %d => %d => %d\n", zup.avail_in, zup.avail_out, (int) zup.total_out);
    98     if (err != Z_STREAM_END) { fprintf (stderr, "error 2: %d vs %d\n", err, Z_STREAM_END); exit (2); }
    99     // fprintf (stderr, "out buffers unc 2: %d => %d => %d\n", zup.avail_in, zup.avail_out, (int) zup.total_out);
    100 
    101 # ifdef VERBOSE
     99    if (VERBOSE) fprintf (stderr, "out buffers unc 1: %d => %d => %d\n", zup.avail_in, zup.avail_out, (int) zup.total_out);
     100    ok (err == Z_STREAM_END, "result is Z_STREAM_END: %d vs %d", err, Z_STREAM_END);
     101
    102102    char *outdata = (char *) outbuf;
    103     fprintf (stderr, "unc: ");
    104     for (i = 0; i < zup.total_out; i++) {
     103    if (VERBOSE) fprintf (stderr, "unc: ");
     104    for (i = 0; VERBOSE && (i < zup.total_out); i++) {
    105105      fprintf (stderr, "0x%02hhx ", outdata[i]);
    106106    }
    107     fprintf (stderr, "\n");
    108 # endif
    109 
    110     assert (zup.total_out <= NTGT*sizeof(double));
    111 
    112     // fprintf (stderr, "result: %d bytes\n", (int) zup.total_out);
     107    if (VERBOSE) fprintf (stderr, "\n");
     108
     109    ok (zup.total_out <= NTGT*sizeof(double), "uncompressed size is good");
     110
     111    int Nbad = 0;
    113112    for (i = 0; 0 && i < zup.total_out / sizeof(double); i++) {
    114       // fprintf (stderr, "%d : %f : %f\n", i, outbuf[i], srcbuf[i]);
    115       assert (outbuf[i] == srcbuf[i]);
    116     }
    117   }
    118 
    119   return exit_status();
    120 }
    121 
    122 int main_old (int argc, char **argv) {
    123  
    124   int i, err;
    125   char srcbuf[NSRC], tgtbuf[NTGT], outbuf[NTGT];
    126  
     113      if (outbuf[i] != srcbuf[i]) Nbad++;
     114    }
     115    ok (Nbad == 0, "no mismatched bytes");
     116  }
     117
     118  /**** TEST 2 : use gzip headers ****/
    127119  {
    128120    z_stream zdn;
    129     zdn.next_in = srcbuf;
    130     zdn.avail_in = NSRC;
    131     zdn.next_out = tgtbuf;
    132     zdn.avail_out = NTGT;
     121    zdn.next_in = (char *) srcbuf;
     122    zdn.avail_in = NSRC * sizeof(double);
     123    zdn.next_out = (char *) tgtbuf;
     124    zdn.avail_out = NTGT * sizeof(double);
    133125 
    134126    zdn.zalloc = Z_NULL;
     
    136128    zdn.opaque = Z_NULL;
    137129
    138     for (i = 0; i < NSRC; i++) srcbuf[i] = i;
    139     memset (tgtbuf, 0, NTGT);
    140     memset (outbuf, 0, NTGT);
     130    for (i = 0; i < NSRC; i++) srcbuf[i] = 1.001*(i + 10);
     131    memset (tgtbuf, 0, NTGT * sizeof(double));
     132    memset (outbuf, 0, NOUT * sizeof(double));
     133
     134    for (i = 0; i < NSRC; i++) {
     135      char *Pout = (char *) &srcbuf[i];
     136      SWAP_DBLE;
     137    }
     138
     139    char *rawdata = (char *) srcbuf;
     140    if (VERBOSE) fprintf (stderr, "inp: ");
     141    for (i = 0; VERBOSE && (i < NSRC*8); i++) {
     142      fprintf (stderr, "0x%02hhx ", rawdata[i]);
     143    }
     144    if (VERBOSE) fprintf (stderr, "\n");
    141145
    142146    // the '5' is the compression level: make this a user argument
    143     err = deflateInit(&zdn, 5);
    144     if (err != Z_OK) { fprintf (stderr, "error 1: %d vs %d\n", err, Z_OK); exit (1); }
     147    // windowBits = 31 = (15 + 16) = (2^15 window bits) + (create a gzip stream)
     148    err = deflateInit2(&zdn, 1, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY);
     149    if (VERBOSE) fprintf (stderr, "inp buffers cmp 0: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
     150    ok (err == Z_OK, "result is Z_OK: %d vs %d", err, Z_OK);
    145151 
    146152    err = deflate(&zdn, Z_FINISH);
    147     if (err != Z_STREAM_END) { fprintf (stderr, "error 2: %d vs %d\n", err, Z_STREAM_END); exit (2); }
    148 
    149     assert (zdn.total_out <= NTGT);
    150 
    151     fprintf (stderr, "result: %d bytes\n", (int) zdn.total_out);
    152     for (i = 0; i < zdn.total_out; i++) {
     153    if (VERBOSE) fprintf (stderr, "out buffers cmp 1: %d => %d => %d\n", zdn.avail_in, zdn.avail_out, (int) zdn.total_out);
     154    ok (err == Z_STREAM_END, "result is Z_STREAM_END: %d vs %d", err, Z_STREAM_END);
     155
     156    // dump out the data which failed to uncompress (and the input data)
     157    char *cmpdata = (char *) tgtbuf;
     158    if (VERBOSE) fprintf (stderr, "out: ");
     159    for (i = 0; VERBOSE && (i < zdn.total_out); i++) {
     160      fprintf (stderr, "0x%02hhx ", cmpdata[i]);
     161    }
     162    if (VERBOSE) fprintf (stderr, "\n");
     163
     164    ok (zdn.total_out <= NTGT*sizeof(double), "output compressed size is good");
     165
     166    if (VERBOSE) fprintf (stderr, "result: %d bytes\n", (int) zdn.total_out);
     167    for (i = 0; VERBOSE && (i < zdn.total_out / sizeof(double)); i++) {
    153168      fprintf (stderr, "%d : 0x%02hhx\n", i, tgtbuf[i]);
    154169    }
     
    157172  {
    158173    z_stream zup;
    159     zup.next_in = tgtbuf;
    160     zup.avail_in = NTGT;
    161     zup.next_out = outbuf;
    162     zup.avail_out = NTGT;
     174    zup.next_in = (char *) tgtbuf;
     175    zup.avail_in = NTGT * sizeof(double);
     176    zup.next_out = (char *) outbuf;
     177    zup.avail_out = NOUT * sizeof(double);
    163178 
    164179    zup.zalloc = Z_NULL;
     
    166181    zup.opaque = Z_NULL;
    167182
    168     // the '5' is the compression level: make this a user argument
    169     err = inflateInit(&zup);
    170     if (err != Z_OK) { fprintf (stderr, "error 1: %d vs %d\n", err, Z_OK); exit (1); }
     183    // a value of 32 tells inflate to use the window size used in the compression AND to look for both zlib and gzip headers
     184    // windowBits = 47 = (15 + 32) = (2^15 window bits) + (test for either gzip or zlib streams)
     185    err = inflateInit2(&zup, 47);
     186    if (VERBOSE) fprintf (stderr, "out buffers unc 0: %d => %d => %d\n", zup.avail_in, zup.avail_out, (int) zup.total_out);
     187    ok (err == Z_OK, "inflateInit2 result is Z_OK: %d vs %d", err, Z_OK);
    171188 
    172189    err = inflate(&zup, Z_FINISH);
    173     if (err != Z_STREAM_END) { fprintf (stderr, "error 2: %d vs %d\n", err, Z_STREAM_END); exit (2); }
    174 
    175     assert (zup.total_out <= NTGT);
    176 
    177     fprintf (stderr, "result: %d bytes\n", (int) zup.total_out);
    178     for (i = 0; i < zup.total_out; i++) {
    179       fprintf (stderr, "%d : 0x%02hhx : 0x%02hhx\n", i, outbuf[i], srcbuf[i]);
    180       assert (outbuf[i] == srcbuf[i]);
    181     }
    182   }
     190    if (VERBOSE) fprintf (stderr, "out buffers unc 1: %d => %d => %d\n", zup.avail_in, zup.avail_out, (int) zup.total_out);
     191    ok (err == Z_STREAM_END, "inflate result is Z_STREAM_END: %d vs %d", err, Z_STREAM_END);
     192
     193    char *outdata = (char *) outbuf;
     194    if (VERBOSE) fprintf (stderr, "unc: ");
     195    for (i = 0; VERBOSE && (i < zup.total_out); i++) {
     196      fprintf (stderr, "0x%02hhx ", outdata[i]);
     197    }
     198    if (VERBOSE) fprintf (stderr, "\n");
     199
     200    ok (zup.total_out <= NTGT*sizeof(double), "uncompressed size is good");
     201
     202    int Nbad = 0;
     203    for (i = 0; 0 && i < zup.total_out / sizeof(double); i++) {
     204      if (outbuf[i] != srcbuf[i]) Nbad++;
     205    }
     206    ok (Nbad == 0, "no mismatched bytes");
     207  }
     208
    183209  return exit_status();
    184210}
Note: See TracChangeset for help on using the changeset viewer.