Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'v3_8_x'
[simgrid.git] / teshsuite / smpi / mpich-test / env / errhand2.c
1 #include <stdio.h>
2 #include "mpi.h"
3 #include "test.h"
4
5 #ifdef USE_STDARG
6 void errfunc( MPI_Comm *, int *, ... );
7 #else
8 void errfunc( MPI_Comm *, int * );
9 #endif
10
11 /*
12  * Test the reference count semantics of error handlers.
13  */
14 int main( int argc, char *argv[] )
15 {
16     MPI_Errhandler errhandler, olderrhandler;
17     MPI_Comm       newcomm;
18     int            rc, errcnt = 0;
19
20     MPI_Init( &argc, &argv );
21
22     MPI_Comm_dup( MPI_COMM_WORLD, &newcomm );
23     MPI_Errhandler_create( errfunc, &errhandler );
24     MPI_Errhandler_set( newcomm, errhandler );
25     /* Once you set it, you should be able to free it */
26     MPI_Errhandler_free( &errhandler );
27     if (errhandler != MPI_ERRHANDLER_NULL) {
28         printf( "Freed errhandler is not set to NULL\n" );
29         errcnt++;
30     }
31     MPI_Errhandler_get( newcomm, &olderrhandler );
32     MPI_Comm_free( &newcomm );
33
34     /* olderrhandler should now be invalid.  Is it? */
35     /* This test is based on an interpretation of the MPI standard that
36        was subsequently overturned.  See the MPI-1.1 errata.  
37        An Errhandler_get is similar to an MPI_Comm_group (having the 
38        effect of creating a copy to the object). */
39     MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
40     rc = MPI_Errhandler_set( MPI_COMM_WORLD, olderrhandler );
41     /* In the old interpretation, the test is !rc */
42     if (rc) {
43         printf( "Olderrhandler invalid after get and comm freed!\n" );
44         errcnt ++;
45     }
46
47     if (errcnt) 
48         printf( "Found %d errors!\n", errcnt );
49     else
50         printf( " No Errors\n" );
51
52     MPI_Finalize( );
53     return 0;
54 }
55
56 #if defined(USE_STDARG)
57 void errfunc( MPI_Comm *comm, int *err, ...)
58 #else
59 void errfunc( MPI_Comm *comm, int *err)
60 #endif
61 {
62 }