Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich3-test / comm / commname.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2001 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7
8 #include "mpi.h"
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include "mpitest.h"
12 #include "mpitestconf.h"
13 #ifdef HAVE_STRING_H
14 #include <string.h>
15 #endif
16
17 int main( int argc, char *argv[] )
18 {
19     int errs = 0;
20     MPI_Comm comm;
21     int cnt, rlen;
22     char name[MPI_MAX_OBJECT_NAME], nameout[MPI_MAX_OBJECT_NAME];
23     MTest_Init( &argc, &argv );
24
25     /* Check world and self firt */
26     nameout[0] = 0;
27     MPI_Comm_get_name( MPI_COMM_WORLD, nameout, &rlen );
28     if (strcmp(nameout,"MPI_COMM_WORLD")) {
29         errs++;
30         printf( "Name of comm world is %s, should be MPI_COMM_WORLD\n", 
31                 nameout );
32     }
33
34     nameout[0] = 0;
35     MPI_Comm_get_name( MPI_COMM_SELF, nameout, &rlen );
36     if (strcmp(nameout,"MPI_COMM_SELF")) {
37         errs++;
38         printf( "Name of comm self is %s, should be MPI_COMM_SELF\n", 
39                 nameout );
40     }
41
42     /* Now, handle other communicators, including world/self */
43     cnt = 0;
44     while (MTestGetComm( &comm, 1 )) {
45         if (comm == MPI_COMM_NULL) continue;
46     
47         sprintf( name, "comm-%d", cnt );
48         cnt++;
49         MPI_Comm_set_name( comm, name );
50         nameout[0] = 0;
51         MPI_Comm_get_name( comm, nameout, &rlen );
52         if (strcmp( name, nameout )) {
53             errs++;
54             printf( "Unexpected name, was %s but should be %s\n",
55                     nameout, name );
56         }
57         
58         MTestFreeComm( &comm );
59     }
60
61     MTest_Finalize( errs );
62     MPI_Finalize();
63     return 0;
64 }