summaryrefslogtreecommitdiffstats
path: root/test/h5test.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-05-20 17:03:41 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-05-20 17:03:41 (GMT)
commit2d43fb8f02956d95fffb9b6d17f54d46aa8671bb (patch)
tree434aafca9b9f4ddb8191c46936d2f95450e274dd /test/h5test.c
parentfd404f711b8a587a5b5534f268a918115884bd56 (diff)
downloadhdf5-2d43fb8f02956d95fffb9b6d17f54d46aa8671bb.zip
hdf5-2d43fb8f02956d95fffb9b6d17f54d46aa8671bb.tar.gz
hdf5-2d43fb8f02956d95fffb9b6d17f54d46aa8671bb.tar.bz2
Moved srcdir changes over from develop.
Diffstat (limited to 'test/h5test.c')
-rw-r--r--test/h5test.c74
1 files changed, 67 insertions, 7 deletions
diff --git a/test/h5test.c b/test/h5test.c
index 495dfdb..ea67e45 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -23,6 +23,7 @@
#include "h5test.h"
#include "H5srcdir.h"
+#include "H5srcdir_str.h"
/* Necessary for h5_verify_cached_stabs() */
#define H5G_FRIEND /*suppress error about including H5Gpkg */
@@ -97,6 +98,12 @@ static const char *multi_letters = "msbrglo";
/* The # of seconds to wait for the message file--used by h5_wait_message() */
#define MESSAGE_TIMEOUT 300 /* Timeout in seconds */
+/* Buffer to construct path in and return pointer to */
+static char srcdir_path[1024] = "";
+
+/* Buffer to construct file in and return pointer to */
+static char srcdir_testpath[1024] = "";
+
/* The strings that correspond to library version bounds H5F_libver_t in H5Fpublic.h */
/* This is used by h5_get_version_string() */
const char *LIBVER_NAMES[] = {
@@ -190,8 +197,7 @@ h5_clean_files(const char *base_name[], hid_t fapl)
* sub_filename in the code below, but early (4.4.7, at least) gcc only
* allows diagnostic pragmas to be toggled outside of functions.
*/
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+H5_GCC_DIAG_OFF(format-nonliteral)
void
h5_delete_test_file(const char *base_name, hid_t fapl)
{
@@ -241,7 +247,7 @@ h5_delete_test_file(const char *base_name, hid_t fapl)
return;
} /* end h5_delete_test_file() */
-#pragma GCC diagnostic pop
+H5_GCC_DIAG_ON(format-nonliteral)
/*-------------------------------------------------------------------------
@@ -1246,8 +1252,7 @@ h5_dump_info_object(MPI_Info info)
* temp in the code below, but early (4.4.7, at least) gcc only
* allows diagnostic pragmas to be toggled outside of functions.
*/
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+H5_GCC_DIAG_OFF(format-nonliteral)
h5_stat_size_t
h5_get_file_size(const char *filename, hid_t fapl)
{
@@ -1349,13 +1354,14 @@ h5_get_file_size(const char *filename, hid_t fapl)
return(-1);
} /* end get_file_size() */
-#pragma GCC diagnostic pop
+H5_GCC_DIAG_ON(format-nonliteral)
/*
* This routine is designed to provide equivalent functionality to 'printf'
* and allow easy replacement for environments which don't have stdin/stdout
* available. (i.e. Windows & the Mac)
*/
+H5_ATTR_FORMAT(printf, 1, 2)
int
print_func(const char *format, ...)
{
@@ -1878,8 +1884,62 @@ error:
*
*-------------------------------------------------------------------------
*/
-char *
+H5_ATTR_PURE const char *
h5_get_version_string(H5F_libver_t libver)
{
return(LIBVER_NAMES[libver]);
} /* end of h5_get_version_string */
+
+/*-------------------------------------------------------------------------
+ * Function: H5_get_srcdir_filename
+ *
+ * Purpose: Append the test file name to the srcdir path and return the whole string
+ *
+ * Return: The string
+ *
+ *-------------------------------------------------------------------------
+ */
+const char *H5_get_srcdir_filename(const char *filename)
+{
+ const char *srcdir = H5_get_srcdir();
+
+ /* Check for error */
+ if(NULL == srcdir)
+ return(NULL);
+ else {
+ /* Build path to test file */
+ if((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) {
+ HDsnprintf(srcdir_testpath, sizeof(srcdir_testpath), "%s%s", srcdir, filename);
+ return(srcdir_testpath);
+ } /* end if */
+ else
+ return(NULL);
+ } /* end else */
+} /* end H5_get_srcdir_filename() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5_get_srcdir
+ *
+ * Purpose: Just return the srcdir path
+ *
+ * Return: The string
+ *
+ *-------------------------------------------------------------------------
+ */
+const char *H5_get_srcdir(void)
+{
+ const char *srcdir = HDgetenv("srcdir");
+
+ /* Check for using the srcdir from configure time */
+ if(NULL == srcdir)
+ srcdir = config_srcdir;
+
+ /* Build path to all test files */
+ if((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) {
+ HDsnprintf(srcdir_path, sizeof(srcdir_path), "%s/", srcdir);
+ return(srcdir_path);
+ } /* end if */
+ else
+ return(NULL);
+} /* end H5_get_srcdir() */
+