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 in case 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", nkeysdup, nkeys);
41 vallen = MPI_MAX_INFO_VAL;
42 for (i = 0; i < nkeys; i++) {
43 /* MPI requires that the keys are in the same order after the dup */
44 MPI_Info_get_nthkey(info1, i, key);
45 MPI_Info_get_nthkey(infodup, i, keydup);
46 if (strcmp(key, keydup)) {
48 printf("keys do not match: %s should be %s\n", keydup, key);
51 vallen = MPI_MAX_INFO_VAL;
52 MPI_Info_get(info1, key, vallen, value, &flag);
53 MPI_Info_get(infodup, keydup, vallen, valdup, &flagdup);
54 if (!flag || !flagdup) {
56 printf("Info get failed for key %s\n", key);
58 else if (strcmp(value, valdup)) {
60 printf("Info values for key %s not the same after dup\n", key);
64 /* Change info and check that infodup does NOT have the new value
65 * (ensure that lazy dups are still duped) */
66 MPI_Info_set(info1, (char *) "path", (char *) "/a:/b:/c/d");
68 MPI_Info_get(infodup, (char *) "path", vallen, value, &flag);
71 printf("inserting path into info changed infodup\n");
74 MPI_Info_free(&info1);
75 MPI_Info_free(&infodup);