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"
16 int main( int argc, char *argv[] )
19 MPI_Info info1, infodup;
20 int nkeys, nkeysdup, i, vallen, flag, flagdup;
21 char key[MPI_MAX_INFO_KEY], keydup[MPI_MAX_INFO_KEY];
22 char value[MPI_MAX_INFO_VAL], valdup[MPI_MAX_INFO_VAL];
24 MTest_Init( &argc, &argv );
26 MPI_Info_create( &info1 );
27 /* Use only named keys incase the info implementation only supports
28 the predefined keys (e.g., IBM) */
29 MPI_Info_set( info1, (char*)"host", (char*)"myhost.myorg.org" );
30 MPI_Info_set( info1, (char*)"file", (char*)"runfile.txt" );
31 MPI_Info_set( info1, (char*)"soft", (char*)"2:1000:4,3:1000:7" );
33 MPI_Info_dup( info1, &infodup );
35 MPI_Info_get_nkeys( infodup, &nkeysdup );
36 MPI_Info_get_nkeys( info1, &nkeys );
37 if (nkeys != nkeysdup) {
39 printf( "Dup'ed info has a different number of keys; is %d should be %d\n",
42 vallen = MPI_MAX_INFO_VAL;
43 for (i=0; i<nkeys; i++) {
44 /* MPI requires that the keys are in the same order after the dup */
45 MPI_Info_get_nthkey( info1, i, key );
46 MPI_Info_get_nthkey( infodup, i, keydup );
47 if (strcmp(key, keydup)) {
49 printf( "keys do not match: %s should be %s\n", keydup, key );
52 vallen = MPI_MAX_INFO_VAL;
53 MPI_Info_get( info1, key, vallen, value, &flag );
54 MPI_Info_get( infodup, keydup, vallen, valdup, &flagdup );
55 if (!flag || !flagdup) {
57 printf( "Info get failed for key %s\n", key );
59 else if (strcmp( value, valdup )) {
61 printf( "Info values for key %s not the same after dup\n", key );
65 /* Change info and check that infodup does NOT have the new value
66 (ensure that lazy dups are still duped) */
67 MPI_Info_set( info1, (char*)"path", (char*)"/a:/b:/c/d" );
69 MPI_Info_get( infodup, (char*)"path", vallen, value, &flag );
72 printf( "inserting path into info changed infodup\n" );
75 MPI_Info_free( &info1 );
76 MPI_Info_free( &infodup );
78 MTest_Finalize( errs );