summaryrefslogtreecommitdiffstats
path: root/testpar
diff options
context:
space:
mode:
authorRichard Warren <Richard.Warren@hdfgroup.org>2017-11-02 16:33:08 (GMT)
committerRichard Warren <Richard.Warren@hdfgroup.org>2017-11-02 16:33:08 (GMT)
commit0d2fd7ae0cd19c2eb040a4ad733b50c7652639cc (patch)
treea12f0b416e987e22f6dcf81419ac51f9cb4b12a5 /testpar
parentef1f2f61e2a0cc9540b44d48ad417f3527df70aa (diff)
downloadhdf5-0d2fd7ae0cd19c2eb040a4ad733b50c7652639cc.zip
hdf5-0d2fd7ae0cd19c2eb040a4ad733b50c7652639cc.tar.gz
hdf5-0d2fd7ae0cd19c2eb040a4ad733b50c7652639cc.tar.bz2
Make a fix to allow CMake testing which does not use relative directories.
Diffstat (limited to 'testpar')
-rw-r--r--testpar/t_pread.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/testpar/t_pread.c b/testpar/t_pread.c
index b5a84f2..a527503 100644
--- a/testpar/t_pread.c
+++ b/testpar/t_pread.c
@@ -55,6 +55,9 @@ fools.\n";
static int generate_test_file(MPI_Comm comm, int mpi_rank, int group);
static int test_parallel_read(MPI_Comm comm, int mpi_rank, int group);
+static char *test_argv0 = NULL;
+extern char *dirname(char *path); /* Avoids additional includes */
+
/*-------------------------------------------------------------------------
* Function: generate_test_file
@@ -392,9 +395,29 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
if ( pass ) {
char cmd[256];
-
- HDsprintf(cmd, "../tools/src/h5jam/h5jam -i %s -u %s -o %s",
- data_filename, prolog_filename, reloc_data_filename);
+ char exe_path[256];
+ char *relative_path = "../tools/src/h5jam";
+ char *exe_dirname = relative_path;
+
+ /* We're checking for the existance of the h5jam utility
+ * With Cmake testing, all binaries are in the same directory
+ * e.g. the same location where this executable is found.
+ * We've copied the argv[0] argument and check to see
+ * if h5jam is co-located here. Otherwise, the autotools
+ * put things into directories, hence the relative path.
+ */
+ if (test_argv0 != NULL) {
+ HDstrncpy(exe_path, test_argv0, sizeof(exe_path));
+ if ( (exe_dirname = (char *)dirname(exe_path)) != NULL) {
+ HDsprintf(cmd, "%s/h5jam", exe_dirname);
+ if ( HDaccess(cmd, F_OK) != 0)
+ exe_dirname = relative_path;
+ }
+ }
+ HDsprintf(cmd, "%s/h5jam -i %s -u %s -o %s",
+ exe_dirname,
+ data_filename,
+ prolog_filename, reloc_data_filename);
if ( system(cmd) != 0 ) {
pass = FALSE;
@@ -680,7 +703,7 @@ test_parallel_read(MPI_Comm comm, int mpi_rank, int group_id)
}
/* collect results from other processes.
- * Only overwrite the failure message if no preveious error
+ * Only overwrite the failure message if no previous error
* has been detected
*/
local_failure = ( pass ? 0 : 1 );
@@ -761,6 +784,17 @@ main( int argc, char **argv)
int split_size;
MPI_Comm group_comm = MPI_COMM_WORLD;
+ /* I don't believe that argv[0] can ever be NULL.
+ * It should thus be safe to dup and save as a check
+ * for cmake testing. Note that in our Cmake builds,
+ * all executables are located in the same directory.
+ * We assume (but we'll check) that the h5jam utility
+ * is in the directory as this executable. If that
+ * isn't true, then we can use a relative path that
+ * should be valid for the autotools environment.
+ */
+ test_argv0 = HDstrdup(argv[0]);
+
if ( (MPI_Init(&argc, &argv)) != MPI_SUCCESS) {
HDfprintf(stderr, "FATAL: Unable to initialize MPI\n");
HDexit(EXIT_FAILURE);
@@ -785,11 +819,11 @@ main( int argc, char **argv)
HDfprintf(stdout, "========================================\n");
}
- if ( mpi_size < 4 ) {
+ if ( mpi_size < 3 ) {
if ( mpi_rank == 0 ) {
- HDprintf(" Need at least 4 processes. Exiting.\n");
+ HDprintf(" Need at least 3 processes. Exiting.\n");
}
goto finish;
}