From 64fda9a437fae1adaf1f6df0a8461416997a55a7 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Fri, 9 Jul 2004 01:58:08 +0000 Subject: [PATCH] Unit test for name server. This commit was SVN r1606. --- test/mca/ns/Makefile.am | 26 +++++++++++++++ test/mca/ns/ns.c | 23 -------------- test/mca/ns/test_ns_replica.c | 60 +++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 23 deletions(-) create mode 100644 test/mca/ns/Makefile.am delete mode 100644 test/mca/ns/ns.c create mode 100644 test/mca/ns/test_ns_replica.c diff --git a/test/mca/ns/Makefile.am b/test/mca/ns/Makefile.am new file mode 100644 index 0000000000..ab424862c8 --- /dev/null +++ b/test/mca/ns/Makefile.am @@ -0,0 +1,26 @@ +# -*- makefile -*- +# +# $HEADER$ +# + +include $(top_srcdir)/config/Makefile.options +AM_CPPFLAGS = -I$(top_srcdir)/test/support -DOMPI_ENABLE_DEBUG_OVERRIDE=1 + +noinst_PROGRAMS = \ + test_ns_replica + +test_ns_replica_SOURCES = test_ns_replica.c +test_ns_replica_LDADD = \ + $(top_builddir)/src/class/ompi_object.lo \ + $(top_builddir)/src/util/malloc.lo \ + $(top_builddir)/src/util/output.lo \ + $(top_builddir)/src/util/argv.lo \ + $(top_builddir)/src/util/strncpy.lo \ + $(top_builddir)/src/mca/ns/base/libmca_ns_base.la \ + $(top_builddir)/src/libmpi.la \ + $(top_builddir)/src/threads/mutex.lo \ + $(top_builddir)/src/threads/mutex_pthread.lo \ + $(top_builddir)/src/threads/mutex_spinlock.lo \ + $(top_builddir)/src/threads/mutex_spinwait.lo \ + $(top_builddir)/test/support/libsupport.la +test_ns_replica_DEPENDENCIES = $(test_ns_replica_LDADD) diff --git a/test/mca/ns/ns.c b/test/mca/ns/ns.c deleted file mode 100644 index 25f9cbdcb2..0000000000 --- a/test/mca/ns/ns.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -#include "ns/name_server.h" - -int main(int argc, char **argv) -{ - int i; - uint32_t *foo; - ompi_process_name_t j; - -foo = (uint32_t*) &j; - - for (i=0; i<30; i++) { - j = ompi_process_name_new(); - fprintf(stderr, "name: %x %x\n", foo[0], foo[1]); - } - - for (i=0; i<3; i++) { - j = ompi_process_name_get_range(30000); - fprintf(stderr, "range name: %x %x\n", foo[0], foo[1]); - } - -} diff --git a/test/mca/ns/test_ns_replica.c b/test/mca/ns/test_ns_replica.c new file mode 100644 index 0000000000..7ced39f97b --- /dev/null +++ b/test/mca/ns/test_ns_replica.c @@ -0,0 +1,60 @@ +/* + * unit test for name server replica. + + -------------------------------------------------------------------------- + + Authors: Ralph H. Castain + + -------------------------------------------------------------------------- + +*/ + +#include +#include + +#include "ompi_config.h" + +#include "include/constants.h" +#include "mca/mca.h" +#include "mca/base/base.h" +#include "mca/ns/base/base.h" + +int main(int argc, char **argv) +{ + ompi_process_name_t *test_name; + + /* startup the MCA */ + if (OMPI_SUCCESS == mca_base_open()) { + fprintf(stderr, "MCA started\n"); + } else { + fprintf(stderr, "MCA could not start - please report error to bugs@open-mpi.org\n"); + exit (1); + } + + /* open the name server */ + if (OMPI_SUCCESS == mca_ns_base_open()) { + fprintf(stderr, "NS opened\n"); + } else { + fprintf(stderr, "NS could not open\n"); + exit(1); + } + + /* startup the name server */ + if (NULL == mca_ns_replica_init()) { + fprintf(stderr, "NS could not start\n"); + exit(1); + } else { + fprintf(stderr, "NS started\n"); + } + + /* create a name */ + test_name = ompi_name_server.create_process_name(0, 1, 1); + if (NULL == test_name) { /* got error */ + fprintf(stderr, "create process name failed\n"); + exit(1); + } else { + fprintf(stderr, "got process name: %x %x %x\n", test_name->cellid, test_name->jobid, test_name->vpid); + } + + return(0); +}