summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-09-11 12:19:45 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-09-11 12:19:45 (GMT)
commitf41b8ab87bfc9702f12a3df10911960731556bed (patch)
treeb5ceafd5da2e0c1ef9ac09fcd0b0929e97e7cb62 /test
parentf4d4d427b2f8bae72a12d4cdbee6acfc233b4c44 (diff)
downloadhdf5-f41b8ab87bfc9702f12a3df10911960731556bed.zip
hdf5-f41b8ab87bfc9702f12a3df10911960731556bed.tar.gz
hdf5-f41b8ab87bfc9702f12a3df10911960731556bed.tar.bz2
[svn-r17463] Description:
Add another regression test for userblock+alignment usage, and correct [another] issue with the combination. *sigh* Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.8 (amazon) in debug mode Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'test')
-rw-r--r--test/tfile.c115
1 files changed, 93 insertions, 22 deletions
diff --git a/test/tfile.c b/test/tfile.c
index b291154..3d730d5 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -2117,7 +2117,7 @@ test_rw_noupdate(void)
/****************************************************************
**
-** test_userblock_alignment_helper(): helper routine for
+** test_userblock_alignment_helper1(): helper routine for
** test_userblock_alignment() test, to handle common testing
**
** Programmer: Quincey Koziol
@@ -2126,7 +2126,7 @@ test_rw_noupdate(void)
**
*****************************************************************/
static int
-test_userblock_alignment_helper(hid_t fcpl, hid_t fapl)
+test_userblock_alignment_helper1(hid_t fcpl, hid_t fapl)
{
hid_t fid; /* File ID */
int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */
@@ -2174,16 +2174,35 @@ test_userblock_alignment_helper(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
} /* end if */
+ return((GetTestNumErrs() == curr_num_errs) ? 0 : -1);
+} /* end test_userblock_alignment_helper1() */
+
+/****************************************************************
+**
+** test_userblock_alignment_helper2(): helper routine for
+** test_userblock_alignment() test, to handle common testing
+**
+** Programmer: Quincey Koziol
+** koziol@hdfgroup.org
+** Septmber 10, 2009
+**
+*****************************************************************/
+static int
+test_userblock_alignment_helper2(hid_t fapl, hbool_t open_rw)
+{
+ hid_t fid; /* File ID */
+ int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */
+ herr_t ret; /* Generic return value */
/* Re-open file */
- fid = H5Fopen(FILE1, H5F_ACC_RDWR, fapl);
+ fid = H5Fopen(FILE1, (open_rw ? H5F_ACC_RDWR : H5F_ACC_RDONLY), fapl);
CHECK(fid, FAIL, "H5Fopen");
/* Only proceed further if file ID is OK */
if(fid > 0) {
- hid_t gid, gid2; /* Group IDs */
- hid_t did; /* Dataset ID */
- int val = 2; /* Dataset value */
+ hid_t gid; /* Group ID */
+ hid_t did; /* Dataset ID */
+ int val = -1; /* Dataset value */
/* Open group */
gid = H5Gopen2(fid, "group1", H5P_DEFAULT);
@@ -2202,13 +2221,18 @@ test_userblock_alignment_helper(hid_t fcpl, hid_t fapl)
ret = H5Dclose(did);
CHECK(ret, FAIL, "H5Dclose");
- /* Create a new group */
- gid2 = H5Gcreate2(gid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(gid, FAIL, "H5Gcreate2");
+ /* Only create new objects if file is open R/W */
+ if(open_rw) {
+ hid_t gid2; /* Group ID */
- /* Close new group */
- ret = H5Gclose(gid2);
- CHECK(ret, FAIL, "H5Gclose");
+ /* Create a new group */
+ gid2 = H5Gcreate2(gid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Close new group */
+ ret = H5Gclose(gid2);
+ CHECK(ret, FAIL, "H5Gclose");
+ } /* end if */
/* Close group */
ret = H5Gclose(gid);
@@ -2220,7 +2244,7 @@ test_userblock_alignment_helper(hid_t fcpl, hid_t fapl)
} /* end if */
return((GetTestNumErrs() == curr_num_errs) ? 0 : -1);
-} /* end test_userblock_alignment_helper() */
+} /* end test_userblock_alignment_helper2() */
/****************************************************************
**
@@ -2261,9 +2285,11 @@ test_userblock_alignment(void)
ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3);
CHECK(ret, FAIL, "H5Pset_alignment");
- /* Call helper routine to perform file manipulations */
- ret = test_userblock_alignment_helper(fcpl, fapl);
- CHECK(ret, FAIL, "test_userblock_alignment_helper");
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper1(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper1");
+ ret = test_userblock_alignment_helper2(fapl, TRUE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
/* Release property lists */
ret = H5Pclose(fcpl);
@@ -2290,9 +2316,11 @@ test_userblock_alignment(void)
ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)16);
CHECK(ret, FAIL, "H5Pset_alignment");
- /* Call helper routine to perform file manipulations */
- ret = test_userblock_alignment_helper(fcpl, fapl);
- CHECK(ret, FAIL, "test_userblock_alignment_helper");
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper1(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper1");
+ ret = test_userblock_alignment_helper2(fapl, TRUE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
/* Release property lists */
ret = H5Pclose(fcpl);
@@ -2319,9 +2347,11 @@ test_userblock_alignment(void)
ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)512);
CHECK(ret, FAIL, "H5Pset_alignment");
- /* Call helper routine to perform file manipulations */
- ret = test_userblock_alignment_helper(fcpl, fapl);
- CHECK(ret, FAIL, "test_userblock_alignment_helper");
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper1(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper1");
+ ret = test_userblock_alignment_helper2(fapl, TRUE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
/* Release property lists */
ret = H5Pclose(fcpl);
@@ -2392,6 +2422,47 @@ test_userblock_alignment(void)
CHECK(ret, FAIL, "H5Pclose");
ret = H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");
+
+
+ /* Case 6:
+ * File created with:
+ * Userblock size = 512, alignment = 512
+ * File re-opened for read-only & read-write access with:
+ * Userblock size = 512, alignment = 1024
+ * Outcome:
+ * Should succeed
+ */
+ /* Create file creation property list with user block */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_userblock(fcpl, (hsize_t)512);
+ CHECK(ret, FAIL, "H5Pset_userblock");
+
+ /* Create file access property list with alignment */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+ ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)512);
+ CHECK(ret, FAIL, "H5Pset_alignment");
+
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper1(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper1");
+
+ /* Change alignment in FAPL */
+ ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024);
+ CHECK(ret, FAIL, "H5Pset_alignment");
+
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper2(fapl, FALSE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
+ ret = test_userblock_alignment_helper2(fapl, TRUE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
+
+ /* Release property lists */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
} /* end test_userblock_alignment() */
/****************************************************************