Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / teshsuite / smpi / mpich3-test / info / infotest.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2001 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 /* Simple info test */
7
8 #include "mpi.h"
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include "mpitestconf.h"
12 #ifdef HAVE_STRING_H
13 #include <string.h>
14 #endif
15
16 int main( int argc, char *argv[] )
17 {
18     MPI_Info i1, i2;
19     int errs = 0;
20     char value[64];
21     int flag;
22
23     MPI_Init( &argc, &argv );
24     
25     MPI_Info_create( &i1 );
26     MPI_Info_create( &i2 );
27
28     MPI_Info_set( i1, (char*)"key1", (char*)"value1" );
29     MPI_Info_set( i2, (char*)"key2", (char*)"value2" );
30
31     MPI_Info_get( i1, (char*)"key2", 64, value, &flag );
32     if (flag) {
33         printf( "Found key2 in info1\n" );
34         errs ++;
35     }
36     MPI_Info_get( i1, (char*)"key1", 64, value, &flag );
37     if (!flag) {
38         errs++;
39         printf( "Did not find key1 in info1\n" );
40     }
41     else if (strcmp( value, "value1" )) {
42         errs++;
43         printf( "Found wrong value (%s), expected value1\n", value );
44     }
45
46     MPI_Info_free( &i1 );
47     MPI_Info_free( &i2 );
48     if (errs) {
49         printf( " Found %d errors\n", errs );
50     }
51     else {
52         printf( " No Errors\n" );
53     }
54     MPI_Finalize( );
55     return 0;
56 }