summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2009-04-15 21:15:04 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2009-04-15 21:15:04 (GMT)
commit0e08da80237bbb4bfb2727c57b1906cc9e17d11b (patch)
tree6e5ce719764edc01a8e9762c31eb4b8a763a3cd8 /test
parent79d1396cfaae09486314dac680fb68d206dda5aa (diff)
downloadhdf5-0e08da80237bbb4bfb2727c57b1906cc9e17d11b.zip
hdf5-0e08da80237bbb4bfb2727c57b1906cc9e17d11b.tar.gz
hdf5-0e08da80237bbb4bfb2727c57b1906cc9e17d11b.tar.bz2
[svn-r16758] The test of family file compatibility with v1.6 used the original family files under the library
source directory. Since the test opens the files with write mode, it's safer to make copies of the original files. I added the copying step in test_family_compat in vfd.c. I changed the Makefile.am to clean up the copied files. I created a new family_v16_00000.h5 with v1.6 library. Tested on jam - supposed to be simple change.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am3
-rw-r--r--test/family_v16_00000.h5bin5120 -> 5120 bytes
-rw-r--r--test/vfd.c64
3 files changed, 56 insertions, 11 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index b9e4b55..d85c72c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -117,7 +117,8 @@ CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offset.h5 \
enum1.h5 titerate.h5 ttsafe.h5 tarray1.h5 tgenprop.h5 \
tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \
getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \
- family_file000[0-3][0-9].h5 multi_file-[rs].h5 core_file \
+ family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \
+ multi_file-[rs].h5 core_file \
new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \
dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \
unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \
diff --git a/test/family_v16_00000.h5 b/test/family_v16_00000.h5
index 5b69c93..ac75ea9 100644
--- a/test/family_v16_00000.h5
+++ b/test/family_v16_00000.h5
Binary files differ
diff --git a/test/vfd.c b/test/vfd.c
index 57798a5..9ca0ac4 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -28,6 +28,7 @@
#define FAMILY_SIZE2 (5*KB)
#define MULTI_SIZE 128
#define CORE_INCREMENT (4*KB)
+#define FILE_COPY_BUF_SIZE 4096
/*Macros for Direct VFD*/
#define MBOUNDARY 512
@@ -44,13 +45,16 @@ const char *FILENAME[] = {
"sec2_file",
"core_file",
"family_file",
+ "family_v16_",
+ "new_family_v16_",
"multi_file",
"direct_file",
NULL
};
-
+/*
#define COMPAT_BASENAME "family_v16_"
-
+#define COMPAT_NEWNAME "new_family_v16_"
+*/
/*-------------------------------------------------------------------------
* Function: test_sec2
@@ -173,7 +177,7 @@ test_direct(void)
fapl = h5_fileaccess();
if(H5Pset_fapl_direct(fapl, MBOUNDARY, FBSIZE, CBSIZE) < 0)
TEST_ERROR;
- h5_fixname(FILENAME[4], fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[6], fapl, filename, sizeof filename);
/* Verify the file access properties */
if(H5Pget_fapl_direct(fapl, &mbound, &fbsize, &cbsize) < 0)
@@ -805,8 +809,14 @@ test_family_compat(void)
hid_t dset;
char dname[]="dataset";
char filename[1024];
- char pathname[1024];
+ char pathname[1024], pathname_individual[1024];
+ char newname[1024], newname_individual[1024];
char *srcdir = getenv("srcdir"); /*where the src code is located*/
+ FILE *tmp_fp, *old_fp; /* Pointers to temp & old files */
+ void *copy_buf; /* Pointer to buffer for copying data */
+ size_t written; /* Amount of data written to new file */
+ size_t read_in; /* Amount of data read in from old file */
+ int counter = 0;
TESTING("FAMILY file driver backward compatibility");
@@ -816,7 +826,8 @@ test_family_compat(void)
if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE2, H5P_DEFAULT) < 0)
TEST_ERROR;
- h5_fixname(COMPAT_BASENAME, fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[3], fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[4], fapl, newname, sizeof newname);
pathname[0] = '\0';
/* Generate correct name for test file by prepending the source path */
@@ -826,9 +837,42 @@ test_family_compat(void)
}
HDstrcat(pathname, filename);
+ /* The following code makes the copies of the family files in the source directory.
+ * Since we're going to open the files with write mode, this protects the original
+ * files.
+ */
+ if(NULL == (copy_buf = HDmalloc((size_t)FILE_COPY_BUF_SIZE))) TEST_ERROR
+
+ sprintf(newname_individual, newname, counter);
+ sprintf(pathname_individual, pathname, counter);
+
+ /* Open the original files until no more left. Copy the content into the new files. */
+ while((old_fp = HDfopen(pathname_individual,"rb"))) {
+ /* Open the new file */
+ if(NULL == (tmp_fp = fopen(newname_individual,"wb"))) TEST_ERROR
+
+ /* Copy data from the old file to the new file */
+ while((read_in = HDfread(copy_buf, (size_t)1, (size_t)FILE_COPY_BUF_SIZE, old_fp)) > 0)
+ /* Write the data to the new file */
+ if(read_in != (written = HDfwrite(copy_buf, (size_t)1, read_in, tmp_fp))) TEST_ERROR
+
+ /* Close the old file */
+ if(HDfclose(old_fp)) TEST_ERROR
+
+ /* Close the new file */
+ if(HDfclose(tmp_fp)) TEST_ERROR
+
+ counter++;
+ sprintf(newname_individual, newname, counter);
+ sprintf(pathname_individual, pathname, counter);
+ }
+
+ /* Free the copy buffer */
+ free(copy_buf);
+
/* Make sure we can open the file. Use the read and write mode to flush the
* superblock. */
- if((file = H5Fopen(pathname, H5F_ACC_RDWR, fapl)) < 0)
+ if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0)
TEST_ERROR;
if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0)
@@ -841,7 +885,7 @@ test_family_compat(void)
TEST_ERROR;
/* Open the file again to make sure it isn't corrupted. */
- if((file = H5Fopen(pathname, H5F_ACC_RDWR, fapl)) < 0)
+ if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0)
TEST_ERROR;
if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0)
@@ -853,8 +897,7 @@ test_family_compat(void)
if(H5Fclose(file) < 0)
TEST_ERROR;
- if(H5Pclose(fapl) < 0)
- TEST_ERROR;
+ h5_cleanup(FILENAME, fapl);
PASSED();
@@ -863,6 +906,7 @@ test_family_compat(void)
error:
H5E_BEGIN_TRY {
H5Fclose(file);
+ H5Pclose(fapl);
} H5E_END_TRY;
return -1;
@@ -979,7 +1023,7 @@ test_multi(void)
if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0)
TEST_ERROR;
- h5_fixname(FILENAME[3], fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[5], fapl, filename, sizeof filename);
if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
TEST_ERROR;