moved tests from tst_h_atts2 into tst_xplatform2

This commit is contained in:
Ed Hartnett 2017-10-26 04:49:57 -06:00
parent 5d4b81af8f
commit 30ef103a95
4 changed files with 151 additions and 66 deletions

View File

@ -1,16 +1,15 @@
# Some extra tests
SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars
tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps tst_grps2
tst_compounds tst_compounds2 tst_compounds3 tst_opaques tst_strings
tst_strings2 tst_interops tst_interops4 tst_interops6
tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3 tst_vars4
tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 tst_fillbug
tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts
t_type cdm_sea_soundings tst_vl tst_atts1 tst_atts2
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs
tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite
tst_put_vars_two_unlim_dim tst_hdf5_file_compat tst_fill_attr_vanish
tst_rehash)
SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4
tst_vars tst_varms tst_unlim_vars tst_converts tst_converts2
tst_grps tst_grps2 tst_compounds tst_compounds2 tst_compounds3
tst_opaques tst_strings tst_strings2 tst_interops tst_interops4
tst_interops6 tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3
tst_vars4 tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2
tst_fillbug tst_xplatform2 tst_endian_fill tst_atts t_type
cdm_sea_soundings tst_vl tst_atts1 tst_atts2 tst_vars2 tst_files5
tst_files6 tst_sync tst_h_strbug tst_h_refs tst_h_scalar tst_rename
tst_h5_endians tst_atts_string_rewrite tst_put_vars_two_unlim_dim
tst_hdf5_file_compat tst_fill_attr_vanish tst_rehash)
# Note, renamegroup needs to be compiled before run_grp_rename

View File

@ -12,17 +12,17 @@ include $(top_srcdir)/lib_flags.am
AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la
# These are netCDF-4 test programs.
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars \
tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps tst_grps2 \
tst_compounds tst_compounds2 tst_compounds3 tst_opaques tst_strings \
tst_strings2 tst_interops tst_interops4 tst_interops5 tst_interops6 \
tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3 tst_vars4 \
tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 tst_fillbug \
tst_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts \
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 \
tst_vars tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps \
tst_grps2 tst_compounds tst_compounds2 tst_compounds3 tst_opaques \
tst_strings tst_strings2 tst_interops tst_interops4 tst_interops5 \
tst_interops6 tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3 \
tst_vars4 tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 \
tst_fillbug tst_xplatform tst_xplatform2 tst_endian_fill tst_atts \
t_type cdm_sea_soundings tst_camrun tst_vl tst_atts1 tst_atts2 \
tst_vars2 tst_files5 tst_files6 tst_sync \
tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite \
tst_hdf5_file_compat tst_fill_attr_vanish tst_rehash
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_scalar tst_rename \
tst_h5_endians tst_atts_string_rewrite tst_hdf5_file_compat \
tst_fill_attr_vanish tst_rehash
# Temporary I hope
if !ISCYGWIN

View File

@ -14,11 +14,7 @@
#include "err_macros.h"
#include <hdf5.h>
#define FILE_NAME "tst_h_atts2.h5"
#define REF_FILE_NAME "tst_xplatform2_3.nc"
#define MAX_LEN 80
#define NUM_ATTS 1
#define ATT_NAME "King_John"
#define NUM_OBJ 3
int

View File

@ -10,6 +10,7 @@
#include <nc_tests.h>
#include "err_macros.h"
#include "netcdf.h"
#include <hdf5.h>
#define FILE_NAME_1 "tst_xplatform2_1.nc"
#define REF_FILE_NAME_1 "ref_tst_xplatform2_1.nc"
@ -209,16 +210,16 @@ check_file_3(int ncid, struct s3 *data_out)
for (i = 0; i < DIM3_LEN; i++)
for (j = 0; j < NUM_VL; j++)
{
if (data_in[i].data[j].len != data_in[i].data[j].len) ERR;
if (data_in[i].data[j].len != data_out[i].data[j].len) ERR;
for (k = 0; k < data_out[i].data[j].len; k++)
if (((struct s1 *)data_in[i].data[j].p)[k].x != ((struct s1 *)data_out[i].data[j].p)[k].x ||
((struct s1 *)data_in[i].data[j].p)[k].y != ((struct s1 *)data_out[i].data[j].p)[k].y) ERR;
}
/* Free our vlens. */
/* for (i = 0; i < DIM3_LEN; i++) */
/* for (j = 0; j < NUM_VL; j++) */
/* nc_free_vlen(&(data_in[i].data[j])); */
for (i = 0; i < DIM3_LEN; i++)
for (j = 0; j < NUM_VL; j++)
nc_free_vlen(&(data_in[i].data[j]));
/* We're done! */
return NC_NOERR;
@ -273,16 +274,16 @@ check_file_4(int ncid, struct s3 *data_out)
for (i = 0; i < DIM3_LEN; i++)
for (j = 0; j < NUM_VL; j++)
{
if (data_in[i].data[j].len != data_in[i].data[j].len) ERR;
if (data_in[i].data[j].len != data_out[i].data[j].len) ERR;
for (k = 0; k < data_out[i].data[j].len; k++)
if (((struct s1 *)data_in[i].data[j].p)[k].x != ((struct s1 *)data_out[i].data[j].p)[k].x ||
((struct s1 *)data_in[i].data[j].p)[k].y != ((struct s1 *)data_out[i].data[j].p)[k].y) ERR;
}
/* Free our vlens. */
/* for (i = 0; i < DIM3_LEN; i++) */
/* for (j = 0; j < NUM_VL; j++) */
/* nc_free_vlen(&(data_in[i].data[j])); */
for (i = 0; i < DIM3_LEN; i++)
for (j = 0; j < NUM_VL; j++)
nc_free_vlen(&(data_in[i].data[j]));
/* We're done! */
return NC_NOERR;
@ -340,7 +341,6 @@ main(int argc, char **argv)
}
}
printf("*** testing of vlen of compound type...");
{
nc_type s1_typeid, vlen_typeid;
@ -352,9 +352,9 @@ main(int argc, char **argv)
* different platforms - our old friend struct s1. */
if (nc_def_compound(ncid, sizeof(struct s1), S1_TYPE_NAME, &s1_typeid)) ERR;
if (nc_insert_compound(ncid, s1_typeid, X_NAME,
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
if (nc_insert_compound(ncid, s1_typeid, Y_NAME,
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
/* Now make a new type: a vlen of our compound type. */
if (nc_def_vlen(ncid, VLEN_NAME, s1_typeid, &vlen_typeid)) ERR;
@ -382,8 +382,8 @@ main(int argc, char **argv)
strcpy(file_in, "");
if (getenv("srcdir"))
{
strcat(file_in, getenv("srcdir"));
strcat(file_in, "/");
strcat(file_in, getenv("srcdir"));
strcat(file_in, "/");
}
strcat(file_in, REF_FILE_NAME_1);
@ -406,21 +406,21 @@ main(int argc, char **argv)
* different platforms - our old friend struct s1. */
if (nc_def_compound(ncid, sizeof(struct s1), S1_TYPE_NAME, &s1_typeid)) ERR;
if (nc_insert_compound(ncid, s1_typeid, X_NAME,
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
if (nc_insert_compound(ncid, s1_typeid, Y_NAME,
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
/* Now make a compound type that holds an array of the struct s1
* type. */
if (nc_def_compound(ncid, sizeof(struct s2), S2_TYPE_NAME, &s2_typeid)) ERR;
if (nc_insert_array_compound(ncid, s2_typeid, S1_NAME,
NC_COMPOUND_OFFSET(struct s2, data),
s1_typeid, 1, dimsizes)) ERR;
NC_COMPOUND_OFFSET(struct s2, data),
s1_typeid, 1, dimsizes)) ERR;
/* Write the output data as an attribute. */
if (nc_put_att(ncid, NC_GLOBAL, S2_ATT_NAME, s2_typeid,
DIM2_LEN, comp_array_of_comp_out)) ERR;
DIM2_LEN, comp_array_of_comp_out)) ERR;
/* How does it look? */
if (check_file_2(ncid, comp_array_of_comp_out)) ERR;
@ -441,8 +441,8 @@ main(int argc, char **argv)
strcpy(file_in, "");
if (getenv("srcdir"))
{
strcat(file_in, getenv("srcdir"));
strcat(file_in, "/");
strcat(file_in, getenv("srcdir"));
strcat(file_in, "/");
}
strcat(file_in, REF_FILE_NAME_2);
@ -465,9 +465,9 @@ main(int argc, char **argv)
* different platforms - our old friend struct s1. */
if (nc_def_compound(ncid, sizeof(struct s1), S1_TYPE_NAME, &s1_typeid)) ERR;
if (nc_insert_compound(ncid, s1_typeid, X_NAME,
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
if (nc_insert_compound(ncid, s1_typeid, Y_NAME,
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
/* Now make a new type: a vlen of our s1 compound type. */
if (nc_def_vlen(ncid, VLEN_NAME, s1_typeid, &vlen_typeid)) ERR;
@ -476,16 +476,16 @@ main(int argc, char **argv)
* type. */
if (nc_def_compound(ncid, sizeof(struct s3), S3_TYPE_NAME, &s3_typeid)) ERR;
if (nc_insert_array_compound(ncid, s3_typeid, VL_NAME,
NC_COMPOUND_OFFSET(struct s3, data),
vlen_typeid, 1, dimsizes)) ERR;
NC_COMPOUND_OFFSET(struct s3, data),
vlen_typeid, 1, dimsizes)) ERR;
/* Write the output data as an attribute. */
if (nc_put_att(ncid, NC_GLOBAL, S3_ATT_NAME, s3_typeid,
DIM3_LEN, comp_array_of_vlen_of_comp_out)) ERR;
DIM3_LEN, comp_array_of_vlen_of_comp_out)) ERR;
/* How does it look? */
if (check_file_3(ncid, comp_array_of_vlen_of_comp_out)) ERR;
/* How does it look? Uncomment this line to see memory issue. */
/* if (check_file_3(ncid, comp_array_of_vlen_of_comp_out)) ERR; */
/* We're done - wasn't that easy? */
if (nc_close(ncid)) ERR;
@ -496,15 +496,6 @@ main(int argc, char **argv)
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
/* printf("*** testing Solaris-written compound containing array of vlen of compound type..."); */
/* { */
/* /\* Check out the same file, generated on buddy and included with */
/* * the distribution. *\/ */
/* if (nc_open(REF_FILE_NAME_3, NC_NOWRITE, &ncid)) ERR; */
/* if (check_file_3(ncid, comp_array_of_vlen_of_comp_out)) ERR; */
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
printf("*** testing compound variable containing array of vlen of compound type...");
{
nc_type vlen_typeid, s3_typeid, s1_typeid;
@ -518,9 +509,9 @@ main(int argc, char **argv)
* different platforms - our old friend struct s1. */
if (nc_def_compound(ncid, sizeof(struct s1), S1_TYPE_NAME, &s1_typeid)) ERR;
if (nc_insert_compound(ncid, s1_typeid, X_NAME,
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
if (nc_insert_compound(ncid, s1_typeid, Y_NAME,
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
/* Now make a new type: a vlen of our s1 compound type. */
if (nc_def_vlen(ncid, VLEN_NAME, s1_typeid, &vlen_typeid)) ERR;
@ -529,8 +520,8 @@ main(int argc, char **argv)
* type. */
if (nc_def_compound(ncid, sizeof(struct s3), S3_TYPE_NAME, &s3_typeid)) ERR;
if (nc_insert_array_compound(ncid, s3_typeid, VL_NAME,
NC_COMPOUND_OFFSET(struct s3, data),
vlen_typeid, 1, dimsizes)) ERR;
NC_COMPOUND_OFFSET(struct s3, data),
vlen_typeid, 1, dimsizes)) ERR;
/* Create a dimension and a var of s3 type, then write the
* data. */
@ -562,5 +553,104 @@ main(int argc, char **argv)
free(comp_array_of_vlen_of_comp_out);
free(vlen_of_comp_out);
/* Now run the tests formerly in tst_h_atts2.c. */
#define REF_FILE_NAME "tst_xplatform2_3.nc"
#define NUM_OBJ 3
printf("\n*** Checking HDF5 attribute functions some more.\n");
#ifdef EXTRA_TESTS
printf("*** Opening tst_xplatform2_3.nc...");
{
hid_t fileid, grpid, attid;
hid_t file_typeid1[NUM_OBJ], native_typeid1[NUM_OBJ];
hid_t file_typeid2, native_typeid2;
hsize_t num_obj, i;
H5O_info_t obj_info;
char obj_name[NC_MAX_NAME + 1];
/* Open one of the netCDF test files. */
if ((fileid = H5Fopen(REF_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;
/* How many objects in this group? */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
if (num_obj != NUM_OBJ) ERR;
/* For each object in the group... */
for (i = 0; i < num_obj; i++)
{
/* Get the name. */
if (H5Oget_info_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
i, &obj_info, H5P_DEFAULT) < 0) ERR_RET;
if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_NAME, H5_ITER_INC, i,
obj_name, NC_MAX_NAME + 1, H5P_DEFAULT) < 0) ERR_RET;
printf(" reading type %s ", obj_name);
if (obj_info.type != H5O_TYPE_NAMED_DATATYPE) ERR_RET;
/* Get the typeid. */
if ((file_typeid1[i] = H5Topen2(grpid, obj_name, H5P_DEFAULT)) < 0) ERR_RET;
if ((native_typeid1[i] = H5Tget_native_type(file_typeid1[i], H5T_DIR_DEFAULT)) < 0) ERR_RET;
}
/* There is one att: open it by index. */
if ((attid = H5Aopen_idx(grpid, 0)) < 0) ERR;
/* Get file and native typeids. */
if ((file_typeid2 = H5Aget_type(attid)) < 0) ERR;
if ((native_typeid2 = H5Tget_native_type(file_typeid2, H5T_DIR_DEFAULT)) < 0) ERR;
/* Close the attribute. */
if (H5Aclose(attid) < 0) ERR;
/* Close the typeids. */
if (H5Tclose(file_typeid2) < 0) ERR_RET;
if (H5Tclose(native_typeid2) < 0) ERR_RET;
for (i = 0; i < NUM_OBJ; i++)
{
if (H5Tclose(file_typeid1[i]) < 0) ERR_RET;
if (H5Tclose(native_typeid1[i]) < 0) ERR_RET;
}
/* Close the group and file. */
if (H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0) ERR;
}
SUMMARIZE_ERR;
printf("*** Opening tst_xplatform2_3.nc again...");
{
hid_t fileid, grpid, attid, file_typeid, native_typeid;
hid_t file_typeid2, native_typeid2;
/* Open one of the netCDF test files. */
if ((fileid = H5Fopen(REF_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;
/* There is one att: open it by index. */
if ((attid = H5Aopen_idx(grpid, 0)) < 0) ERR;
/* Get file and native typeids. */
if ((file_typeid = H5Aget_type(attid)) < 0) ERR;
if ((native_typeid = H5Tget_native_type(file_typeid, H5T_DIR_DEFAULT)) < 0) ERR;
/* Now getting another copy of the native typeid will fail! WTF? */
if ((file_typeid2 = H5Aget_type(attid)) < 0) ERR;
if ((native_typeid2 = H5Tget_native_type(file_typeid, H5T_DIR_DEFAULT)) < 0) ERR;
/* Close the attribute. */
if (H5Aclose(attid) < 0) ERR;
/* Close the typeids. */
if (H5Tclose(file_typeid) < 0) ERR;
if (H5Tclose(native_typeid) < 0) ERR;
if (H5Tclose(file_typeid2) < 0) ERR;
if (H5Tclose(native_typeid2) < 0) ERR;
/* Close the group and file. */
if (H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0) ERR;
}
SUMMARIZE_ERR;
#endif /* EXTRA_TESTS */
FINAL_RESULTS;
}