hdf5/test/trefer_shutdown.c

84 lines
2.2 KiB
C
Raw Normal View History

2020-01-16 07:16:25 +08:00
#include "h5test.h"
int
main(int argc, char **argv)
{
H5R_ref_t write_ref, read_ref;
hid_t fid;
hid_t did;
hid_t sid;
2020-09-30 22:27:10 +08:00
int i;
2020-01-16 07:16:25 +08:00
if ((fid = H5Fcreate("HDFFV-10992.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
fprintf(stderr, "H5Fcreate failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
if ((sid = H5Screate(H5S_SCALAR)) < 0) {
fprintf(stderr, "H5Screate failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
/* Create a dataset of object references */
if ((did = H5Dcreate2(fid, "dset", H5T_STD_REF, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
fprintf(stderr, "H5Dcreate failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
for (i = 0; i < 100; i++) {
/* Create reference to the root group */
if (H5Rcreate_object(fid, "/dset", H5P_DEFAULT, &write_ref) < 0) {
fprintf(stderr, "H5Rcreate_object failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
}
/* Write reference to dataset */
if (H5Dwrite(did, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, &write_ref) < 0) {
fprintf(stderr, "H5Dwrite failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
for (i = 0; i < 500; i++) {
/* Read reference back into different reference buffer */
if (H5Dread(did, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, &read_ref) < 0) {
fprintf(stderr, "H5Dread failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
}
/*
* "Forget" to call H5Rdestroy on reference objects. If H5Rdestroy
* is called at least once on either reference object, or both
2020-04-21 07:12:00 +08:00
* objects, the infinite loop goes away. If H5Rdestroy is never
2020-01-16 07:16:25 +08:00
* called, the infinite loop will appear.
*/
#if 0
if (H5Rdestroy(&write_ref) < 0) {
fprintf(stderr, "H5Rdestroy on reference write buffer failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
if (H5Rdestroy(&read_ref) < 0) {
fprintf(stderr, "H5Rdestroy on reference read buffer failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
#endif
if (H5Sclose(sid) < 0) {
fprintf(stderr, "H5Sclose failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
if (H5Dclose(did) < 0) {
fprintf(stderr, "H5Dclose failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
if (H5Fclose(fid) < 0) {
fprintf(stderr, "H5Fclose failed\n");
2020-01-16 07:16:25 +08:00
return 1;
}
return 0;
}