Skip to content

Commit

Permalink
Fix file names in tfile.c (HDFGroup#3743)
Browse files Browse the repository at this point in the history
Some tests in tfile.c use h5_fileaccess to get a VFD-dependent file
name but use the scheme from testhdf5, reusing the FILE1 and FILE8
names. This leads to files like test1.h5.h5 which are unintended
and not cleaned up.

This changes the filename scheme for a few tests to work with h5test,
resulting in more informative names and allowing the files to
be cleaned up at the end of the test. The test files have also
been added to the `make clean` target for the Autotools.
  • Loading branch information
derobins authored and jhendersonHDF committed Oct 24, 2023
1 parent 02a6727 commit d28c530
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 mdset.h5 compact_dataset.h5 dataset.h5 d
splitter*.h5 splitter.log mirror_rw mirror_ro event_set_[0-9].h5 \
cmpd_dtransform.h5 single_latest.h5 source_file.h5 stdio_file.h5 \
tfile_is_accessible.h5 tfile_is_accessible_non_hdf5.h5 tverbounds_dtype.h5 \
virtual_file1.h5 flushrefresh_test
virtual_file1.h5 tfile_double_open.h5 tfile_incr_filesize.h5 flushrefresh_test

# Sources for testhdf5 executable
testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
Expand Down
21 changes: 17 additions & 4 deletions test/tfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,15 @@
#define NGROUPS 2
#define NDSETS 4

/* Declaration for test_incr_filesize() */
/* Declaration for libver bounds tests */
#define FILE8 "tfile8.h5" /* Test file */

/* Declaration for test_file_double_file_dataset_open() */
#define FILE_DOUBLE_OPEN "tfile_double_open"

/* Declaration for test_incr_filesize() */
#define FILE_INCR_FILESIZE "tfile_incr_filesize"

/* Files created under 1.6 branch and 1.8 branch--used in test_filespace_compatible() */
static const char *OLD_FILENAME[] = {
"filespace_1_6.h5", /* 1.6 HDF5 file */
Expand Down Expand Up @@ -2623,8 +2629,8 @@ test_file_double_file_dataset_open(bool new_format)
if (new_format) {
ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
CHECK(ret, FAIL, "H5Pset_libver_bounds");
} /* end if */
h5_fixname(FILE1, fapl, filename, sizeof filename);
}
h5_fixname(FILE_DOUBLE_OPEN, fapl, filename, sizeof filename);

/* Create the test file */
fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
Expand Down Expand Up @@ -2934,6 +2940,9 @@ test_file_double_file_dataset_open(bool new_format)
ret = H5Tclose(tid1);
CHECK(ret, FAIL, "H5Tclose");

/* Delete the test file */
h5_delete_test_file(filename, fapl);

/* Close FAPL */
ret = H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");
Expand Down Expand Up @@ -7649,7 +7658,7 @@ test_incr_filesize(void)
MESSAGE(5, ("Testing H5Fincrement_filesize() and H5Fget_eoa())\n"));

fapl = h5_fileaccess();
h5_fixname(FILE8, fapl, filename, sizeof filename);
h5_fixname(FILE_INCR_FILESIZE, fapl, filename, sizeof filename);

/* Get the VFD feature flags */
driver_id = H5Pget_driver(fapl);
Expand Down Expand Up @@ -7734,6 +7743,9 @@ test_incr_filesize(void)
/* Verify the filesize is the previous stored_eoa + 512 */
VERIFY(filesize, stored_eoa + 512, "file size");

/* Delete the test file */
h5_delete_test_file(FILE_INCR_FILESIZE, fapl);

/* Close the file access property list */
ret = H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");
Expand Down Expand Up @@ -8224,6 +8236,7 @@ cleanup_file(void)
H5Fdelete(FILE5, H5P_DEFAULT);
H5Fdelete(FILE6, H5P_DEFAULT);
H5Fdelete(FILE7, H5P_DEFAULT);
H5Fdelete(FILE8, H5P_DEFAULT);
H5Fdelete(DST_FILE, H5P_DEFAULT);
}
H5E_END_TRY
Expand Down

0 comments on commit d28c530

Please sign in to comment.