1 /* Procedures for recording and printing test results */
7 #if defined(USE_STDARG)
11 static int tests_passed = 0;
12 static int tests_failed = 0;
13 static char failed_tests[255][81];
14 static char suite_name[255];
17 void Test_Init(const char *suite, int rank)
21 sprintf(filename, "%s-%d.out", suite, rank);
22 strncpy(suite_name, suite, 255);
23 fileout = fopen(filename, "w");
25 fprintf( stderr, "Could not open %s on node %d\n", filename, rank );
26 MPI_Abort( MPI_COMM_WORLD, 1 );
29 //MPI_Errhandler_create( Test_Errors_warn, &TEST_ERRORS_WARN );
32 void Test_Message(const char *mess)
34 fprintf(fileout, "[%s]: %s\n", suite_name, mess);
38 void Test_Failed(const char *test)
40 fprintf(fileout, "[%s]: *** Test '%s' Failed! ***\n", suite_name, test);
41 strncpy(failed_tests[tests_failed], test, 81);
46 void Test_Passed(const char *test)
49 fprintf(fileout, "[%s]: Test '%s' Passed.\n", suite_name, test);
55 int Summarize_Test_Results()
58 fprintf(fileout, "For test suite '%s':\n", suite_name);
63 fprintf(fileout, "Of %d attempted tests, %d passed, %d failed.\n",
64 tests_passed + tests_failed, tests_passed, tests_failed);
66 if (tests_failed > 0) {
69 fprintf(fileout, "*** Tests Failed:\n");
70 for (i = 0; i < tests_failed; i++)
71 fprintf(fileout, "*** %s\n", failed_tests[i]);
76 void Test_Finalize( void )
78 //if (TEST_ERRORS_WARN != MPI_ERRHANDLER_NULL)
79 //MPI_Errhandler_free( &TEST_ERRORS_WARN );
87 /* Wait for every process to pass through this point. This test is used
88 to make sure that all processes complete, and that a test "passes" because
89 it executed, not because it some process failed.
91 void Test_Waitforall( void )
93 int m, one, myrank, n;
95 MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
96 MPI_Comm_size( MPI_COMM_WORLD, &n );
98 MPI_Allreduce( &one, &m, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
101 printf( "[%d] Expected %d processes to wait at end, got %d\n", myrank,
105 printf( " No Errors\n" );
109 Handler prints warning messsage and returns. Internal. Not
110 a part of the standard.
112 MPI_Errhandler TEST_ERRORS_WARN ;
115 void Test_Errors_warn( MPI_Comm *comm, int *code, ... )
117 char buf[MPI_MAX_ERROR_STRING];
124 static int in_handler = 0;
127 #ifdef USE_OLDSTYLE_STDARG
130 va_start( Argp, code );
132 string = va_arg(Argp,char *);
134 /* These are only needed for debugging output */
135 file = va_arg(Argp,char *);
136 line = va_arg(Argp,int *);
140 void Test_Errors_warn( MPI_Comm *comm, int *code, char *string, char *file,
143 char buf[MPI_MAX_ERROR_STRING];
144 int myid, result_len;
145 static int in_handler = 0;
148 if (in_handler) return;
151 MPI_Comm_rank( MPI_COMM_WORLD, &myid );
152 //MPI_Error_string( *code, buf, &result_len );
154 /* Generate this information ONLY when debugging MPIR */
155 fprintf( stderr, "%d - File: %s Line: %d\n", myid,
158 fprintf( stderr, "%d - %s : %s\n", myid,
159 string ? string : "<NO ERROR MESSAGE>", buf );