|
Packit Service |
c5cf8c |
/* -*- Mode: C++; c-basic-offset:4 ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2003 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include "mpitestconf.h"
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_IOSTREAM
|
|
Packit Service |
c5cf8c |
// Not all C++ compilers have iostream instead of iostream.h
|
|
Packit Service |
c5cf8c |
#include <iostream>
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_NAMESPACE_STD
|
|
Packit Service |
c5cf8c |
// Those that do often need the std namespace; otherwise, a bare "cout"
|
|
Packit Service |
c5cf8c |
// is likely to fail to compile
|
|
Packit Service |
c5cf8c |
using namespace std;
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#include <iostream.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#include "mpitestcxx.h"
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_STRING_H
|
|
Packit Service |
c5cf8c |
#include <string.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int errs = 0;
|
|
Packit Service |
c5cf8c |
MPI::Info info1, infodup;
|
|
Packit Service |
c5cf8c |
int nkeys, nkeysdup, i, vallen, flag, flagdup;
|
|
Packit Service |
c5cf8c |
char *key, *keydup;
|
|
Packit Service |
c5cf8c |
char *value, *valdup;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
key = new char[MPI::MAX_INFO_KEY];
|
|
Packit Service |
c5cf8c |
keydup = new char[MPI::MAX_INFO_KEY];
|
|
Packit Service |
c5cf8c |
value = new char[MPI::MAX_INFO_VAL];
|
|
Packit Service |
c5cf8c |
valdup = new char[MPI::MAX_INFO_VAL];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
info1 = MPI::Info::Create();
|
|
Packit Service |
c5cf8c |
/* Use only named keys incase the info implementation only supports
|
|
Packit Service |
c5cf8c |
* the predefined keys (e.g., IBM) */
|
|
Packit Service |
c5cf8c |
info1.Set("host", "myhost.myorg.org");
|
|
Packit Service |
c5cf8c |
info1.Set("file", "runfile.txt");
|
|
Packit Service |
c5cf8c |
info1.Set("soft", "2:1000:4,3:1000:7");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
infodup = info1.Dup();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
nkeysdup = infodup.Get_nkeys();
|
|
Packit Service |
c5cf8c |
nkeys = info1.Get_nkeys();
|
|
Packit Service |
c5cf8c |
if (nkeys != nkeysdup) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "Dup'ed info has a different number of keys; is " <<
|
|
Packit Service |
c5cf8c |
nkeysdup << " should be " << nkeys << "\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
vallen = MPI::MAX_INFO_VAL;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < nkeys; i++) {
|
|
Packit Service |
c5cf8c |
/* MPI requires that the keys are in the same order after the dup */
|
|
Packit Service |
c5cf8c |
info1.Get_nthkey(i, key);
|
|
Packit Service |
c5cf8c |
infodup.Get_nthkey(i, keydup);
|
|
Packit Service |
c5cf8c |
if (strcmp(key, keydup)) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "keys do not match: " << keydup << " should be " << key << "\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
vallen = MPI::MAX_INFO_VAL;
|
|
Packit Service |
c5cf8c |
flag = info1.Get(key, vallen, value);
|
|
Packit Service |
c5cf8c |
flagdup = infodup.Get(keydup, vallen, valdup);
|
|
Packit Service |
c5cf8c |
if (!flag || !flagdup) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "Info get failed for key " << key << "\n";
|
|
Packit Service |
c5cf8c |
} else if (strcmp(value, valdup)) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "Info values for key " << key << " not the same after dup\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Change info and check that infodup does NOT have the new value
|
|
Packit Service |
c5cf8c |
* (ensure that lazy dups are still duped) */
|
|
Packit Service |
c5cf8c |
info1.Set("path", "/a:/b:/c/d");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
flag = infodup.Get("path", vallen, value);
|
|
Packit Service |
c5cf8c |
if (flag) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "inserting path into info changed infodup\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
info1.Free();
|
|
Packit Service |
c5cf8c |
infodup.Free();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
delete[]key;
|
|
Packit Service |
c5cf8c |
delete[]keydup;
|
|
Packit Service |
c5cf8c |
delete[]value;
|
|
Packit Service |
c5cf8c |
delete[]valdup;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|