static void test_vgisinternal() { int32 fid, vgroup_id; intn is_internal = FALSE; int32 vref = -1; intn ii, status; char testfile[H4_MAX_NC_NAME] = ""; char internal_array2[2] = {TRUE, TRUE}; intn num_errs = 0; /* number of errors so far */ /* Use a GR file to test Vgisinternal on internal vgroups */ /* The file GR_FILE is an existing file in the test_files directory, make_datafilename builds the file name with correct path */ if (make_datafilename(GR_FILE, testfile, H4_MAX_NC_NAME) != FAIL) { /* Open the old GR file and initialize the V interface */ fid = Hopen(testfile, DFACC_READ, 0); CHECK_VOID(fid, FAIL, "Hopen: grtdfui83.hdf"); status = Vstart(fid); CHECK_VOID(status, FAIL, "Vstart"); ii = 0; while ((vref = Vgetid(fid, vref)) != FAIL) { /* until no more vgroups */ vgroup_id = Vattach(fid, vref, "r"); /* attach to vgroup */ /* Test that the current vgroup is or is not internal as specified in the array internal_array2 */ is_internal = Vgisinternal(vgroup_id); CHECK_VOID(is_internal, FAIL, "Vgisinternal"); VERIFY_VOID(is_internal, internal_array2[ii], "Vgisinternal"); status = Vdetach(vgroup_id); CHECK_VOID(status, FAIL, "Vdetach"); ii++; /* increment vgroup index */ } /* Terminate access to the V interface and close the file */ status = Vend(fid); CHECK_VOID(status, FAIL, "Vend"); status = Hclose(fid); CHECK_VOID(status, FAIL, "Hclose"); } else { fprintf(stderr, "ERROR>>> Unable to make filename for %s\n", GR_FILE); H4_FAILED() } } /* test_vgisinternal */
/******************************************************************** Name: test_getszipdata() - verifies that SZIP compressed data can be read when either SZIP library encoder or only decoder is present Description: This test function opens the existing file "sds_szipped.dat" that contains a dataset with SZIP compression and verifies that the SZIP compressed data can be read with or without the encoder as long as the szlib is available. The input file, sds_szipped.dat, is generated by the program mfhdf/libsrc/gen_sds_szipped.c Return value: The number of errors occurred in this routine. BMR - Oct 10, 2008 *********************************************************************/ #ifdef H4_HAVE_LIBSZ /* needed to read data, either decoder or encoder */ static intn test_getszipdata() { /************************* Variable declaration **************************/ int32 sd_id, sds_id; intn status; int32 dim_sizes[2], array_rank, num_type, attributes; char name[H4_MAX_NC_NAME]; comp_info c_info; int32 start[2], edges[2]; int16 fill_value = 0; /* Fill value */ int i,j; int num_errs = 0; /* number of errors so far */ int32 out_data[SZ_LENGTH][SZ_WIDTH]; char testfile[512] = ""; char *basename = "sds_szipped.dat"; /* data to compare against read data from sds_szipped.dat */ int32 in_data[SZ_LENGTH][SZ_WIDTH]={ 100,100,200,200,300, 0, 0, 0, 0, 0, 100,100,200,200,300, 400,300,200,100,0, 300,300, 0,400,300, 300,300, 0,400,300, 300,300, 0,400,300, 0, 0,600,600,300, 500,500,600,600,300, 0, 0,600,600,300, 0, 0,600,600,300, 0, 0,600,600,300, 0, 0,600,600,300, 500,500,600,600,300, 500,500,600,600,300, 500,500,600,600,300 }; /********************* End of variable declaration ***********************/ /* Make the name for the test file */ make_datafilename(basename, testfile, sizeof(testfile)); /* Open the file */ sd_id = SDstart (testfile, DFACC_READ); CHECK(sd_id, FAIL, "SDstart"); /* Get the first SDS */ sds_id = SDselect (sd_id, 0); CHECK(sds_id, FAIL, "SDselect:Failed to select a data set for szip compression testing"); /* Retrieve information of the data set */ status = SDgetinfo(sds_id, name, &array_rank, dim_sizes, &num_type, &attributes); CHECK(status, FAIL, "SDgetinfo"); /* Prepare for reading */ start[0] = 0; start[1] = 0; edges[0] = dim_sizes[0]; edges[1] = dim_sizes[1]; /* Wipe out the output buffer */ HDmemset(&out_data, 0, sizeof(out_data)); /* Read the data set */ status = SDreaddata (sds_id, start, NULL, edges, (VOIDP)out_data); CHECK(status, FAIL, "SDreaddata"); /* Compare read data against input data */ for (j=0; j<SZ_LENGTH; j++) { for (i=0; i<SZ_WIDTH; i++) if (out_data[j][i] != in_data[j][i]) { fprintf(stderr,"This one: Bogus val in loc [%d][%d] in compressed dset, want %ld got %ld\n", j, i, (long)in_data[j][i], (long)out_data[j][i]); num_errs++; } } /* Terminate access to the data set */ status = SDendaccess (sds_id); CHECK(status, FAIL, "SDendaccess"); /* Terminate access to the SD interface and close the file */ status = SDend (sd_id); CHECK(status, FAIL, "SDend"); /* Return the number of errors that's been kept track of so far */ return num_errs; } /* test_getszipdata */
static intn test_getszipinfo() { /************************* Variable declaration **************************/ int32 sd_id, sds_id, sds_index; intn status; int32 dim_sizes[2], array_rank, num_type, attributes; char name[H4_MAX_NC_NAME]; comp_info c_info; int32 start[2], edges[2]; comp_coder_t comp_type; int32 comp_size, uncomp_size, orig_size; int16 fill_value = 0; /* Fill value */ int i,j; int num_errs = 0; /* number of errors so far */ char testfile[512] = ""; int32 *out_data = NULL; char *basename = "sds_szipped.dat"; /********************* End of variable declaration ***********************/ /* Make the name for the test file */ make_datafilename(basename, testfile, sizeof(testfile)); /* Open the file and select dataset SDS1_NAME */ sd_id = SDstart (testfile, DFACC_RDONLY); CHECK(sd_id, FAIL, "SDstart"); sds_index = SDnametoindex(sd_id, SDS1_NAME); CHECK(sds_index, FAIL, "SDnametoindex"); sds_id = SDselect (sd_id, sds_index); CHECK(sds_id, FAIL, "SDselect:Failed to select a data set for szip compression testing"); /* Retrieve and verify information of the data set */ status = SDgetinfo(sds_id, name, &array_rank, dim_sizes, &num_type, &attributes); CHECK(status, FAIL, "SDgetinfo"); VERIFY(array_rank, RANK, "SDgetinfo"); VERIFY(dim_sizes[0], SZ_LENGTH, "SDgetinfo"); VERIFY(dim_sizes[1], SZ_WIDTH, "SDgetinfo"); VERIFY(num_type, DFNT_INT32, "SDgetinfo"); VERIFY(attributes, 0, "SDgetinfo"); /* Get the compression method and verify it */ comp_type = COMP_CODE_INVALID; /* reset variables before retrieving info */ status = SDgetcomptype(sds_id, &comp_type); CHECK(status, FAIL, "SDgetcomptype"); VERIFY(comp_type, COMP_CODE_SZIP, "SDgetcomptype"); /* Get the compressed data size and non-compressed data size */ status = SDgetdatasize(sds_id, &comp_size, &uncomp_size); CHECK(status, FAIL, "SDgetdatasize"); /* Compute the uncompressed/original size of the data for comparision */ orig_size = SZ_WIDTH * SZ_LENGTH * SIZE_INT32; VERIFY(uncomp_size, orig_size, "SDgetdatasize"); /* In this test, compressed data size should be smaller than non-compressed data size */ if (comp_size >= uncomp_size) { printf("*** Routine test_getszipinfo: FAILED at line %d ***\n", __LINE__); printf(" In this test, compressed data size (%d) should be smaller than non-compressed data size (%d)\n", comp_size, uncomp_size); num_errs++; } /* Terminate access to the data set */ status = SDendaccess (sds_id); CHECK(status, FAIL, "SDendaccess"); /* Terminate access to the SD interface and close the file */ status = SDend (sd_id); CHECK(status, FAIL, "SDend"); /* Return the number of errors that's been kept track of so far */ return num_errs; } /* test_getszipinfo */