1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2003 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
11 #include "mpitestconf.h"
17 int main( int argc, char *argv[] )
21 char *keys[NKEYS] = { (char*)"file", (char*)"soft", (char*)"host" };
22 char *values[NKEYS] = { (char*)"runfile.txt", (char*)"2:1000:4,3:1000:7",
23 (char*)"myhost.myorg.org" };
24 char value[MPI_MAX_INFO_VAL];
27 MTest_Init( &argc, &argv );
29 MPI_Info_create( &info );
30 /* Use only named keys incase the info implementation only supports
31 the predefined keys (e.g., IBM) */
32 for (i=0; i<NKEYS; i++) {
33 MPI_Info_set( info, keys[i], values[i] );
36 /* Check that all values are present */
37 for (i=0; i<NKEYS; i++) {
38 MPI_Info_get( info, keys[i], MPI_MAX_INFO_VAL, value, &flag );
41 printf( "No value for key %s\n", keys[i] );
43 if (strcmp( value, values[i] )) {
45 printf( "Incorrect value for key %s, got %s expected %s\n",
46 keys[i], value, values[i] );
50 /* Now, change one value and remove another, then check again */
51 MPI_Info_delete( info, keys[NKEYS-1] );
52 MPI_Info_get_nkeys( info, &nkeys );
53 if (nkeys != NKEYS - 1) {
55 printf( "Deleting a key did not change the number of keys\n" );
58 values[0] = (char*)"backfile.txt";
59 MPI_Info_set( info, keys[0], values[0] );
60 for (i=0; i<NKEYS-1; i++) {
61 MPI_Info_get( info, keys[i], MPI_MAX_INFO_VAL, value, &flag );
64 printf( "(after reset) No value for key %s\n", keys[i] );
66 if (strcmp( value, values[i] )) {
68 printf( "(after reset) Incorrect value for key %s, got %s expected %s\n",
69 keys[i], value, values[i] );
73 MPI_Info_free( &info );
74 if (info != MPI_INFO_NULL) {
76 printf( "MPI_Info_free should set info to MPI_INFO_NULL\n" );
79 MTest_Finalize( errs );