summaryrefslogtreecommitdiffstats
path: root/test/h5test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/h5test.c')
-rw-r--r--test/h5test.c70
1 files changed, 64 insertions, 6 deletions
diff --git a/test/h5test.c b/test/h5test.c
index ab859a5..78d0077 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 */
@@ -100,6 +101,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[] = {
@@ -196,8 +203,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)
{
@@ -247,7 +253,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)
/*-------------------------------------------------------------------------
@@ -1358,8 +1364,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)
{
@@ -1461,7 +1466,7 @@ 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'
@@ -2038,3 +2043,56 @@ 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() */