summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/dsets.c36
-rw-r--r--test/mount.c139
-rw-r--r--test/vfd.c2
3 files changed, 158 insertions, 19 deletions
diff --git a/test/dsets.c b/test/dsets.c
index b444e0e..5ea5ac4 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -2573,7 +2573,7 @@ test_nbit_int(hid_t file)
for (i= 0;i< size[0]; i++)
for (j = 0; j < size[1]; j++) {
orig_data[i][j] = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision - 1)) << offset;
+ (long_long)HDpow(2.0, precision - 1)) << offset;
/* even-numbered values are negtive */
if((i*size[1]+j+1)%2 == 0)
@@ -2987,7 +2987,7 @@ test_nbit_array(hid_t file)
for (m = 0; m < adims[0]; m++)
for (n = 0; n < adims[1]; n++)
orig_data[i][j][m][n] = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision)) << offset;
+ (long_long)HDpow(2.0, precision)) << offset;
PASSED();
#else
SKIPPED();
@@ -3167,11 +3167,11 @@ test_nbit_compound(hid_t file)
for (i= 0;i< size[0]; i++)
for (j = 0; j < size[1]; j++) {
orig_data[i][j].i = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision[0]-1)) << offset[0];
+ (long_long)HDpow(2.0, precision[0]-1)) << offset[0];
orig_data[i][j].c = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision[1]-1)) << offset[1];
+ (long_long)HDpow(2.0, precision[1]-1)) << offset[1];
orig_data[i][j].s = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision[2]-1)) << offset[2];
+ (long_long)HDpow(2.0, precision[2]-1)) << offset[2];
orig_data[i][j].f = float_val[i][j];
/* some even-numbered integer values are negtive */
@@ -3414,29 +3414,29 @@ test_nbit_compound_2(hid_t file)
for (i= 0;i< size[0]; i++)
for (j = 0; j < size[1]; j++) {
orig_data[i][j].a.i = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision[0]-1)) << offset[0];
+ (long_long)HDpow(2.0, precision[0]-1)) << offset[0];
orig_data[i][j].a.c = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision[1]-1)) << offset[1];
+ (long_long)HDpow(2.0, precision[1]-1)) << offset[1];
orig_data[i][j].a.s = -((long_long)HDrandom() %
- (long_long)HDpow(2, precision[2]-1)) << offset[2];
+ (long_long)HDpow(2.0, precision[2]-1)) << offset[2];
orig_data[i][j].a.f = float_val[i][j];
orig_data[i][j].v = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision[3])) << offset[3];
+ (long_long)HDpow(2.0, precision[3])) << offset[3];
for(m = 0; m < array_dims[0]; m++)
for(n = 0; n < array_dims[1]; n++)
orig_data[i][j].b[m][n] = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision[4]-1)) << offset[4];
+ (long_long)HDpow(2.0, precision[4]-1)) << offset[4];
for(m = 0; m < array_dims[0]; m++)
for(n = 0; n < array_dims[1]; n++) {
orig_data[i][j].d[m][n].i = -((long_long)HDrandom() %
- (long_long)HDpow(2, precision[0]-1)) << offset[0];
+ (long_long)HDpow(2.0, precision[0]-1)) << offset[0];
orig_data[i][j].d[m][n].c = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision[1]-1)) << offset[1];
+ (long_long)HDpow(2.0, precision[1]-1)) << offset[1];
orig_data[i][j].d[m][n].s = ((long_long)HDrandom() %
- (long_long)HDpow(2, precision[2]-1)) << offset[2];
+ (long_long)HDpow(2.0, precision[2]-1)) << offset[2];
orig_data[i][j].d[m][n].f = float_val[i][j];
}
}
@@ -3639,7 +3639,7 @@ test_nbit_compound_3(hid_t file)
/* Initialize data */
for(i = 0; i < size[0]; i++) {
- orig_data[i].i = HDrandom() % (long)HDpow(2, 17-1);
+ orig_data[i].i = HDrandom() % (long)HDpow(2.0, 17-1);
strcpy(orig_data[i].str, "fixed-length C string");
orig_data[i].vl_str = strdup("variable-length C string");
@@ -4131,7 +4131,7 @@ test_scaleoffset_float(hid_t file)
/* Check that the values read are the same as the values written */
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
- if (HDfabs(new_data[i][j]-orig_data[i][j]) > HDpow(10, -3)) {
+ if (HDfabs(new_data[i][j]-orig_data[i][j]) > HDpow(10.0, -3)) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
@@ -4281,7 +4281,7 @@ test_scaleoffset_float_2(hid_t file)
/* Check that the values read are the same as the values written */
for (j=0; j<size[1]; j++) {
- if (HDfabs(new_data[0][j]-orig_data[0][j]) > HDpow(10, -3)) {
+ if (HDfabs(new_data[0][j]-orig_data[0][j]) > HDpow(10.0, -3)) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j);
@@ -4411,7 +4411,7 @@ test_scaleoffset_double(hid_t file)
/* Check that the values read are the same as the values written */
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
- if (HDfabs(new_data[i][j]-orig_data[i][j]) > HDpow(10, -7)) {
+ if (HDfabs(new_data[i][j]-orig_data[i][j]) > HDpow(10.0, -7)) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
@@ -4561,7 +4561,7 @@ test_scaleoffset_double_2(hid_t file)
/* Check that the values read are the same as the values written */
for (j=0; j<size[1]; j++) {
- if (HDfabs(new_data[0][j]-orig_data[0][j]) > HDpow(10, -7)) {
+ if (HDfabs(new_data[0][j]-orig_data[0][j]) > HDpow(10.0, -7)) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j);
diff --git a/test/mount.c b/test/mount.c
index bff93d6..71d8c5a 100644
--- a/test/mount.c
+++ b/test/mount.c
@@ -19,6 +19,7 @@
* Purpose: Tests file mounting.
*/
#include "h5test.h"
+#include "H5Iprivate.h" /* IDs */
const char *FILENAME[] = {
"mount_1",
@@ -1651,7 +1652,15 @@ test_missing_unmount(hid_t fapl)
/* Close group in top file */
if(H5Gclose(gidA) < 0)
TEST_ERROR
-
+
+ /* Check that all file IDs have been closed */
+ if(H5I_nmembers(H5I_FILE) != 0)
+ TEST_ERROR
+
+ /* Check that all "file closing" IDs have been closed */
+ if(H5I_nmembers(H5I_FILE_CLOSING) != 0)
+ TEST_ERROR
+
PASSED();
return 0;
@@ -1671,6 +1680,133 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_hold_open
+ *
+ * Purpose: Test that the library correctly holds open files when they
+ * have child files that have not been unmounted.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, July 5, 2005
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_hold_open(hid_t fapl)
+{
+ hid_t fid1 = -1, fid2 = -1; /* File IDs */
+ hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */
+ char filename1[1024],
+ filename2[1024]; /* Name of files to mount */
+
+ TESTING("hold open");
+
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
+
+ /* Create file #1 */
+ if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ if((gidA = H5Gcreate(fid1, "A", (size_t)0)) < 0)
+ TEST_ERROR
+
+ if(H5Gclose(gidA) < 0)
+ TEST_ERROR
+
+ if(H5Fclose(fid1) < 0)
+ TEST_ERROR
+
+
+ /* Create file #2 */
+ if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ if((gidM = H5Gcreate(fid2, "M", (size_t)0)) < 0)
+ TEST_ERROR
+
+ if(H5Gclose(gidM) < 0)
+ TEST_ERROR
+
+ if(H5Fclose(fid2) < 0)
+ TEST_ERROR
+
+
+ /* Re-open files and mount file #2 in file #1 */
+ if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ if((gidA = H5Gopen(fid1, "A")) < 0)
+ TEST_ERROR
+
+ if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ if((gidAM = H5Gopen(fid1, "A/M")) < 0)
+ TEST_ERROR
+
+ /* Close file #2 */
+ if(H5Fclose(fid2) < 0)
+ TEST_ERROR
+
+ /* Close group in mounted file */
+ if(H5Gclose(gidAM) < 0)
+ TEST_ERROR
+
+ /* Attempt to open group in mounted file */
+ /* (Should work because file is still mounted) */
+ if((gidAM = H5Gopen(fid1, "A/M")) < 0)
+ TEST_ERROR
+
+ /* Close file #1 */
+ if(H5Fclose(fid1) < 0)
+ TEST_ERROR
+
+ /* Close group in mounted file */
+ if(H5Gclose(gidAM) < 0)
+ TEST_ERROR
+
+ /* Attempt to open group in mounted file */
+ /* (Should work because file is still mounted) */
+ if((gidAM = H5Gopen(gidA, "/A/M")) < 0)
+ TEST_ERROR
+
+ /* Close group in mounted file */
+ if(H5Gclose(gidAM) < 0)
+ TEST_ERROR
+
+ /* Unmount file #2 */
+ if(H5Funmount(gidA, ".") < 0)
+ TEST_ERROR
+
+ /* Close group in top file */
+ if(H5Gclose(gidA) < 0)
+ TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(gidM);
+ H5Gclose(gidAM);
+ H5Gclose(gidA);
+ H5Fclose(fid2);
+ H5Fclose(fid1);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_hold_open() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test file mounting
@@ -1712,6 +1848,7 @@ main(void)
nerrors += test_mount_after_close(fapl);
nerrors += test_mount_after_unmount(fapl);
nerrors += test_missing_unmount(fapl);
+ nerrors += test_hold_open(fapl);
if (nerrors) goto error;
puts("All mount tests passed.");
diff --git a/test/vfd.c b/test/vfd.c
index 16038c3..f8e2c3d 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -451,10 +451,12 @@ error:
static herr_t
test_family_compat(void)
{
+#ifdef H5_WANT_H5_V1_6_COMPAT
hid_t file=(-1), fapl;
char filename[1024];
char pathname[1024];
char *srcdir = getenv("srcdir"); /*where the src code is located*/
+#endif /*H5_WANT_H5_V1_6_COMPAT*/
TESTING("FAMILY file driver backward compatibility");