Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename some symbols around Link::isShared to make their purpose clear
[simgrid.git] / teshsuite / smpi / mpich3-test / info / infovallen.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2003 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include "mpi.h"
8 #include <stdio.h>
9 #include <string.h>
10 #include "mpitest.h"
11
12 #define NKEYS 3
13 int main( int argc, char *argv[] )
14 {
15     int errs = 0;
16     MPI_Info info;
17     char *keys[NKEYS] = { (char*)"file", (char*)"soft", (char*)"host" };
18     char *values[NKEYS] = { (char*)"runfile.txt", (char*)"2:1000:4,3:1000:7", 
19                             (char*)"myhost.myorg.org" };
20     char value[MPI_MAX_INFO_VAL];
21     int i, flag, vallen;
22
23     MTest_Init( &argc, &argv );
24
25     MPI_Info_create( &info );
26     /* Use only named keys incase the info implementation only supports
27        the predefined keys (e.g., IBM) */
28     for (i=0; i<NKEYS; i++) {
29         MPI_Info_set( info, keys[i], values[i] );
30     }
31
32     /* Check that all values are present */
33     for (i=0; i<NKEYS; i++) {
34         MPI_Info_get_valuelen( info, keys[i], &vallen, &flag );
35         if (!flag) {
36             errs++;
37             printf( "get_valuelen failed for valid key %s\n", keys[i] );
38         }
39         MPI_Info_get( info, keys[i], MPI_MAX_INFO_VAL, value, &flag );
40         if (!flag) {
41             errs++;
42             printf( "No value for key %s\n", keys[i] );
43         }
44         if (strcmp( value, values[i] )) {
45             errs++;
46             printf( "Incorrect value for key %s\n", keys[i] );
47         }
48         if (strlen(value) != vallen) {
49             errs++;
50             printf( "value_len returned %d but actual len is %d\n", 
51                     vallen, (int) strlen(value) );
52         }
53     }
54
55     MPI_Info_free( &info );
56     
57     MTest_Finalize( errs );
58     MPI_Finalize();
59     return 0;
60   
61 }