summaryrefslogtreecommitdiffstats
path: root/testpar
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2004-08-20 05:03:28 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2004-08-20 05:03:28 (GMT)
commit1926a6538e52bb626be4411d52fd12eb4496a426 (patch)
treefe7be3d50066ce3ebd0622127fcb362c8a368eed /testpar
parent824ba5e2fde476934df42284271c358b14e1a6af (diff)
downloadhdf5-1926a6538e52bb626be4411d52fd12eb4496a426.zip
hdf5-1926a6538e52bb626be4411d52fd12eb4496a426.tar.gz
hdf5-1926a6538e52bb626be4411d52fd12eb4496a426.tar.bz2
[svn-r9130] Purpose:
bug fix. Description: The test routines only print error messages but not all of them return number of errors detected back to the main routine which always exit with a 0 status. Thus make or shell commands could not detect there were errors. Solution: Changed the test routines to return appropriate number of errors to main routine which in turn exit with the appropriate exit code if errors found. Platforms tested: Tested in Sol and eirene (pp). Misc. update:
Diffstat (limited to 'testpar')
-rw-r--r--testpar/t_mpi.c95
-rw-r--r--testpar/testphdf5.c4
2 files changed, 67 insertions, 32 deletions
diff --git a/testpar/t_mpi.c b/testpar/t_mpi.c
index 2d5da66..62aba13 100644
--- a/testpar/t_mpi.c
+++ b/testpar/t_mpi.c
@@ -37,14 +37,10 @@ int nerrors = 0;
hid_t fapl; /* file access property list */
/* protocols */
-static void test_mpio_overlap_writes(char *filename);
-static void test_mpio_gb_file(char *filename);
-static int parse_options(int argc, char **argv);
-static void usage(void);
#define MPIO_TEST_WRITE_SIZE 1024*1024 /* 1 MB */
-void
+int
test_mpio_overlap_writes(char *filename)
{
int mpi_size, mpi_rank;
@@ -53,7 +49,7 @@ test_mpio_overlap_writes(char *filename)
int color, mrc;
MPI_File fh;
int i;
- int vrfyerrs;
+ int vrfyerrs, nerrs;
unsigned char buf[4093]; /* use some prime number for size */
int bufsize = sizeof(buf);
MPI_Offset stride;
@@ -65,6 +61,7 @@ test_mpio_overlap_writes(char *filename)
printf("MPIO independent overlapping writes test on file %s\n",
filename);
+ nerrs = 0;
/* set up MPI parameters */
MPI_Comm_size(MPI_COMM_WORLD,&mpi_size);
MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
@@ -74,7 +71,7 @@ test_mpio_overlap_writes(char *filename)
if (MAINPROCESS)
printf("Need at least 2 processes to run MPIO test.\n");
printf(" -SKIP- \n");
- return;
+ return 0;
}
/* splits processes 0 to n-2 into one comm. and the last one into another */
@@ -153,6 +150,8 @@ test_mpio_overlap_writes(char *filename)
}
if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED)
printf("proc %d: [more errors ...]\n", mpi_rank);
+
+ nerrs += vrfyerrs;
}
/* close file and free the communicator */
@@ -168,6 +167,7 @@ test_mpio_overlap_writes(char *filename)
*/
mrc = MPI_Barrier(MPI_COMM_WORLD);
VRFY((mrc==MPI_SUCCESS), "Sync before leaving test");
+ return (nerrs);
}
@@ -186,7 +186,7 @@ test_mpio_overlap_writes(char *filename)
* Then reads the file back in by reverse order, that is process 0
* reads the data of process n-1 and vice versa.
*/
-void
+int
test_mpio_gb_file(char *filename)
{
int mpi_size, mpi_rank;
@@ -196,6 +196,7 @@ test_mpio_gb_file(char *filename)
int i, j, n;
int vrfyerrs;
int writerrs; /* write errors */
+ int nerrs;
int ntimes; /* how many times */
char *buf = NULL;
char expected;
@@ -204,7 +205,7 @@ test_mpio_gb_file(char *filename)
MPI_Status mpi_stat;
int is_signed, sizeof_mpi_offset;
-
+ nerrs = 0;
/* set up MPI parameters */
MPI_Comm_size(MPI_COMM_WORLD,&mpi_size);
MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
@@ -217,6 +218,10 @@ test_mpio_gb_file(char *filename)
is_signed = ((MPI_Offset)(mpi_off - 1)) < 0;
sizeof_mpi_offset = (int)(sizeof(MPI_Offset));
+ /*
+ * Verify the sizeof MPI_Offset and correctness of handling multiple GB
+ * sizes.
+ */
if (MAINPROCESS){ /* only process 0 needs to check it*/
printf("MPI_Offset is %s %d bytes integeral type\n",
is_signed ? "signed" : "unsigned", (int)sizeof(MPI_Offset));
@@ -263,7 +268,9 @@ test_mpio_gb_file(char *filename)
}
}
- /*================================*/
+ /*
+ * Verify if we can write to a file of multiple GB sizes.
+ */
if (VERBOSE_MED)
printf("MPIO GB file test %s\n", filename);
@@ -317,10 +324,13 @@ test_mpio_gb_file(char *filename)
mrc = MPI_Barrier(MPI_COMM_WORLD);
VRFY((mrc==MPI_SUCCESS), "Sync after writes");
+ /*
+ * Verify if we can read the multiple GB file just created.
+ */
/* open it again to verify the data written */
/* but only if there was no write errors */
printf("MPIO GB file read test %s\n", filename);
- if (writerrs){
+ if (errors_sum(writerrs)>0){
printf("proc %d: Skip read test due to previous write errors\n",
mpi_rank);
goto finish;
@@ -350,6 +360,7 @@ test_mpio_gb_file(char *filename)
if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED)
printf("proc %d: [more errors ...]\n", mpi_rank);
+ nerrs += vrfyerrs;
}
}
@@ -368,6 +379,7 @@ test_mpio_gb_file(char *filename)
finish:
if (buf)
HDfree(buf);
+ return (nerrs);
}
@@ -406,7 +418,7 @@ int test_mpio_1wMr(char *filename, int special_request)
unsigned char writedata[DIMSIZE], readdata[DIMSIZE];
unsigned char expect_val;
int i, irank;
- int nerrors = 0; /* number of errors */
+ int nerrs = 0; /* number of errors */
int atomicity;
MPI_Offset mpi_off;
MPI_Status mpi_stat;
@@ -562,7 +574,7 @@ if (special_request & USEFSYNC){
PRINTID;
printf("read data[%d:%d] got %02x, expect %02x\n", irank, i,
readdata[i], expect_val);
- nerrors++;
+ nerrs++;
}
}
@@ -570,18 +582,11 @@ if (special_request & USEFSYNC){
if (VERBOSE_HI){
PRINTID;
- printf("%d data errors detected\n", nerrors);
- }
-
- {
- int temp;
- MPI_Reduce(&nerrors, &temp, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (mpi_rank == 0 && temp > 0)
- nerrors = temp;
+ printf("%d data errors detected\n", nerrs);
}
mpi_err = MPI_Barrier(MPI_COMM_WORLD);
- return nerrors;
+ return nerrs;
}
@@ -659,6 +664,16 @@ usage(void)
printf("\n");
}
+/*
+ * return the sum of all errors.
+ */
+int errors_sum(nerrs)
+{
+ int temp;
+ MPI_Allreduce(&nerrs, &temp, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ return(temp);
+}
+
int
main(int argc, char **argv)
@@ -671,7 +686,6 @@ main(int argc, char **argv)
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
H5open();
- TestInit(argv[0], NULL, parse_options);
if (parse_options(argc, argv) != 0){
if (MAINPROCESS)
usage();
@@ -692,28 +706,47 @@ main(int argc, char **argv)
MPI_BANNER("MPIO 1 write Many read test...");
ret_code = test_mpio_1wMr(filenames[0], USENONE);
- if (mpi_rank==0 && ret_code > 0)
+ ret_code = errors_sum(ret_code);
+ if (mpi_rank==0 && ret_code > 0){
printf("***FAILED with %d total errors\n", ret_code);
+ nerrors += ret_code;
+ }
/* test atomicity and file sync in high verbose mode only */
/* since they often hang when broken and PHDF5 does not use them. */
- if (VERBOSE_HI){
+ if (VERBOSE_HI){
MPI_BANNER("MPIO 1 write Many read test with atomicity...");
ret_code = test_mpio_1wMr(filenames[0], USEATOM);
- if (mpi_rank==0 && ret_code > 0)
+ ret_code = errors_sum(ret_code);
+ if (mpi_rank==0 && ret_code > 0){
printf("***FAILED with %d total errors\n", ret_code);
+ nerrors += ret_code;
+ }
MPI_BANNER("MPIO 1 write Many read test with file sync...");
ret_code = test_mpio_1wMr(filenames[0], USEFSYNC);
- if (mpi_rank==0 && ret_code > 0)
+ ret_code = errors_sum(ret_code);
+ if (mpi_rank==0 && ret_code > 0){
printf("***FAILED with %d total errors\n", ret_code);
+ nerrors += ret_code;
+ }
}
MPI_BANNER("MPIO File size range test...");
- test_mpio_gb_file(filenames[0]);
+ ret_code = test_mpio_gb_file(filenames[0]);
+ ret_code = errors_sum(ret_code);
+ if (mpi_rank==0 && ret_code > 0){
+ printf("***FAILED with %d total errors\n", ret_code);
+ nerrors += ret_code;
+ }
MPI_BANNER("MPIO independent overlapping writes...");
- test_mpio_overlap_writes(filenames[0]);
+ ret_code = test_mpio_overlap_writes(filenames[0]);
+ ret_code = errors_sum(ret_code);
+ if (mpi_rank==0 && ret_code > 0){
+ printf("***FAILED with %d total errors\n", ret_code);
+ nerrors += ret_code;
+ }
finish:
/* make sure all processes are finished before final report, cleanup
@@ -737,7 +770,7 @@ finish:
/* MPI_Finalize must be called AFTER H5close which may use MPI calls */
MPI_Finalize();
- /* always return 0 as this test is informational only. */
- return(0);
+ /* cannot just return (nerrors) because exit code is limited to 1byte */
+ return(nerrors!=0);
}
diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c
index 3578843..d377b47 100644
--- a/testpar/testphdf5.c
+++ b/testpar/testphdf5.c
@@ -547,6 +547,8 @@ finish:
/* MPI_Finalize must be called AFTER H5close which may use MPI calls */
MPI_Finalize();
- return(nerrors);
+
+ /* cannot just return (nerrors) because exit code is limited to 1byte */
+ return(nerrors!=0);
}