Skip to content

Commit

Permalink
Merge remote-tracking branch 'canonical/master' into hdf_test_warning…
Browse files Browse the repository at this point in the history
…_fixes
  • Loading branch information
derobins committed Oct 7, 2024
2 parents 64e0a21 + effa6f1 commit d5eb31e
Show file tree
Hide file tree
Showing 17 changed files with 197 additions and 120 deletions.
4 changes: 4 additions & 0 deletions hdf/src/cszip.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ static int32 HCIcszip_init(accrec_t *access_rec);

static int32 HCIcszip_decode(compinfo_t *info, int32 length, uint8 *buf);

#ifdef H4_HAVE_LIBSZ
static int32 HCIcszip_encode(compinfo_t *info, int32 length, const uint8 *buf);
#endif

static int32 HCIcszip_term(compinfo_t *info);

Expand Down Expand Up @@ -332,6 +334,7 @@ HCIcszip_decode(compinfo_t *info, int32 length, uint8 *buf)
DESCRIPTION
Common code called to encode SZIP data into a file.
--------------------------------------------------------------------------*/
#ifdef H4_HAVE_LIBSZ
static int32
HCIcszip_encode(compinfo_t *info, int32 length, const uint8 *buf)
{
Expand Down Expand Up @@ -377,6 +380,7 @@ HCIcszip_encode(compinfo_t *info, int32 length, const uint8 *buf)
#endif /* H4_HAVE_SZIP_ENCODER */

} /* end HCIcszip_encode() */
#endif /* H4_HAVE_LIBSZ */

/*--------------------------------------------------------------------------
NAME
Expand Down
12 changes: 12 additions & 0 deletions hdf/src/hfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3550,3 +3550,15 @@ Hgetntinfo(const int32 numbertype, hdf_ntinfo_t *nt_info)
} /* end switch */
return SUCCEED;
} /* Hgetntinfo */

/* Used in the HI_CLOSE macro in hfile_priv.h */
#if (FILELIB == UNIXBUFIO)
int
hi_close_stdio(FILE **f)
{
if (EOF == fclose(*f))
return FAIL;
*f = NULL;
return SUCCEED;
}
#endif
6 changes: 5 additions & 1 deletion hdf/src/hfile_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef FILE *hdf_file_t;
#define HI_CREATE(p) (fopen((p), "wb+"))
#define HI_READ(f, b, n) (((size_t)(n) == (size_t)fread((b), 1, (size_t)(n), (f))) ? SUCCEED : FAIL)
#define HI_WRITE(f, b, n) (((size_t)(n) == (size_t)fwrite((b), 1, (size_t)(n), (f))) ? SUCCEED : FAIL)
#define HI_CLOSE(f) (((f = ((fclose(f) == 0) ? NULL : f)) == NULL) ? SUCCEED : FAIL)
#define HI_CLOSE(f) hi_close_stdio(&f)
#define HI_FLUSH(f) (fflush(f) == 0 ? SUCCEED : FAIL)
#define HI_SEEK(f, o) (fseek((f), (long)(o), SEEK_SET) == 0 ? SUCCEED : FAIL)
#define HI_SEEK_CUR(f, o) (fseek((f), (long)(o), SEEK_CUR) == 0 ? SUCCEED : FAIL)
Expand Down Expand Up @@ -402,6 +402,10 @@ typedef struct functab_t {
extern "C" {
#endif

#if (FILELIB == UNIXBUFIO)
HDFLIBAPI int hi_close_stdio(FILE **f);
#endif

#ifdef DISKBLOCK_DEBUG

HDFLIBAPI const uint8 diskblock_header[4];
Expand Down
13 changes: 0 additions & 13 deletions hdf/test/fortest.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ main(int argc, char *argv[])
{
int CLLoop; /* Command Line Loop */
int Loop, Loop1;
int Summary = 0;
int CleanUp = 1;
int num_tests = 0;
FILE *cmdfile;
const char *cmdfilename = "fortest.arg";
Expand Down Expand Up @@ -113,17 +111,11 @@ main(int argc, char *argv[])
Verbosity = atoi(argv[CLLoop + 1]);
fprintf(cmdfile, "%s %d\n", VERBOSITY_STR, Verbosity);
}
if ((argc > CLLoop) &&
((strcmp(argv[CLLoop], "-summary") == 0) || (strcmp(argv[CLLoop], "-s") == 0))) {
Summary = 1;
}
if ((argc > CLLoop) && (strcmp(argv[CLLoop], "-help") == 0)) {
printf("Usage: fortest [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] \n");
printf(" [-[e]x[clude] name+] \n");
printf(" [-o[nly] name+] \n");
printf(" [-b[egin] name] \n");
printf(" [-s[ummary]] \n");
printf(" [-c[leanno]] \n");
printf("\n\n");
printf("verbose controls the amount of information displayed\n");
printf("exclude to exclude tests by name\n");
Expand All @@ -141,11 +133,6 @@ main(int argc, char *argv[])
printf("\n\n");
exit(0);
}
if ((argc > CLLoop) &&
((strcmp(argv[CLLoop], "-cleanno") == 0) || (strcmp(argv[CLLoop], "-c") == 0))) {
CleanUp = 0;
fprintf(cmdfile, "%s %s\n", CLEAN_STR, "No");
}
if ((argc > CLLoop + 1) &&
((strcmp(argv[CLLoop], "-exclude") == 0) || (strcmp(argv[CLLoop], "-x") == 0))) {
Loop = CLLoop + 1;
Expand Down
4 changes: 4 additions & 0 deletions mfhdf/hrepack/hrepack_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ set_szip(int pixels_per_block, /*in */

return 0;
#else
(void)pixels_per_block;
(void)compression_mode;
(void)c_info;

printf("Warning: SZIP compression is not available\n");
return -1;
#endif
Expand Down
32 changes: 17 additions & 15 deletions mfhdf/test/cdftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ static char mrcsid[] = "Id: cdftest.c,v 1.11 1994/01/10 23:07:27 chouck Exp ";
#include "hdf4_netcdf.h"
#endif

#include "hdftest.h"

#define CDFMAXSHORT 32767
#define CDFMAXLONG 2147483647
#define CDFMAXBYTE 127
Expand Down Expand Up @@ -109,10 +111,10 @@ chkgot(nc_type type, union getret got, double check)
cdf_assert((nclong)check == got.lng[0]);
break;
case NC_FLOAT:
cdf_assert((float)check == got.fl[0]);
cdf_assert(H4_FLT_ABS_EQUAL((float)check, got.fl[0]));
break;
case NC_DOUBLE:
cdf_assert(check == got.dbl);
cdf_assert(H4_DBL_ABS_EQUAL(check, got.dbl));
break;
}
}
Expand Down Expand Up @@ -229,12 +231,12 @@ createtestvars(int id, struct tcdfvar *testvars, int count)
for (ii = 0; ii < count; ii++, vp++) {
cdf_assert(ncvardef(id, vp->mnem, vp->type, vp->ndims, vp->dims) == ii);

cdf_assert(ncattput(id, ii, reqattr[0], NC_CHAR, strlen(vp->units), vp->units) == 0);
cdf_assert(ncattput(id, ii, reqattr[0], NC_CHAR, (int)strlen(vp->units), vp->units) == 0);
cdf_assert(ncattput(id, ii, reqattr[1], NC_DOUBLE, 1, (ncvoid *)&(vp->validmin)) == 1);
cdf_assert(ncattput(id, ii, reqattr[2], NC_DOUBLE, 1, (ncvoid *)&(vp->validmax)) == 2);
cdf_assert(ncattput(id, ii, reqattr[3], NC_DOUBLE, 1, (ncvoid *)&(vp->scalemin)) == 3);
cdf_assert(ncattput(id, ii, reqattr[4], NC_DOUBLE, 1, (ncvoid *)&(vp->scalemax)) == 4);
cdf_assert(ncattput(id, ii, reqattr[5], NC_CHAR, strlen(vp->fieldnam), vp->fieldnam) == 5);
cdf_assert(ncattput(id, ii, reqattr[5], NC_CHAR, (int)strlen(vp->fieldnam), vp->fieldnam) == 5);
}
}

Expand All @@ -253,7 +255,7 @@ fill_seq(int id)
long vindices[NUM_DIMS];
long *cc, *mm;
float val;
int ii = 0;
float ii = 0.0F;

sizes_g[0] = NUM_RECS;
/* zero the indices */
Expand All @@ -275,7 +277,7 @@ fill_seq(int id)
#endif
cdf_assert(ncvarput1(id, Float_id, vindices, (ncvoid *)&val) != -1);
(*cc)++;
ii++;
ii += 1.0F;
continue;
}
cc++;
Expand All @@ -296,7 +298,7 @@ check_fill_seq(int id)
long vindices[NUM_DIMS];
long *cc, *mm;
union getret got;
int ii = 0;
float ii = 0.0F;
float val;

sizes_g[0] = NUM_RECS;
Expand All @@ -313,12 +315,12 @@ check_fill_seq(int id)
if (ncvarget1(id, Float_id, vindices, (ncvoid *)&got) == -1)
goto bad_ret;
val = ii;
if (val != got.fl[0]) {
if (!H4_FLT_ABS_EQUAL(val, got.fl[0])) {
parray("indices", (unsigned)NUM_DIMS, vindices);
printf("\t%f != %f\n", (double)val, (double)got.fl[0]);
}
(*cc)++;
ii++;
ii += 1.0F;
continue;
}
cc++;
Expand Down Expand Up @@ -382,12 +384,12 @@ main(void)
cdf_assert(ncattput(id, NC_GLOBAL, "TITLE", NC_CHAR, 12, "another name") != -1);
cdf_assert(ncattget(id, NC_GLOBAL, "TITLE", (ncvoid *)new) != -1);
/* printf("title 1 \"%s\"\n", new) ; */
cdf_assert(ncattput(id, NC_GLOBAL, "TITLE", NC_CHAR, strlen(fname), fname) != -1);
cdf_assert(ncattput(id, NC_GLOBAL, "TITLE", NC_CHAR, (int)strlen(fname), fname) != -1);
cdf_assert(ncattget(id, NC_GLOBAL, "TITLE", (ncvoid *)new) != -1);
new[strlen(fname)] = 0;
/* printf("title 2 \"%s\"\n", new) ; */
cdf_assert(strcmp(fname, new) == 0);
cdf_assert(ncattput(id, NC_GLOBAL, "RCSID", NC_CHAR, strlen(mrcsid), (ncvoid *)mrcsid) != -1);
cdf_assert(ncattput(id, NC_GLOBAL, "RCSID", NC_CHAR, (int)strlen(mrcsid), (ncvoid *)mrcsid) != -1);

createtestdims(id, NUM_DIMS, sizes_g, dim_names_g);
testdims(id, NUM_DIMS, sizes_g, dim_names_g);
Expand Down Expand Up @@ -480,7 +482,7 @@ main(void)
cdf_assert(strcmp("TITLE", adesc->mnem) == 0);
cdf_assert(ncattinq(id, NC_GLOBAL, adesc->mnem, &(adesc->type), &(adesc->len)) != -1);
cdf_assert(adesc->type == NC_CHAR);
cdf_assert(adesc->len == strlen(fname));
cdf_assert(adesc->len == (int)strlen(fname));
cdf_assert(ncattget(id, NC_GLOBAL, "TITLE", (ncvoid *)new) != -1);
new[adesc->len] = 0;
cdf_assert(strcmp(fname, new) == 0);
Expand All @@ -490,7 +492,7 @@ main(void)
cdf_assert(strcmp("RCSID", adesc->mnem) == 0);
cdf_assert(ncattinq(id, NC_GLOBAL, adesc->mnem, &(adesc->type), &(adesc->len)) != -1);
cdf_assert(adesc->type == NC_CHAR);
cdf_assert(adesc->len == strlen(mrcsid));
cdf_assert(adesc->len == (int)strlen(mrcsid));
cdf_assert(ncattget(id, NC_GLOBAL, "RCSID", (ncvoid *)new) != -1);
new[adesc->len] = 0;
cdf_assert(strcmp(mrcsid, new) == 0);
Expand Down Expand Up @@ -532,7 +534,7 @@ main(void)

if (ncattinq(id, ii, reqattr[0], &(adesc->type), &(adesc->len)) != -1) {
cdf_assert(adesc->type == NC_CHAR);
cdf_assert(adesc->len == strlen(tvp->units));
cdf_assert(adesc->len == (int)strlen(tvp->units));
cdf_assert(ncattget(id, ii, reqattr[0], (ncvoid *)new) != -1);
new[adesc->len] = 0;
cdf_assert(strcmp(tvp->units, new) == 0);
Expand Down Expand Up @@ -568,7 +570,7 @@ main(void)

if (ncattinq(id, ii, reqattr[5], &(adesc->type), &(adesc->len)) != -1) {
cdf_assert(adesc->type == NC_CHAR);
cdf_assert(adesc->len == strlen(tvp->fieldnam));
cdf_assert(adesc->len == (int)strlen(tvp->fieldnam));
cdf_assert(ncattget(id, ii, reqattr[5], (ncvoid *)new) != -1);
new[adesc->len] = 0;
cdf_assert(strcmp(tvp->fieldnam, new) == 0);
Expand Down
2 changes: 1 addition & 1 deletion mfhdf/test/hdftest.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int32 make_Ext3D_SDS(int32 sd_id, char *sds_name, int32 type, int32 rank, int32
int32 append_Data2SDS(int32 sd_id, char *sds_name, int32 *start, int32 *edges, void *ap_data);

/* Calls SDgetdatasize then verify the size against data_size */
int verify_datasize(int32 sds_id, int32 data_size, char *sds_name);
int verify_datasize(int32 sds_id, int32 data_size, const char *sds_name);

/* Verifies the unlimited dimension's size and the variable's data. */
int verify_info_data(int32 sds_id, int32 expected_dimsize, int16 *result);
Expand Down
8 changes: 6 additions & 2 deletions mfhdf/test/tattributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,15 @@ test_attribute_ops()
/* Get the info about the first attribute of this dimension */
status = SDattrinfo(dimid, (int32)0, name, &nt, &count);
CHECK(status, FAIL, "SDattrinfo");
if (count < 0)
count = 0;

/* Read first attribute in, assume CHAR here. */
status = SDreadattr(dimid, 0, text);
CHECK(status, FAIL, "SDreadattr");

/* Compare value retrieved to what was written */
if (strncmp(text, "TRUE", count)) {
if ((status != FAIL) && strncmp(text, "TRUE", (size_t)count)) {
fprintf(stderr, "SDreadattr: Invalid dimension attribute read <%s>\n", text);
num_errs++;
}
Expand Down Expand Up @@ -613,12 +615,14 @@ test_attribute_ops()
/* Get info about the global attribute just created */
status = SDattrinfo(fid1, (int32)0, name, &nt, &count);
CHECK(status, FAIL, "SDattrinfo");
if (count < 0)
count = 0;

/* Read this global attribute back in and verify the values */
status = SDreadattr(fid1, 0, text);
CHECK(status, FAIL, "SDreadattr");

if (strncmp(text, "globulator", count)) {
if ((status != FAIL) && strncmp(text, "globulator", (size_t)count)) {
fprintf(stderr, "Invalid global attribute read <%s>\n", text);
num_errs++;
}
Expand Down
10 changes: 5 additions & 5 deletions mfhdf/test/tchunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,14 +825,14 @@ test_chunk()
comp_type = COMP_CODE_INVALID; /* reset variables before retrieving info */
status = SDgetcomptype(newsds6, &comp_type);
CHECK(status, FAIL, "Chunk Test 6. SDgetcomptype");
VERIFY(comp_type, chunk_def.comp.comp_type, "Chunk Test 6. SDgetcomptype");
VERIFY((int)comp_type, chunk_def.comp.comp_type, "Chunk Test 6. SDgetcomptype");

/* Retrieve and verify the compression info - bug# 307 and bugzilla# 130 */
comp_type = COMP_CODE_INVALID; /* reset variables before retrieving info */
memset(&cinfo, 0, sizeof(cinfo));
status = SDgetcompinfo(newsds6, &comp_type, &cinfo);
CHECK(status, FAIL, "Chunk Test 6. SDgetcompinfo");
VERIFY(comp_type, chunk_def.comp.comp_type, "Chunk Test 6. SDgetcompinfo");
VERIFY((int)comp_type, chunk_def.comp.comp_type, "Chunk Test 6. SDgetcompinfo");
VERIFY(cinfo.skphuff.skp_size, chunk_def.comp.cinfo.skphuff.skp_size, "Chunk Test 6. SDgetcompinfo");

/* Write data use SDwriteChunk */
Expand Down Expand Up @@ -1036,7 +1036,7 @@ test_chunk()
c_flags_out = 0;
status = SDgetchunkinfo(newsds6, &chunk_def_out, &c_flags_out);
CHECK(status, FAIL, "Chunk Test 6. SDgetchunkinfo");
VERIFY(chunk_def_out.comp.comp_type, comp_type, "Chunk Test 6. SDgetchunkinfo");
VERIFY((int)comp_type, chunk_def_out.comp.comp_type, "Chunk Test 6. SDgetchunkinfo");
VERIFY(chunk_def_out.comp.cinfo.skphuff.skp_size, chunk_def.comp.cinfo.skphuff.skp_size,
"Chunk Test 6. chunkinfo_new");
VERIFY(c_flags_out, (HDF_CHUNK | HDF_COMP), "Chunk Test 6. SDgetchunkinfo");
Expand Down Expand Up @@ -1204,14 +1204,14 @@ test_chunk()
memset(&cinfo, 0, sizeof(cinfo));
status = SDgetcompinfo(newsds7, &comp_type, &cinfo);
CHECK(status, FAIL, "Chunk Test 6. SDgetcompinfo");
VERIFY(comp_type, chunk_def.comp.comp_type, "Chunk Test 6. SDgetcompinfo");
VERIFY((int)comp_type, chunk_def.comp.comp_type, "Chunk Test 6. SDgetcompinfo");
VERIFY(cinfo.deflate.level, chunk_def.comp.cinfo.deflate.level, "Chunk Test 6. SDgetcompinfo");

/* Retrieve and verify the compression type */
comp_type = COMP_CODE_INVALID; /* reset variables before retrieving info */
status = SDgetcomptype(newsds7, &comp_type);
CHECK(status, FAIL, "Chunk Test 7. SDgetcomptype");
VERIFY(comp_type, chunk_def.comp.comp_type, "Chunk Test 7. SDgetcomptype");
VERIFY((int)comp_type, chunk_def.comp.comp_type, "Chunk Test 7. SDgetcomptype");

/* Close down SDS*/
status = SDendaccess(newsds7);
Expand Down
20 changes: 10 additions & 10 deletions mfhdf/test/tcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,20 @@
static int
test_various_comps()
{
/************************* Variable declaration **************************/

int32 sd_id, sds_id;
int status;
int32 comp_type; /* Compression flag */
comp_info c_info; /* Compression structure */
int32 start[2], edges[2], dim_sizes[2];
int32 data[Y_LENGTH][X_LENGTH];
int32 pixels_per_scanline;
int num_errs = 0; /* number of errors in compression test so far */
int i, j;

/********************* End of variable declaration ***********************/
#ifdef H4_HAVE_SZIP_ENCODER
int32 pixels_per_scanline;
#endif

/* Buffer array data and define array dimensions. */
for (j = 0; j < Y_LENGTH; j++) {
for (i = 0; i < X_LENGTH; i++)
for (int j = 0; j < Y_LENGTH; j++) {
for (int i = 0; i < X_LENGTH; i++)
data[j][i] = (i + j) + 1;
}
dim_sizes[0] = Y_LENGTH;
Expand Down Expand Up @@ -126,7 +123,10 @@ test_various_comps()
status = SDendaccess(sds_id);
CHECK(status, FAIL, "SDendaccess");

#ifdef H4_HAVE_SZIP_ENCODER /* we have szip library with encoder */
#ifdef H4_HAVE_SZIP_ENCODER

/* We have an szip library with encoder */

/* Create 3rd data set for SZIP compression. */
sds_id = SDcreate(sd_id, SDS3_NAME, DFNT_INT32, RANK, dim_sizes);
CHECK(sds_id, FAIL, "SDcreate");
Expand All @@ -135,7 +135,7 @@ test_various_comps()
comp_type = COMP_CODE_SZIP;
pixels_per_scanline = dim_sizes[1];
c_info.szip.pixels = dim_sizes[0] * dim_sizes[1];
;

c_info.szip.pixels_per_block = 2;
if (pixels_per_scanline >= 2048)
c_info.szip.pixels_per_scanline = 512;
Expand Down
Loading

0 comments on commit d5eb31e

Please sign in to comment.