summaryrefslogtreecommitdiffstats
path: root/test/vfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/vfd.c')
-rw-r--r--test/vfd.c167
1 files changed, 154 insertions, 13 deletions
diff --git a/test/vfd.c b/test/vfd.c
index b196406..2b15430 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -58,6 +58,7 @@ const char *FILENAME[] = {
"stdio_file", /*7*/
"windows_file", /*8*/
"new_multi_file_v16",/*9*/
+ "ro_s3_file6", /*10*/
NULL
};
@@ -66,7 +67,7 @@ const char *FILENAME[] = {
#define COMPAT_BASENAME "family_v16_"
#define MULTI_COMPAT_BASENAME "multi_file_v16"
-
+
/*-------------------------------------------------------------------------
* Function: test_sec2
*
@@ -178,7 +179,7 @@ error:
return -1;
} /* end test_sec2() */
-
+
/*-------------------------------------------------------------------------
* Function: test_core
*
@@ -534,7 +535,7 @@ error:
return -1;
} /* end test_core() */
-
+
/*-------------------------------------------------------------------------
* Function: test_direct
*
@@ -754,7 +755,7 @@ error:
#endif /*H5_HAVE_DIRECT*/
}
-
+
/*-------------------------------------------------------------------------
* Function: test_family_opens
*
@@ -835,7 +836,7 @@ error:
} /* end test_family_opens() */
#pragma GCC diagnostic pop
-
+
/*-------------------------------------------------------------------------
* Function: test_family
*
@@ -1017,7 +1018,7 @@ error:
return -1;
}
-
+
/*-------------------------------------------------------------------------
* Function: test_family_compat
*
@@ -1129,7 +1130,7 @@ error:
} /* end test_family_compat() */
#pragma GCC diagnostic pop
-
+
/*-------------------------------------------------------------------------
* Function: test_multi_opens
*
@@ -1170,7 +1171,7 @@ test_multi_opens(char *fname)
} /* end test_multi_opens() */
#pragma GCC diagnostic pop
-
+
/*-------------------------------------------------------------------------
* Function: test_multi
*
@@ -1404,7 +1405,7 @@ error:
return FAIL;
} /* end test_multi() */
-
+
/*-------------------------------------------------------------------------
* Function: test_multi_compat
*
@@ -1578,7 +1579,7 @@ error:
return -1;
}
-
+
/*-------------------------------------------------------------------------
* Function: test_log
*
@@ -1689,7 +1690,7 @@ error:
return -1;
}
-
+
/*-------------------------------------------------------------------------
* Function: test_stdio
*
@@ -1794,7 +1795,7 @@ error:
}
-
+
/*-------------------------------------------------------------------------
* Function: test_windows
*
@@ -1916,7 +1917,146 @@ error:
} /* end test_windows() */
-
+/*-------------------------------------------------------------------------
+ * Function: test_ros3
+ *
+ * Purpose: Tests the file handle interface for the ROS3 driver
+ *
+ * As the ROS3 driver is 1) read only, 2) requires access
+ * to an S3 server (minio for now), this test is quite
+ * different from the other tests.
+ *
+ * For now, test only fapl & flags. Extend as the
+ * work on the VFD continues.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: John Mainzer
+ * 7/12/17
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_ros3(void)
+{
+ hid_t fid = -1; /* file ID */
+ hid_t fapl_id = -1; /* file access property list ID */
+ hid_t fapl_id_out = -1; /* from H5Fget_access_plist */
+ hid_t driver_id = -1; /* ID for this VFD */
+ unsigned long driver_flags = 0; /* VFD feature flags */
+ char filename[1024]; /* filename */
+ void *os_file_handle = NULL; /* OS file handle */
+ hsize_t file_size; /* file size */
+ H5FD_ros3_fapl_t test_ros3_fa;
+ H5FD_ros3_fapl_t ros3_fa_0 =
+ {
+ /* version = */ H5FD__CURR_ROS3_FAPL_T_VERSION,
+ /* authenticate = */ FALSE,
+ /* aws_region = */ "",
+ /* secret_id = */ "",
+ /* secret_key = */ "plugh",
+ };
+
+ TESTING("ROS3 file driver");
+
+ /* Set property list and file name for ROS3 driver. */
+ if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
+
+ if(H5Pset_fapl_ros3(fapl_id, &ros3_fa_0) < 0)
+ TEST_ERROR;
+
+ /* verify that the ROS3 FAPL entry is set as expected */
+ if(H5Pget_fapl_ros3(fapl_id, &test_ros3_fa) < 0)
+ TEST_ERROR;
+
+ /* need a macro to compare instances of H5FD_ros3_fapl_t */
+ if((test_ros3_fa.version != ros3_fa_0.version) ||
+ (test_ros3_fa.authenticate != ros3_fa_0.authenticate) ||
+ (strcmp(test_ros3_fa.aws_region, ros3_fa_0.aws_region) != 0) ||
+ (strcmp(test_ros3_fa.secret_id, ros3_fa_0.secret_id) != 0) ||
+ (strcmp(test_ros3_fa.secret_key, ros3_fa_0.secret_key) != 0))
+ TEST_ERROR;
+
+ h5_fixname(FILENAME[10], fapl_id, filename, sizeof(filename));
+
+ /* Check that the VFD feature flags are correct */
+ if ((driver_id = H5Pget_driver(fapl_id)) < 0)
+ TEST_ERROR;
+
+ if (H5FDdriver_query(driver_id, &driver_flags) < 0)
+ TEST_ERROR;
+
+ if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR
+
+ /* Check for extra flags not accounted for above */
+ if(driver_flags != (H5FD_FEAT_DATA_SIEVE))
+ TEST_ERROR
+
+ /* can't create analogs of the following tests until the
+ * ROS3 driver is up and running in a minimal fashion.
+ * Comment them out until we get to them.
+ */
+#if 0
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
+ TEST_ERROR;
+
+ /* Retrieve the access property list... */
+ if((fapl_id_out = H5Fget_access_plist(fid)) < 0)
+ TEST_ERROR;
+
+ /* Check that the driver is correct */
+ if(H5FD_ROS3 != H5Pget_driver(fapl_id_out))
+ TEST_ERROR;
+
+ /* ...and close the property list */
+ if(H5Pclose(fapl_id_out) < 0)
+ TEST_ERROR;
+
+ /* Check that we can get an operating-system-specific handle from
+ * the library.
+ */
+ if(H5Fget_vfd_handle(fid, H5P_DEFAULT, &os_file_handle) < 0)
+ TEST_ERROR;
+ if(os_file_handle == NULL)
+ FAIL_PUTS_ERROR("NULL os-specific vfd/file handle was returned from H5Fget_vfd_handle");
+
+
+ /* There is no garantee the size of metadata in file is constant.
+ * Just try to check if it's reasonable.
+ *
+ * Currently it should be around 2 KB.
+ */
+ if(H5Fget_filesize(fid, &file_size) < 0)
+ TEST_ERROR;
+ if(file_size < 1 * KB || file_size > 4 * KB)
+ FAIL_PUTS_ERROR("suspicious file size obtained from H5Fget_filesize");
+
+ /* Close and delete the file */
+ if(H5Fclose(fid) < 0)
+ TEST_ERROR;
+ h5_delete_test_file(FILENAME[0], fapl_id);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl_id) < 0)
+ TEST_ERROR;
+#endif
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl_id);
+ H5Pclose(fapl_id_out);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end test_ros3() */
+
+
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -1949,6 +2089,7 @@ main(void)
nerrors += test_log() < 0 ? 1 : 0;
nerrors += test_stdio() < 0 ? 1 : 0;
nerrors += test_windows() < 0 ? 1 : 0;
+ nerrors += test_ros3() < 0 ? 1 : 0;
if(nerrors) {
HDprintf("***** %d Virtual File Driver TEST%s FAILED! *****\n",