|
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 |
#define NKEYS 3
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int errs = 0;
|
|
Packit Service |
c5cf8c |
MPI::Info info;
|
|
Packit Service |
c5cf8c |
const char *keys[NKEYS] = { "file", "soft", "host" };
|
|
Packit Service |
c5cf8c |
const char *values[NKEYS] = { "runfile.txt", "2:1000:4,3:1000:7",
|
|
Packit Service |
c5cf8c |
"myhost.myorg.org"
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
char *value;
|
|
Packit Service |
c5cf8c |
int i, flag, nkeys;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
value = new char[MPI::MAX_INFO_VAL];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
info = 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 |
for (i = 0; i < NKEYS; i++) {
|
|
Packit Service |
c5cf8c |
info.Set(keys[i], values[i]);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Check that all values are present */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < NKEYS; i++) {
|
|
Packit Service |
c5cf8c |
flag = info.Get(keys[i], MPI::MAX_INFO_VAL, value);
|
|
Packit Service |
c5cf8c |
if (!flag) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "No value for key " << keys[i] << "\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (strcmp(value, values[i])) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "Incorrect value for key " << keys[i] <<
|
|
Packit Service |
c5cf8c |
", got " << value << " expected " << values[i] << "\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Now, change one value and remove another, then check again */
|
|
Packit Service |
c5cf8c |
info.Delete(keys[NKEYS - 1]);
|
|
Packit Service |
c5cf8c |
nkeys = info.Get_nkeys();
|
|
Packit Service |
c5cf8c |
if (nkeys != NKEYS - 1) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "Deleting a key did not change the number of keys\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
values[0] = (char *) "backfile.txt";
|
|
Packit Service |
c5cf8c |
info.Set(keys[0], values[0]);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < NKEYS - 1; i++) {
|
|
Packit Service |
c5cf8c |
flag = info.Get(keys[i], MPI::MAX_INFO_VAL, value);
|
|
Packit Service |
c5cf8c |
if (!flag) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "(after reset) No value for key " << keys[i] << "\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (strcmp(value, values[i])) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
cout << "(after reset) Incorrect value for key " <<
|
|
Packit Service |
c5cf8c |
keys[i] << ", got " << value << " expected " << values[i] << "\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
info.Free();
|
|
Packit Service |
c5cf8c |
delete[]value;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|