|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
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 |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* A simple test program for name service routines. This does not
|
|
Packit Service |
c5cf8c |
* require the MPI library
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdarg.h>
|
|
Packit Service |
c5cf8c |
/* This is incomplete for the purposes of testing */
|
|
Packit Service |
c5cf8c |
typedef struct {
|
|
Packit Service |
c5cf8c |
int handle;
|
|
Packit Service |
c5cf8c |
} MPIR_Info;
|
|
Packit Service |
c5cf8c |
#define MPIR_INFO_NULL ((MPIR_Info *)0)
|
|
Packit Service |
c5cf8c |
#include "namepub.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
void Error(const char *fmat, ...);
|
|
Packit Service |
c5cf8c |
int MPIR_Err_create_code(int old, int kind, const char *fname, int line, int class, ...);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPID_NS_Handle ns;
|
|
Packit Service |
c5cf8c |
char port[1024];
|
|
Packit Service |
c5cf8c |
int rc;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Create a name service */
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Create(MPIR_INFO_NULL, &ns);
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not create name service; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* publish several names */
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Publish(ns, MPIR_INFO_NULL, "name1", "foo$$12");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not publish name1; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Publish(ns, MPIR_INFO_NULL, "namea", "bar--14");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not publish namea; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Publish(ns, MPIR_INFO_NULL, "1-2-3", "testname");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not publish 1-2-3; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Try look ups */
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Lookup(ns, MPIR_INFO_NULL, "name1", port);
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not lookup name1; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (strcmp(port, "foo$$12") != 0) {
|
|
Packit Service |
c5cf8c |
Error("Wrong value for port, got %s\n", port);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Lookup(ns, MPIR_INFO_NULL, "namea", port);
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not lookup namea; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (strcmp(port, "bar--14") != 0) {
|
|
Packit Service |
c5cf8c |
Error("Wrong value for port, got %s\n", port);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Lookup(ns, MPIR_INFO_NULL, "1-2-3", port);
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not lookup 1-2-3; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (strcmp(port, "testname") != 0) {
|
|
Packit Service |
c5cf8c |
Error("Wrong value for port, got %s\n", port);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Try a name that isn't published */
|
|
Packit Service |
c5cf8c |
port[0] = 0;
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Lookup(ns, MPIR_INFO_NULL, "name", port);
|
|
Packit Service |
c5cf8c |
if (!rc) {
|
|
Packit Service |
c5cf8c |
Error("Found port (%s) for unpublished name\n", port);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Publish(ns, MPIR_INFO_NULL, "name 1", "foo 12");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not publish \"name 1\"; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Lookup(ns, MPIR_INFO_NULL, "name 1", port);
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not lookup \"name 1\"; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (strcmp(port, "foo 12") != 0) {
|
|
Packit Service |
c5cf8c |
Error("Wrong value for port, got %s\n", port);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Note that there are some restrictions in the file-based version */
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Publish(ns, MPIR_INFO_NULL, "name/1", "foo/12a");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
/* Allow publish to fail with some names */
|
|
Packit Service |
c5cf8c |
;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Lookup(ns, MPIR_INFO_NULL, "name/1", port);
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not lookup name/1; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (strcmp(port, "foo/12a") != 0) {
|
|
Packit Service |
c5cf8c |
Error("Wrong value for port, got %s\n", port);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Unpublish(ns, MPIR_INFO_NULL, "name/1");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not unpublish name/1; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Try to unpublish the names */
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Unpublish(ns, MPIR_INFO_NULL, "name1");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not unpublish name1; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Unpublish(ns, MPIR_INFO_NULL, "name 1");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not unpublish \"name 1\"; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Unpublish(ns, MPIR_INFO_NULL, "namea");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not unpublish namea; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
rc = MPID_NS_Unpublish(ns, MPIR_INFO_NULL, "1-2-3");
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
Error("Could not unpublish 1-2-3; rc = %d\n", rc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* If we make it to the end, there are no errors */
|
|
Packit Service |
c5cf8c |
printf(" No Errors\n");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
void Error(const char *fmat, ...)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
va_list list;
|
|
Packit Service |
c5cf8c |
va_start(list, fmat);
|
|
Packit Service |
c5cf8c |
vprintf(fmat, list);
|
|
Packit Service |
c5cf8c |
va_end(list);
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
exit(1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef STANDALONE
|
|
Packit Service |
c5cf8c |
int MPIR_Err_create_code(int old, int kind, const char *fname, int line, int class, ...)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
return class;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|