1 /* Procedures for recording and printing test results */
8 static int tests_passed = 0;
9 static int tests_failed = 0;
10 static char failed_tests[255][81];
11 static char suite_name[255];
14 void Test_Init( const char *suite, int rank)
18 sprintf(filename, "%s-%d.out", suite, rank);
19 strncpy(suite_name, suite, 255);
20 fileout = fopen(filename, "w");
22 fprintf( stderr, "Could not open %s on node %d\n", filename, rank );
23 MPI_Abort( MPI_COMM_WORLD, 1 );
27 void Test_Message( const char *mess)
29 fprintf(fileout, "[%s]: %s\n", suite_name, mess);
30 if(fileout)fflush(fileout);
33 void Test_Failed(const char *test)
35 fprintf(fileout, "[%s]: *** Test '%s' Failed! ***\n", suite_name, test);
36 strncpy(failed_tests[tests_failed], test, 81);
37 if(fileout)fflush(fileout);
41 void Test_Passed(const char *test)
44 fprintf(fileout, "[%s]: Test '%s' Passed.\n", suite_name, test);
45 if(fileout)fflush(fileout);
50 int Summarize_Test_Results(void)
53 fprintf(fileout, "For test suite '%s':\n", suite_name);
58 fprintf(fileout, "Of %d attempted tests, %d passed, %d failed.\n",
59 tests_passed + tests_failed, tests_passed, tests_failed);
61 if (tests_failed > 0) {
64 fprintf(fileout, "*** Tests Failed:\n");
65 for (i = 0; i < tests_failed; i++)
66 fprintf(fileout, "*** %s\n", failed_tests[i]);
71 void Test_Finalize(void)
73 if(fileout)fflush(fileout);
78 /* Wait for every process to pass through this point. This test is used
79 to make sure that all processes complete, and that a test "passes" because
80 it executed, not because some process failed.
82 void Test_Waitforall(void)
84 int m, one, myrank, n;
86 MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
87 MPI_Comm_size( MPI_COMM_WORLD, &n );
89 MPI_Allreduce( &one, &m, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
92 printf( "[%d] Expected %d processes to wait at end, got %d\n", myrank,
96 printf( " No Errors\n" );