1
1

Remove stale test code. At least we were wise enough to have eliminated this code from the "make check" tree, but almost none of it compiles and of what does compile, nothing seems to really work.

This commit was SVN r15446.
Этот коммит содержится в:
Ralph Castain 2007-07-16 16:34:14 +00:00
родитель 6a1f876e98
Коммит 511457feb5
63 изменённых файлов: 0 добавлений и 17596 удалений

Просмотреть файл

@ -1,22 +0,0 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
SUBDIRS = oob schema
DIST_SUBDIRS = gpr gpr/remote ns oob ras rds rmaps rmgr schema smr

Просмотреть файл

@ -1,131 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
TESTS_ENVIRONMENT = TEST_WRITE_TO_FILE=1
check_PROGRAMS = \
gpr_dt_buffer \
gpr_dt_copy \
gpr_dt_cmp \
gpr_dt_release \
gpr_dt_size \
gpr_dt_print \
gpr_internal_fns \
gpr_mem_leaks \
gpr_overwrite \
gpr_put_get \
gpr_quick_put \
gpr_quick_triggers \
gpr_sub_test \
gpr_threads \
gpr_triggers
TESTS =
gpr_dt_buffer_SOURCES = gpr_dt_buffer.c
gpr_dt_buffer_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_dt_buffer_DEPENDENCIES = $(gpr_dt_buffer_LDADD)
gpr_dt_copy_SOURCES = gpr_dt_copy.c
gpr_dt_copy_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_dt_copy_DEPENDENCIES = $(gpr_dt_copy_LDADD)
gpr_dt_cmp_SOURCES = gpr_dt_cmp.c
gpr_dt_cmp_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_dt_cmp_DEPENDENCIES = $(gpr_dt_cmp_LDADD)
gpr_dt_release_SOURCES = gpr_dt_release.c
gpr_dt_release_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_dt_release_DEPENDENCIES = $(gpr_dt_release_LDADD)
gpr_dt_size_SOURCES = gpr_dt_size.c
gpr_dt_size_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_dt_size_DEPENDENCIES = $(gpr_dt_size_LDADD)
gpr_dt_print_SOURCES = gpr_dt_print.c
gpr_dt_print_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_dt_print_DEPENDENCIES = $(gpr_dt_print_LDADD)
gpr_internal_fns_SOURCES = gpr_internal_fns.c
gpr_internal_fns_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_internal_fns_DEPENDENCIES = $(gpr_internal_fns_LDADD)
gpr_mem_leaks_SOURCES = gpr_mem_leaks.c
gpr_mem_leaks_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_mem_leaks_DEPENDENCIES = $(gpr_mem_leaks_LDADD)
gpr_overwrite_SOURCES = gpr_overwrite.c
gpr_overwrite_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_overwrite_DEPENDENCIES = $(gpr_overwrite_LDADD)
gpr_put_get_SOURCES = gpr_put_get.c
gpr_put_get_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_put_get_DEPENDENCIES = $(gpr_put_get_LDADD)
gpr_threads_SOURCES = gpr_threads.c
gpr_threads_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_threads_DEPENDENCIES = $(gpr_threads_LDADD)
gpr_triggers_SOURCES = gpr_triggers.c
gpr_triggers_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_triggers_DEPENDENCIES = $(gpr_triggers_LDADD)
gpr_quick_put_SOURCES = gpr_quick_put.c
gpr_quick_put_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_quick_put_DEPENDENCIES = $(gpr_quick_put_LDADD)
gpr_quick_triggers= gpr_quick_triggers.c
gpr_quick_triggers_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_quick_triggers_DEPENDENCIES = $(gpr_quick_triggers_LDADD)
gpr_sub_test= gpr_sub_test.c
gpr_sub_test_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_sub_test_DEPENDENCIES = $(gpr_sub_test_LDADD)

Просмотреть файл

@ -1,980 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
#define NUM_ITERS 1
#define NUM_ELEMS 3
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_buffer_t *bufA;
orte_gpr_cmd_flag_t scmd[NUM_ELEMS], dcmd[NUM_ELEMS];
orte_gpr_subscription_id_t ssubid[NUM_ELEMS], dsubid[NUM_ELEMS];
orte_gpr_trigger_id_t strigid[NUM_ELEMS], dtrigid[NUM_ELEMS];
orte_gpr_notify_action_t snotact[NUM_ELEMS], dnotact[NUM_ELEMS];
orte_gpr_trigger_action_t strigact[NUM_ELEMS], dtrigact[NUM_ELEMS];
orte_gpr_notify_msg_type_t snottype[NUM_ELEMS], dnottype[NUM_ELEMS];
orte_gpr_addr_mode_t smode[NUM_ELEMS], dmode[NUM_ELEMS];
size_t i;
int rc;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW");
fprintf(test_out, "OBJ_NEW failed\n");
return false;
}
for(i=0; i<NUM_ELEMS; i++) {
scmd[i] = 0x0f;
ssubid[i] = i;
strigid[i] = i;
snotact[i] = ORTE_GPR_NOTIFY_ANY;
strigact[i] = ORTE_GPR_TRIG_ANY;
snottype[i] = 0x0f;
smode[i] = 0x0f0f;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, scmd, NUM_ELEMS, ORTE_GPR_CMD);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, ssubid, NUM_ELEMS, ORTE_GPR_SUBSCRIPTION_ID);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, strigid, NUM_ELEMS, ORTE_GPR_TRIGGER_ID);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, snotact, NUM_ELEMS, ORTE_GPR_NOTIFY_ACTION);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, strigact, NUM_ELEMS, ORTE_GPR_TRIGGER_ACTION);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, snottype, NUM_ELEMS, ORTE_GPR_NOTIFY_MSG_TYPE);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, smode, NUM_ELEMS, ORTE_GPR_ADDR_MODE);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
size_t count = NUM_ELEMS;
/* buffer is FIFO, so unpack in same order */
rc = orte_dss.unpack(bufA, dcmd, &count, ORTE_GPR_CMD);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dsubid, &count, ORTE_GPR_SUBSCRIPTION_ID);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dtrigid, &count, ORTE_GPR_TRIGGER_ID);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dnotact, &count, ORTE_GPR_NOTIFY_ACTION);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dtrigact, &count, ORTE_GPR_TRIGGER_ACTION);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dnottype, &count, ORTE_GPR_NOTIFY_MSG_TYPE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dmode, &count, ORTE_GPR_ADDR_MODE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
/* all from this iteration are unpacked - check all values */
for(j=0; j<NUM_ELEMS; j++) {
if(scmd[j] != dcmd[j] ||
ssubid[j] != dsubid[j] ||
strigid[j] != dtrigid[j] ||
snotact[j] != dnotact[j] ||
strigact[j] != dtrigact[j] ||
snottype[j] != dnottype[j] ||
smode[j] != dmode[j]) {
fprintf(test_out, "test unstructured values: invalid values returned\n");
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
return false;
}
return (true);
}
static bool test_keyval(void)
{
orte_buffer_t *bufA;
int rc;
size_t i;
int16_t i16;
int32_t i32;
orte_gpr_keyval_t *src[NUM_ELEMS];
orte_gpr_keyval_t *dst[NUM_ELEMS];
orte_data_value_t *dval, *sval;
/* setup source array of keyvals */
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_keyval_t);
asprintf(&(src[i]->key), "%lu", (unsigned long)i);
src[i]->value = OBJ_NEW(orte_data_value_t);
sval = src[i]->value;
sval->type = ((i % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
i16 = i;
i32 = i;
if (ORTE_INT16 == sval->type) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_KEYVAL);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed with error %s\n",
ORTE_ERROR_NAME(rc));
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
size_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_KEYVAL);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack (KEYVAL) failed on iteration %lu with error %s\n",
(unsigned long)i, ORTE_ERROR_NAME(rc));
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if (0 != strcmp(src[j]->key, dst[j]->key)) {
fprintf(test_out, "test9: invalid results key mismatch from unpack\n");
return(false);
}
if (src[j]->value->type != dst[j]->value->type) {
fprintf(test_out, "test9: invalid results type mismatch from unpack\n");
return(false);
}
sval = src[j]->value;
dval = dst[j]->value;
if (ORTE_EQUAL != orte_dss.compare(sval->data, dval->data, sval->type)) {
fprintf(test_out, "test keyval: invalid value returned\n");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
static bool test_val(void)
{
orte_buffer_t *bufA;
int rc;
size_t i, j, k;
int16_t i16;
int32_t i32;
orte_gpr_value_t *src[NUM_ELEMS];
orte_gpr_value_t *dst[NUM_ELEMS];
orte_data_value_t *dval, *sval;
/* test gpr_value */
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_value_t);
src[i]->segment = strdup("test-segment");
src[i]->num_tokens = (i % 10) + 1; /* ensure there is always at least one */
src[i]->tokens = (char**)malloc(src[i]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->num_tokens; j++) {
src[i]->tokens[j] = strdup("test-token");
}
src[i]->cnt = (i % 20) + 1;
src[i]->keyvals = (orte_gpr_keyval_t**)malloc(src[i]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->cnt; j++) {
src[i]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
dval = src[i]->keyvals[j]->value;
asprintf(&((src[i]->keyvals[j])->key), "%lu",
(unsigned long) j);
dval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (dval->type == ORTE_INT16) {
i16 = j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW");
fprintf(test_out, "OBJ_NEW failed\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_VALUE);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
size_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_VALUE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(0 != strcmp(src[j]->segment, dst[j]->segment) ||
src[j]->num_tokens != dst[j]->num_tokens ||
src[j]->cnt != dst[j]->cnt) {
fprintf(test_out, "test1_val: invalid results from unpack");
return(false);
}
for (k=0; k<src[j]->num_tokens; k++) {
if (0 != strcmp(src[j]->tokens[k], dst[j]->tokens[k])) {
fprintf(test_out, "test1_val: invalid results (tokens) from unpack");
return(false);
}
}
for (k=0; k < src[j]->cnt; k++) {
if (0 != strcmp((src[j]->keyvals[k])->key,
(dst[j]->keyvals[k])->key)) {
fprintf(test_out, "test1_val: invalid results (keyvalues) from unpack");
return(false);
}
dval = dst[j]->keyvals[k]->value;
sval = src[j]->keyvals[k]->value;
if (sval->type != dval->type) {
fprintf(test_out, "test1_val: invalid results (keyvalue types) from unpack");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, dval->type)) {
fprintf(stderr, "test1_val: orte_dss.compare failed\n");
return(false);
}
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
return false;
}
return(true);
}
static bool test_sub(void)
{
orte_buffer_t *bufA;
int rc;
size_t i, j, k, m;
orte_gpr_subscription_t *src[NUM_ELEMS];
orte_gpr_subscription_t *dst[NUM_ELEMS];
/* test gpr_subscription */
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to NUM_ELEMS+1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to NUM_ELEMS */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to NUM_ELEMS */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
/* source data set, now create buffer and pack source data */
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_SUBSCRIPTION);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "test_sub pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
size_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_SUBSCRIPTION);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "test_sub unpack failed with return code %d (count=%lu)\n", rc, (unsigned long) count);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if ((NULL == src[j]->name && NULL != dst[j]->name) ||
(NULL != src[j]->name && NULL == dst[j]->name)
) {
fprintf(test_out, "test_sub invalid results from unpack\n");
return(false);
}
if ((NULL != src[j]->name &&
0 != strcmp(src[j]->name, dst[j]->name)) ||
src[j]->id != dst[j]->id ||
src[j]->action != dst[j]->action ||
src[j]->cnt != dst[j]->cnt
) {
fprintf(test_out, "test_sub: invalid results from unpack\n");
return(false);
}
/* now compare each of the size/cnt dependent values */
for (k=0; k<src[j]->cnt; k++) {
if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) {
fprintf(test_out, "test_sub: invalid results (value num_tokens) from unpack\n");
return(false);
}
for (m=0; m < src[j]->values[k]->num_tokens; m++) {
if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) {
fprintf(test_out, "test_sub: invalid results (tokens) from unpack\n");
return(false);
}
}
if (src[j]->values[k]->cnt != dst[j]->values[k]->cnt) {
fprintf(test_out, "test_sub: invalid results (value cnt) from unpack\n");
return(false);
}
for (m=0; m < src[j]->values[k]->cnt; m++) {
if (0 != strcmp(src[j]->values[k]->keyvals[m]->key,
dst[j]->values[k]->keyvals[m]->key)) {
fprintf(test_out, "test_sub: invalid results (keys) from unpack\n");
return(false);
}
}
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
static bool test_trig(void)
{
orte_buffer_t *bufA;
int rc;
size_t i, j, k, m;
orte_gpr_trigger_t *src[NUM_ELEMS];
orte_gpr_trigger_t *dst[NUM_ELEMS];
/* test gpr_trigger */
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to NUM_ELEMS+1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to NUM_ELEMS */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to NUM_ELEMS */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
/* source data set, now create buffer and pack source data */
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_TRIGGER);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "test_trig pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
size_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_TRIGGER);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "test_trig unpack failed with return code %d (count=%lu)\n", rc, (unsigned long) count);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if ((NULL == src[j]->name && NULL != dst[j]->name) ||
(NULL != src[j]->name && NULL == dst[j]->name)
) {
fprintf(test_out, "test_trig invalid results from unpack\n");
return(false);
}
if ((NULL != src[j]->name &&
0 != strcmp(src[j]->name, dst[j]->name)) ||
src[j]->id != dst[j]->id ||
src[j]->action != dst[j]->action ||
src[j]->cnt != dst[j]->cnt
) {
fprintf(test_out, "test_trig: invalid results from unpack\n");
return(false);
}
/* now compare each of the size/cnt dependent values */
for (k=0; k<src[j]->cnt; k++) {
if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) {
fprintf(test_out, "test_trig: invalid results (value num_tokens) from unpack\n");
return(false);
}
for (m=0; m < src[j]->values[k]->num_tokens; m++) {
if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) {
fprintf(test_out, "test_trig: invalid results (tokens) from unpack\n");
return(false);
}
}
if (src[j]->values[k]->cnt != dst[j]->values[k]->cnt) {
fprintf(test_out, "test_trig: invalid results (value cnt) from unpack\n");
return(false);
}
for (m=0; m < src[j]->values[k]->cnt; m++) {
if (0 != strcmp(src[j]->values[k]->keyvals[m]->key,
dst[j]->values[k]->keyvals[m]->key)) {
fprintf(test_out, "test_trig: invalid results (keys) from unpack\n");
return(false);
}
}
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
static bool test_notify_data(void)
{
orte_buffer_t *bufA;
int rc;
size_t i, j, k, l, n;
orte_data_value_t *sdv, *ddv;
int32_t i32;
orte_gpr_value_t *value, **sval, **dval;
orte_gpr_notify_data_t *src[NUM_ELEMS];
orte_gpr_notify_data_t *dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to NUM_ELEMS-1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0-NUM_ELEMS-1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0-NUM_ELEMS-1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
/* source data set, now create buffer and pack source data */
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_NOTIFY_DATA);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "test_notify_data pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
size_t count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_NOTIFY_DATA);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "test_notify_data unpack failed with return code %d (count=%lu)\n", rc, (unsigned long) count);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if (
src[j]->id != dst[j]->id ||
src[j]->cnt != dst[j]->cnt ||
src[j]->remove != dst[j]->remove
) {
fprintf(test_out, "test_notify_data: invalid results from unpack\n");
return(false);
}
if ((NULL == src[j]->target && NULL != dst[j]->target) ||
(NULL != src[j]->target && NULL == dst[j]->target)) {
fprintf(test_out, "test_notify_data failed with mismatched NULL targets\n");
return(false);
}
if (NULL != src[j]->target && NULL != dst[j]->target &&
0 != strcmp(src[j]->target, dst[j]->target)) {
fprintf(test_out, "test_notify_data failed with mismatched target names\n");
return(false);
}
/* now compare each value of the cnt depedant values */
sval = (orte_gpr_value_t**)(src[j]->values)->addr;
dval = (orte_gpr_value_t**)(dst[j]->values)->addr;
/* because of the way this has been done, we can safely assume
* that these are in the same relative order
*/
for (k=0, n=0; n < src[j]->cnt &&
k < (src[j]->values)->size; k++) {
if (NULL != sval[k]) {
n++;
if (sval[k]->addr_mode != dval[k]->addr_mode) {
fprintf(test_out, "test_notify_data: invalid results (values-addr-mode) from unpack\n");
return(false);
}
if (0 != strcmp(sval[k]->segment, dval[k]->segment)) {
fprintf(test_out, "test_notify_data: invalid results (values-segment) from unpack\n");
return(false);
}
if (sval[k]->num_tokens != dval[k]->num_tokens) {
fprintf(test_out, "test_notify_data: invalid results (values-num_tokens) from unpack\n");
return(false);
}
for (l=0; l<sval[k]->num_tokens; l++) {
if (0 != strcmp(sval[k]->tokens[l], dval[k]->tokens[l])) {
fprintf(test_out, "test_notify_data: invalid results (values-tokens) from unpack\n");
return(false);
}
} /* for each token inside each grp value */
if (sval[k]->cnt != dval[k]->cnt) {
fprintf(test_out, "test_notify_data: invalid results (values-cnt (of keyval pairs)) from unpack\n");
return(false);
}
for (l=0; l< sval[k]->cnt; l++) {
if (0 != strcmp(sval[k]->keyvals[l]->key, dval[k]->keyvals[l]->key)) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-key) from unpack\n");
return(false);
}
sdv = sval[k]->keyvals[l]->value;
ddv = dval[k]->keyvals[l]->value;
if (sdv->type != ddv->type) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-type) from unpack\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(sdv->data, ddv->data, sdv->type)) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-value.i32) from unpack\n");
return(false);
}
}/* for each keyvalpair inside each grp value */
} /* for each grp value */
}
} /* for each ELEMENT */
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}

Просмотреть файл

@ -1,588 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd, *dcmd;
orte_gpr_subscription_id_t ssubid, *dsubid;
orte_gpr_trigger_id_t strigid, *dtrigid;
orte_gpr_notify_action_t snotact, *dnotact;
orte_gpr_trigger_action_t strigact, *dtrigact;
orte_gpr_notify_msg_type_t snottype, *dnottype;
orte_gpr_addr_mode_t smode, *dmode;
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
if (ORTE_SUCCESS != orte_dss.copy((void**)&dcmd, &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_CMD returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dcmd, &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_CMD yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dsubid, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dsubid, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_SUBSCRIPTION_ID yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigid, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dtrigid, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_TRIGGER_ID yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnotact, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dnotact, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_NOTIFY_ACTION yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigact, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dtrigact, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_TRIGGER_ACTION yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnottype, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dnottype, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_NOTIFY_MSG_TYPE yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dmode, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dmode, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_ADDR_MODE yielded incorrect value\n");
return(false);
}
return (true);
}
static bool test_keyval(void)
{
int16_t i16=10;
int32_t i32=2345;
orte_gpr_keyval_t *src, *dst;
orte_data_value_t *sval;
orte_gpr_keyval_t src1 = { {OBJ_CLASS(orte_gpr_keyval_t),0},"test-key-2",NULL};
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.copy dynamic keyval returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.compare dynamic keyval failed\n");
return(false);
}
src1.value = OBJ_NEW(orte_data_value_t);
sval = src1.value;
sval->type = ORTE_INT32;
if (ORTE_SUCCESS != orte_dss.set(sval, &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.set int32 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, &src1, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.copy static keyval returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst, &src1, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.compare static keyval failed\n");
return(false);
}
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src, *dst;
orte_gpr_value_t value = { {OBJ_CLASS(orte_gpr_value_t),0},
ORTE_GPR_TOKENS_AND,
"test-segment", 1, NULL, 0, NULL };
orte_gpr_keyval_t *keyvals;
orte_gpr_keyval_t keyval = { {OBJ_CLASS(orte_gpr_keyval_t),0},"dumb-key",NULL};
orte_data_value_t *dval, *sval;
size_t j;
int16_t i16;
int32_t i32;
return true; /* no comparison function defined yet */
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
dval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
dval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (dval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.copy dynamic value returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.compare dynamic value failed\n");
return(false);
}
OBJ_RELEASE(dst);
value.keyvals = &keyvals;
keyvals = &keyval;
keyval.value = OBJ_NEW(orte_data_value_t);
sval = keyval.value;
sval->type = ORTE_INT32;
sval->data = &i32;
i32 = 23456;
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, &value, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.copy static value returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst, &value, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.compare static value failed\n");
return(false);
}
OBJ_RELEASE(dst);
return(true);
}
static bool test_sub(void)
{
size_t i, j, k;
orte_gpr_subscription_t *src[2];
orte_gpr_subscription_t *dst[2];
return true; /* no comparison function defined yet */
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(test_out, "test_sub copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(stderr, "orte_dss.compare sub failed\n");
return(false);
}
}
return (true);
}
static bool test_trig(void)
{
size_t i, j, k;
orte_gpr_trigger_t *src[2];
orte_gpr_trigger_t *dst[2];
return true; /* no comparison function defined yet */
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(test_out, "test_trig copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(stderr, "orte_dss.compare trig failed\n");
return(false);
}
}
return (true);
}
static bool test_notify_data(void)
{
size_t i, j, k;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
orte_gpr_notify_data_t *dst[2];
return true; /* no comparison function defined yet */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(test_out, "test_notify_data copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(stderr, "orte_dss.compare notify_data failed\n");
return(false);
}
} /* for each ELEMENT */
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}

Просмотреть файл

@ -1,832 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd, *dcmd;
orte_gpr_subscription_id_t ssubid, *dsubid;
orte_gpr_trigger_id_t strigid, *dtrigid;
orte_gpr_notify_action_t snotact, *dnotact;
orte_gpr_trigger_action_t strigact, *dtrigact;
orte_gpr_notify_msg_type_t snottype, *dnottype;
orte_gpr_addr_mode_t smode, *dmode;
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
if (ORTE_SUCCESS != orte_dss.copy((void**)&dcmd, &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_CMD returned error\n");
return(false);
}
if (*dcmd != scmd) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_CMD yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dsubid, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
if (*dsubid != ssubid) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_SUBSCRIPTION_ID yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigid, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
if (*dtrigid != strigid) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ID yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnotact, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
if (*dnotact != snotact) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_ACTION yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigact, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
if (*dtrigact != strigact) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ACTION yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnottype, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
if (*dnottype != snottype) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_MSG_TYPE yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dmode, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
if (*dmode != smode) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_ADDR_MODE yielded incorrect value\n");
return(false);
}
return (true);
}
static bool test_keyval(void)
{
int16_t i16=10;
int32_t i32=2345;
orte_gpr_keyval_t *src, *dst;
orte_data_value_t *dval, *sval;
orte_gpr_keyval_t src1 = { {OBJ_CLASS(orte_gpr_keyval_t),0},"test-key-2",NULL};
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.copy dynamic keyval returned error\n");
return(false);
}
if (0 != strcmp(src->key, dst->key)) {
fprintf(stderr, "orte_dss.copy dynamic keyval string mismatch\n");
return(false);
}
sval = src->value;
dval = dst->value;
if (sval->type != dval->type) {
fprintf(stderr, "orte_dss.copy dynamic keyval type mismatch\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy dynamic keyval data mismatch\n");
return(false);
}
OBJ_RELEASE(dst);
src1.value = OBJ_NEW(orte_data_value_t);
sval = src1.value;
sval->type = ORTE_INT32;
if (ORTE_SUCCESS != orte_dss.set(sval, &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.set int32 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, &src1, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.copy static keyval returned error\n");
return(false);
}
if (0 != strcmp(src1.key, dst->key)) {
fprintf(stderr, "orte_dss.copy static keyval string mismatch\n");
return(false);
}
sval = src1.value;
dval = dst->value;
if (sval->type != dval->type) {
fprintf(stderr, "orte_dss.copy static keyval type mismatch\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy static keyval data mismatch\n");
return(false);
}
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src, *dst;
orte_gpr_value_t value = { {OBJ_CLASS(orte_gpr_value_t),0},
ORTE_GPR_TOKENS_AND,
"test-segment", 1, NULL, 0, NULL };
orte_gpr_keyval_t *keyvals;
orte_gpr_keyval_t keyval = { {OBJ_CLASS(orte_gpr_keyval_t),0},"dumb-key",NULL};
orte_data_value_t *dval, *sval;
size_t j;
int16_t i16;
int32_t i32;
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
dval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
dval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (dval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.copy dynamic value returned error\n");
return(false);
}
if (src->addr_mode != dst->addr_mode) {
fprintf(stderr, "orte_dss.copy dynamic value addr_mode mismatch\n");
return(false);
}
if (0 != strcmp(src->segment, dst->segment)) {
fprintf(stderr, "orte_dss.copy dynamic value segment mismatch\n");
return(false);
}
if (src->num_tokens != dst->num_tokens) {
fprintf(stderr, "orte_dss.copy dynamic value num_tokens mismatch\n");
return(false);
}
for (j=0; j < src->num_tokens; j++) {
if (0 != strcmp(src->tokens[j], dst->tokens[j])) {
fprintf(stderr, "orte_dss.copy dynamic value token mismatch\n");
return(false);
}
}
if (src->cnt != dst->cnt) {
fprintf(stderr, "orte_dss.copy dynamic value cnt mismatch\n");
return(false);
}
for (j=0; j < src->cnt; j++) {
if (0 != strcmp(src->keyvals[j]->key, dst->keyvals[j]->key)) {
fprintf(stderr, "orte_dss.copy dynamic value key mismatch\n");
return(false);
}
sval = src->keyvals[j]->value;
dval = dst->keyvals[j]->value;
if (sval->type != dval->type) {
fprintf(stderr, "orte_dss.copy dynamic value data type mismatch\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, sval->type)) {
fprintf(stderr, "orte_dss.copy dynamic value data mismatch\n");
return(false);
}
}
OBJ_RELEASE(dst);
value.keyvals = &keyvals;
keyvals = &keyval;
keyval.value = OBJ_NEW(orte_data_value_t);
sval = keyval.value;
sval->type = ORTE_INT32;
sval->data = &i32;
i32 = 23456;
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, &value, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.copy static value returned error\n");
return(false);
}
if (value.addr_mode != dst->addr_mode) {
fprintf(stderr, "orte_dss.copy static value addr_mode mismatch\n");
return(false);
}
if (0 != strcmp(value.segment, dst->segment)) {
fprintf(stderr, "orte_dss.copy static value segment mismatch\n");
return(false);
}
if (value.num_tokens != dst->num_tokens) {
fprintf(stderr, "orte_dss.copy static value num_tokens mismatch\n");
return(false);
}
for (j=0; j < value.num_tokens; j++) {
if (0 != strcmp(value.tokens[j], dst->tokens[j])) {
fprintf(stderr, "orte_dss.copy static value token mismatch\n");
return(false);
}
}
if (value.cnt != dst->cnt) {
fprintf(stderr, "orte_dss.copy static value cnt mismatch\n");
return(false);
}
for (j=0; j < value.cnt; j++) {
if (0 != strcmp(value.keyvals[j]->key, dst->keyvals[j]->key)) {
fprintf(stderr, "orte_dss.copy static value key mismatch\n");
return(false);
}
sval = value.keyvals[j]->value;
dval = dst->keyvals[j]->value;
if (sval->type != dval->type) {
fprintf(stderr, "orte_dss.copy static value data type mismatch\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, sval->type)) {
fprintf(stderr, "orte_dss.copy static value data mismatch\n");
return(false);
}
}
OBJ_RELEASE(dst);
return(true);
}
static bool test_sub(void)
{
size_t i, j, k, m;
orte_gpr_subscription_t *src[2];
orte_gpr_subscription_t *dst[2];
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(test_out, "test_sub copy failed\n");
return(false);
}
if ((NULL == src[j]->name && NULL != dst[j]->name) ||
(NULL != src[j]->name && NULL == dst[j]->name)
) {
fprintf(test_out, "test_sub invalid name results\n");
return(false);
}
if ((NULL != src[j]->name &&
0 != strcmp(src[j]->name, dst[j]->name)) ||
src[j]->id != dst[j]->id ||
src[j]->action != dst[j]->action ||
src[j]->cnt != dst[j]->cnt
) {
fprintf(test_out, "test_sub: invalid values\n");
return(false);
}
/* now compare each of the size/cnt dependent values */
for (k=0; k<src[j]->cnt; k++) {
if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) {
fprintf(test_out, "test_sub: invalid results (value num_tokens)\n");
return(false);
}
for (m=0; m < src[j]->values[k]->num_tokens; m++) {
if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) {
fprintf(test_out, "test_sub: invalid results (tokens)\n");
return(false);
}
}
if (src[j]->values[k]->cnt != dst[j]->values[k]->cnt) {
fprintf(test_out, "test_sub: invalid results (value cnt)\n");
return(false);
}
for (m=0; m < src[j]->values[k]->cnt; m++) {
if (0 != strcmp(src[j]->values[k]->keyvals[m]->key,
dst[j]->values[k]->keyvals[m]->key)) {
fprintf(test_out, "test_sub: invalid results (keys)\n");
return(false);
}
}
}
}
return (true);
}
static bool test_trig(void)
{
size_t i, j, k, m;
orte_gpr_trigger_t *src[2];
orte_gpr_trigger_t *dst[2];
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(test_out, "test_trig copy failed\n");
return(false);
}
if ((NULL == src[j]->name && NULL != dst[j]->name) ||
(NULL != src[j]->name && NULL == dst[j]->name)
) {
fprintf(test_out, "test_trig invalid name results\n");
return(false);
}
if ((NULL != src[j]->name &&
0 != strcmp(src[j]->name, dst[j]->name)) ||
src[j]->id != dst[j]->id ||
src[j]->action != dst[j]->action ||
src[j]->cnt != dst[j]->cnt
) {
fprintf(test_out, "test_trig: invalid value results\n");
return(false);
}
/* now compare each of the size/cnt dependent values */
for (k=0; k<src[j]->cnt; k++) {
if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) {
fprintf(test_out, "test_trig: invalid results (value num_tokens)\n");
return(false);
}
for (m=0; m < src[j]->values[k]->num_tokens; m++) {
if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) {
fprintf(test_out, "test_trig: invalid results (tokens)\n");
return(false);
}
}
if (src[j]->values[k]->cnt != dst[j]->values[k]->cnt) {
fprintf(test_out, "test_trig: invalid results (value cnt)\n");
return(false);
}
for (m=0; m < src[j]->values[k]->cnt; m++) {
if (0 != strcmp(src[j]->values[k]->keyvals[m]->key,
dst[j]->values[k]->keyvals[m]->key)) {
fprintf(test_out, "test_trig: invalid results (keys)\n");
return(false);
}
}
}
}
return (true);
}
static bool test_notify_data(void)
{
size_t i, j, k, l, n;
orte_data_value_t *sdv, *ddv;
int32_t i32;
orte_gpr_value_t *value, **sval, **dval;
orte_gpr_notify_data_t *src[2];
orte_gpr_notify_data_t *dst[2];
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(test_out, "test_notify_data copy failed\n");
return(false);
}
if (
src[j]->id != dst[j]->id ||
src[j]->cnt != dst[j]->cnt ||
src[j]->remove != dst[j]->remove
) {
fprintf(test_out, "test_notify_data: invalid values\n");
return(false);
}
if ((NULL == src[j]->target && NULL != dst[j]->target) ||
(NULL != src[j]->target && NULL == dst[j]->target)) {
fprintf(test_out, "test_notify_data failed with mismatched NULL targets\n");
return(false);
}
if (NULL != src[j]->target && NULL != dst[j]->target &&
0 != strcmp(src[j]->target, dst[j]->target)) {
fprintf(test_out, "test_notify_data failed with mismatched target names\n");
return(false);
}
/* now compare each value of the cnt depedant values */
sval = (orte_gpr_value_t**)(src[j]->values)->addr;
dval = (orte_gpr_value_t**)(dst[j]->values)->addr;
/* because of the way this has been done, we can safely assume
* that these are in the same relative order
*/
for (k=0, n=0; n < src[j]->cnt &&
k < (src[j]->values)->size; k++) {
if (NULL != sval[k]) {
n++;
if (sval[k]->addr_mode != dval[k]->addr_mode) {
fprintf(test_out, "test_notify_data: invalid results (values-addr-mode)\n");
return(false);
}
if (0 != strcmp(sval[k]->segment, dval[k]->segment)) {
fprintf(test_out, "test_notify_data: invalid results (values-segment)\n");
return(false);
}
if (sval[k]->num_tokens != dval[k]->num_tokens) {
fprintf(test_out, "test_notify_data: invalid results (values-num_tokens)\n");
return(false);
}
for (l=0; l<sval[k]->num_tokens; l++) {
if (0 != strcmp(sval[k]->tokens[l], dval[k]->tokens[l])) {
fprintf(test_out, "test_notify_data: invalid results (values-tokens)\n");
return(false);
}
} /* for each token inside each grp value */
if (sval[k]->cnt != dval[k]->cnt) {
fprintf(test_out, "test_notify_data: invalid results (values-cnt (of keyval pairs))\n");
return(false);
}
for (l=0; l< sval[k]->cnt; l++) {
if (0 != strcmp(sval[k]->keyvals[l]->key, dval[k]->keyvals[l]->key)) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-key)\n");
return(false);
}
sdv = sval[k]->keyvals[l]->value;
ddv = dval[k]->keyvals[l]->value;
if (sdv->type != ddv->type) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-type)\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(sdv->data, ddv->data, sdv->type)) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-value.i32)\n");
return(false);
}
}/* for each keyvalpair inside each grp value */
} /* for each grp value */
}
} /* for each ELEMENT */
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}

Просмотреть файл

@ -1,635 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *stderr;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
stderr = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd;
orte_gpr_subscription_id_t ssubid;
orte_gpr_trigger_id_t strigid;
orte_gpr_notify_action_t snotact;
orte_gpr_trigger_action_t strigact;
orte_gpr_notify_msg_type_t snottype;
orte_gpr_addr_mode_t smode;
char *output;
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
if (ORTE_EQUAL != orte_dss.print(&output, NULL, &scmd, ORTE_GPR_CMD)) {
fprintf(stderr, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for gpr cmd\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for gpr cmd: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for subscription\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for subscription: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for trigger id\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for trigger id: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for notify action\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for notify action: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for trigger action\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for trigger action: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for notify message type\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for notify message type: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for notify message type\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for notify message type: %s\n", output);
free(output);
return (true);
}
static bool test_keyval(void)
{
int16_t i16=10;
orte_gpr_keyval_t *src;
orte_data_value_t *sval;
char *output;
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_KEYVAL returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_KEYVAL\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_KEYVAL: %s\n", output);
free(output);
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src;
orte_data_value_t *sval;
size_t j;
int16_t i16;
int32_t i32;
char *output;
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
sval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
sval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (sval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_VALUE returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_VALUE\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_VALUE: %s\n", output);
free(output);
return(true);
}
static bool test_sub(void)
{
size_t i, j, k;
orte_gpr_subscription_t *src[2];
char *output;
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_SUBSCRIPTION returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_SUBSCRIPTION\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_SUBSCRIPTION: %s\n", output);
free(output);
}
return (true);
}
static bool test_trig(void)
{
size_t i, j, k;
orte_gpr_trigger_t *src[2];
char *output;
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src[j], ORTE_GPR_TRIGGER)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_TRIGGER returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_TRIGGER\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_TRIGGER: %s\n", output);
free(output);
}
return (true);
}
static bool test_notify_data(void)
{
size_t i, j, k;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
char *output;
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(stderr, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_NOTIFY_DATA returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_NOTIFY_DATA\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_NOTIFY_DATA: %s\n", output);
free(output);
} /* for each ELEMENT */
return (true);
}
static bool test_notify_msg(void)
{
size_t i, j, k;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
orte_gpr_notify_message_t *msg;
char *output;
msg = OBJ_NEW(orte_gpr_notify_message_t);
msg->msg_type = 2;
msg->target = strdup("nonsense-msg");
msg->id = 1;
msg->remove = false;
msg->cnt = 2;
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(stderr, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
/* add the data object to the pointer array */
orte_pointer_array_add(&i, msg->data, src[i]);
} /* for each data */
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, msg, ORTE_GPR_NOTIFY_MSG)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_NOTIFY_MSG returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_NOTIFY_MSG\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_NOTIFY_MSG: %s\n", output);
free(output);
return (true);
}

Просмотреть файл

@ -1,561 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd, *dcmd;
orte_gpr_subscription_id_t ssubid, *dsubid;
orte_gpr_trigger_id_t strigid, *dtrigid;
orte_gpr_notify_action_t snotact, *dnotact;
orte_gpr_trigger_action_t strigact, *dtrigact;
orte_gpr_notify_msg_type_t snottype, *dnottype;
orte_gpr_addr_mode_t smode, *dmode;
orte_data_value_t *dval2, dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
dval2 = OBJ_NEW(orte_data_value_t);
dval2->type = ORTE_GPR_CMD;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval2->data), &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_CMD returned error\n");
return(false);
}
orte_dss.release(dval2);
if (NULL != dval2->data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_CMD failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dsubid, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
dval.type = ORTE_GPR_SUBSCRIPTION_ID;
dval.data = dsubid;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_SUBSCRIPTION_ID failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigid, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
dval.type = ORTE_GPR_TRIGGER_ID;
dval.data = dtrigid;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_TRIGGER_ID failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnotact, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
dval.type = ORTE_GPR_NOTIFY_ACTION;
dval.data = dnotact;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_NOTIFY_ACTION failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigact, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
dval.type = ORTE_GPR_TRIGGER_ACTION;
dval.data = dtrigact;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_TRIGGER_ACTION failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnottype, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
dval.type = ORTE_GPR_NOTIFY_MSG_TYPE;
dval.data = dnottype;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_NOTIFY_MSG_TYPE failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dmode, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
dval.type = ORTE_GPR_ADDR_MODE;
dval.data = dmode;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_ADDR_MODE failed to NULL pointer\n");
return(false);
}
return (true);
}
static bool test_keyval(void)
{
int32_t i16=2345;
orte_gpr_keyval_t *src;
orte_data_value_t *sval, dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
dval.type = ORTE_GPR_KEYVAL;
dval.data = src;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_KEYVAL failed to NULL pointer\n");
return(false);
}
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src;
orte_gpr_keyval_t *keyvals;
orte_data_value_t *sval, dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
size_t j;
int16_t i16;
int32_t i32;
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
sval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
sval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (sval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
dval.type = ORTE_GPR_VALUE;
dval.data = src;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_KEYVAL failed to NULL pointer\n");
return(false);
}
return(true);
}
static bool test_sub(void)
{
size_t i, j, k;
orte_gpr_subscription_t *src[2];
orte_gpr_subscription_t *dst[2];
return true; /* no comparison function defined yet */
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(test_out, "test_sub copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(stderr, "orte_dss.compare sub failed\n");
return(false);
}
}
return (true);
}
static bool test_trig(void)
{
size_t i, j, k;
orte_gpr_trigger_t *src[2];
orte_gpr_trigger_t *dst[2];
return true; /* no comparison function defined yet */
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(test_out, "test_trig copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(stderr, "orte_dss.compare trig failed\n");
return(false);
}
}
return (true);
}
static bool test_notify_data(void)
{
size_t i, j, k;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
orte_gpr_notify_data_t *dst[2];
return true; /* no comparison function defined yet */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(test_out, "test_notify_data copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(stderr, "orte_dss.compare notify_data failed\n");
return(false);
}
} /* for each ELEMENT */
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}

Просмотреть файл

@ -1,644 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd;
orte_gpr_subscription_id_t ssubid;
orte_gpr_trigger_id_t strigid;
orte_gpr_notify_action_t snotact;
orte_gpr_trigger_action_t strigact;
orte_gpr_notify_msg_type_t snottype;
orte_gpr_addr_mode_t smode;
size_t sz;
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
if (ORTE_SUCCESS != orte_dss.size(&sz, &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_CMD returned error\n");
return(false);
}
if (sz != sizeof(scmd)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_CMD returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_CMD returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(scmd)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_CMD returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
if (sz != sizeof(ssubid)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION_ID returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION_ID returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(ssubid)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION_ID returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
if (sz != sizeof(strigid)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ID returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ID returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(strigid)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ID returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
if (sz != sizeof(snotact)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_ACTION returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_ACTION returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(snotact)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_ACTION returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
if (sz != sizeof(strigact)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ACTION returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ACTION returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(strigact)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ACTION returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
if (sz != sizeof(snottype)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_MSG_TYPE returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_MSG_TYPE returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(snottype)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_MSG_TYPE returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
if (sz != sizeof(smode)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_ADDR_MODE returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_ADDR_MODE returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(smode)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_ADDR_MODE returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_keyval(void)
{
int16_t i16=10;
int32_t i32=2345;
orte_gpr_keyval_t *src;
orte_data_value_t *sval;
orte_gpr_keyval_t src1 = { {OBJ_CLASS(orte_gpr_keyval_t),0},"test-key-2",NULL};
size_t sz;
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.size dynamic keyval returned error\n");
return(false);
}
src1.value = OBJ_NEW(orte_data_value_t);
sval = src1.value;
sval->type = ORTE_INT32;
if (ORTE_SUCCESS != orte_dss.set(sval, &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.set int32 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &src1, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.size static keyval returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.size keyval with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_keyval_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_KEYVAL returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src;
orte_gpr_value_t value = { {OBJ_CLASS(orte_gpr_value_t),0},
ORTE_GPR_TOKENS_AND,
"test-segment", 1, NULL, 0, NULL };
orte_gpr_keyval_t *keyvals;
orte_gpr_keyval_t keyval = { {OBJ_CLASS(orte_gpr_keyval_t),0},"dumb-key",NULL};
orte_data_value_t *dval, *sval;
size_t j, sz;
int16_t i16;
int32_t i32;
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
dval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
dval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (dval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
if (ORTE_SUCCESS != orte_dss.size(&sz, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.size dynamic value returned error\n");
return(false);
}
value.keyvals = &keyvals;
keyvals = &keyval;
keyval.value = OBJ_NEW(orte_data_value_t);
sval = keyval.value;
sval->type = ORTE_INT32;
sval->data = &i32;
i32 = 23456;
if (ORTE_SUCCESS != orte_dss.size(&sz, &value, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.size static value returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.size keyval with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_value_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_VALUE returned wrong size for NULL pointer\n");
return(false);
}
return(true);
}
static bool test_sub(void)
{
size_t i, j, k, sz;
orte_gpr_subscription_t *src[2];
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.size(&sz, src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(test_out, "test_sub size failed\n");
return(false);
}
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_SUBSCRIPTION)) {
fprintf(stderr, "orte_dss.size sub with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_subscription_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_trig(void)
{
size_t i, j, k, sz;
orte_gpr_trigger_t *src[2];
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.size(&sz, src[j], ORTE_GPR_TRIGGER)) {
fprintf(test_out, "test_trig size failed\n");
return(false);
}
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_TRIGGER)) {
fprintf(stderr, "orte_dss.size trig with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_subscription_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_notify_data(void)
{
size_t i, j, k, sz;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.size(&sz, src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(test_out, "test_notify_data size failed\n");
return(false);
}
} /* for each ELEMENT */
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_NOTIFY_DATA)) {
fprintf(stderr, "orte_dss.size notify_data with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_notify_data_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_DATA returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}

Просмотреть файл

@ -1,403 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "opal/runtime/opal.h"
#include "orte/orte_constants.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/runtime/runtime.h"
#include "orte/util/proc_info.h"
#include "orte/util/sys_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/gpr.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "orte/mca/gpr/replica/functional_layer/gpr_replica_fn.h"
#include "orte/mca/gpr/replica/communications/gpr_replica_comm.h"
#include "orte/mca/gpr/replica/transition_layer/gpr_replica_tl.h"
int main(int argc, char **argv)
{
int rc;
size_t num_names;
size_t i;
char *tmp=NULL, *tmp2=NULL, *names[15], *keys[5];
orte_gpr_replica_segment_t *seg=NULL;
orte_gpr_replica_itag_t itag[10], itag2, *itaglist;
orte_gpr_replica_container_t *cptr=NULL;
orte_gpr_keyval_t *kptr=NULL;
orte_gpr_replica_itagval_t *iptr;
int16_t i16;
int32_t i32;
/* ENSURE THE REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* do a select on the registry components */
if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(stderr, "GPR selected\n");
} else {
fprintf(stderr, "GPR could not select\n");
exit (1);
}
/* initialize the pointer variables */
for (i=0; i < 15; i++) names[i]=NULL;
for (i=0; i < 5; i++) keys[i] = NULL;
/* Now do the tests */
fprintf(stderr, "going to find seg\n");
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_seg(&seg, true, "test-segment"))) {
fprintf(stderr, "gpr_test: find_seg failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: find_seg passed\n");
}
orte_gpr.dump_all(0);
fprintf(stderr, "creating tags\n");
for (i=0; i<10; i++) {
asprintf(&tmp, "test-tag-%lu", (unsigned long) i);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_itag(&itag[i], seg, tmp))) {
fprintf(stderr, "gpr_test: create_itag failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: create_itag passed\n");
}
free(tmp);
}
fprintf(stderr, "lookup tags\n");
for (i=0; i<10; i++) {
asprintf(&tmp, "test-tag-%lu", (unsigned long) i);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dict_lookup(&itag2, seg, tmp)) ||
itag2 != itag[i]) {
fprintf(stderr, "gpr_test: lookup failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: lookup passed\n");
}
free(tmp);
}
fprintf(stderr, "reverse lookup tags\n");
for (i=0; i<10; i++) {
asprintf(&tmp2, "test-tag-%lu", (unsigned long) i);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dict_reverse_lookup(&tmp, seg, itag[i])) ||
0 != strcmp(tmp2, tmp)) {
fprintf(stderr, "gpr_test: reverse lookup failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: reverse lookup passed\n");
}
free(tmp);
free(tmp2);
}
fprintf(stderr, "delete tags\n");
for (i=0; i<10; i++) {
asprintf(&tmp, "test-tag-%lu", (unsigned long) i);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_delete_itag(seg, tmp))) {
fprintf(stderr, "gpr_test: delete tag failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: delete tag passed\n");
}
free(tmp);
}
fprintf(stderr, "get itag list\n");
for (i=0; i < 14; i++) {
asprintf(&names[i], "dummy%lu", (unsigned long) i);
}
names[14] = NULL;
num_names = 0;
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_itag_list(&itaglist, seg,
names, &num_names))) {
fprintf(stderr, "gpr_test: get itag list failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: get itag list passed\n");
}
fprintf(stderr, "number of names found %lu\n",
(unsigned long) num_names);
for (i=0; i < num_names; i++) {
fprintf(stderr, "\tname %s itag %lu\n", names[i],
(unsigned long) itaglist[i]);
}
fprintf(stderr, "creating container\n");
if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_container(&cptr, seg,
3, itaglist))) {
fprintf(stderr, "gpr_test: create_container failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: create_container passed\n");
}
orte_gpr.dump_all(0);
fprintf(stderr, "itags for container\n");
for (i=0; i < cptr->num_itags; i++) {
fprintf(stderr, "\tindex %lu itag %lu\n", (unsigned long) i,
(unsigned long) cptr->itags[i]);
}
fprintf(stderr, "add keyval\n");
kptr = OBJ_NEW(orte_gpr_keyval_t);
kptr->key = strdup("stupid-value");
kptr->value = OBJ_NEW(orte_data_value_t);
kptr->value->type = ORTE_INT16;
i16 = 21;
orte_dss.copy(&(kptr->value->data), &i16, ORTE_INT16);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_add_keyval(&iptr, seg, cptr, kptr))) {
fprintf(stderr, "gpr_test: add keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: add keyval passed\n");
}
OBJ_RELEASE(kptr);
orte_gpr.dump_all(0);
fprintf(stderr, "search container for single entry\n");
kptr = OBJ_NEW(orte_gpr_keyval_t);
kptr->key = strdup("stupid-value");
kptr->value = OBJ_NEW(orte_data_value_t);
kptr->value->type = ORTE_STRING;
kptr->value->data = strdup("try-string-value");
orte_gpr_replica_create_itag(&itag2, seg, kptr->key);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_search_container(ORTE_GPR_REPLICA_OR,
&itag2, 1, cptr) ||
0 >= orte_gpr_replica_globals.num_srch_ival)) {
fprintf(stderr, "gpr_test: search container for single entry failed - returned %s for itag %lu\n",
ORTE_ERROR_NAME(rc), (unsigned long) itag2);
return -1;
} else {
fprintf(stderr, "gpr_test: search container for single entry passed\n");
}
OBJ_RELEASE(kptr);
fprintf(stderr, "update single keyval\n");
kptr = OBJ_NEW(orte_gpr_keyval_t);
kptr->key = strdup("stupid-value");
kptr->value = OBJ_NEW(orte_data_value_t);
kptr->value->type = ORTE_STRING;
kptr->value->data =strdup("try-string-value");
if (ORTE_SUCCESS != (rc = orte_gpr_replica_update_keyval(&iptr, seg, cptr, kptr))) {
fprintf(stderr, "gpr_test: update single keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: update single keyval passed\n");
}
OBJ_RELEASE(kptr);
orte_gpr.dump_all(0);
fprintf(stderr, "add multiple keyvals to a container\n");
for (i=0; i < 10; i++) {
kptr = OBJ_NEW(orte_gpr_keyval_t);
kptr->key = strdup("stupid-value");
kptr->value = OBJ_NEW(orte_data_value_t);
kptr->value->type = ORTE_INT16;
i16 = i * 100;
orte_dss.copy(&(kptr->value->data), &i16, ORTE_INT16);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_add_keyval(&iptr, seg, cptr, kptr))) {
fprintf(stderr, "gpr_test: add keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: add keyval passed\n");
}
OBJ_RELEASE(kptr);
}
orte_gpr.dump_all(0);
kptr = OBJ_NEW(orte_gpr_keyval_t);
kptr->key = strdup("stupid-value");
kptr->value = OBJ_NEW(orte_data_value_t);
kptr->value->type = ORTE_INT32;
i32 = 123456;
orte_dss.copy(&(kptr->value->data), &i32, ORTE_INT32);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_itag(&itag2, seg, kptr->key))) {
fprintf(stderr, "gpr_internal_fns: update multiple keyvals - failed to get itag with error %s\n",
ORTE_ERROR_NAME(rc));
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_search_container(ORTE_GPR_REPLICA_OR,
&itag2, 1, cptr))) {
fprintf(stderr, "gpr_internal_fns: update multiple keyvals - failed to find itag with error %s\n",
ORTE_ERROR_NAME(rc));
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_update_keyval(&iptr, seg, cptr, kptr))) {
fprintf(stderr, "gpr_test: update multiple keyvals failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: update multiple keyvals passed\n");
}
OBJ_RELEASE(kptr);
orte_gpr.dump_all(0);
fprintf(stderr, "check itag list\n");
if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_XAND, 0, NULL, 10, itaglist)) {
fprintf(stderr, "check_itag_list: trivial NULL case passed\n");
} else {
fprintf(stderr, "check_itag_list: trivial NULL case failed\n");
}
if (!orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_XAND, 5, itaglist, 10, itaglist)) {
fprintf(stderr, "check_itag_list: trivial mismatched xand case passed\n");
} else {
fprintf(stderr, "check_itag_list: trivial mismatched xand case failed\n");
}
if (!orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_AND, 10, itaglist, 5, itaglist)) {
fprintf(stderr, "check_itag_list: trivial mismatched and case passed\n");
} else {
fprintf(stderr, "check_itag_list: trivial mismatched and case failed\n");
}
if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_XAND, 10, itaglist, 10, itaglist)) {
fprintf(stderr, "check_itag_list: non-trivial xand case passed\n");
} else {
fprintf(stderr, "check_itag_list: non-trivial xand case failed\n");
}
if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_AND, 5, itaglist, 10, itaglist)) {
fprintf(stderr, "check_itag_list: non-trivial and case passed\n");
} else {
fprintf(stderr, "check_itag_list: non-trivial and case failed\n");
}
if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_OR, 5, itaglist, 10, itaglist)) {
fprintf(stderr, "check_itag_list: non-trivial or case passed\n");
} else {
fprintf(stderr, "check_itag_list: non-trivial or case failed\n");
}
if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_XOR, 10, itaglist, 5, itaglist)) {
fprintf(stderr, "check_itag_list: non-trivial or case passed\n");
} else {
fprintf(stderr, "check_itag_list: non-trivial or case failed\n");
}
fprintf(stderr, "\ncheck events prior to releasing segment to clear action records\n");
orte_gpr_replica_check_events();
fprintf(stderr, "\nreleasing segment\n");
if (ORTE_SUCCESS != (rc = orte_gpr_replica_release_segment(&seg)) ||
NULL != seg) {
fprintf(stderr, "gpr_test: release segment failed with error code %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(stderr, "gpr_test: release segment passed\n");
}
fprintf(stderr, "now finalize and see if all memory cleared\n");
for (i=0; i < 15; i++) {
if (NULL != names[i]) free(names[i]);
}
for (i=0; i < 5; i++) {
if (NULL != keys[i]) free(keys[i]);
}
free(itaglist);
/* finalize the gpr component */
orte_gpr_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}

Просмотреть файл

@ -1,280 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "orte/mca/schema/schema.h"
#include "orte/mca/schema/base/base.h"
#include "orte/mca/ns/base/base.h"
#include "orte/mca/soh/base/base.h"
#include "orte/mca/rmgr/base/base.h"
#include "support.h"
#include "orte/class/orte_pointer_array.h"
#include "dps/dps.h"
#include "runtime/runtime.h"
#include "util/proc_info.h"
#include "util/sys_info.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/gpr.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std";
int main(int argc, char **argv)
{
int rc;
size_t i, cnt;
char *names[15], *keys[5];
orte_gpr_value_t **values, *val;
test_init("test_gpr_replica");
/* test_out = fopen( "test_gpr_replica_out", "w+" ); */
test_out = stderr;
if( test_out == NULL ) {
test_failure("gpr_test couldn't open test file failed");
test_finalize();
exit(1);
}
/* ENSURE THE REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* Open up the output streams */
if (!opal_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads -
* and reset otherwise.
*/
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
opal_malloc_init();
/* Ensure the system_info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_sys_info())) {
return rc;
}
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start\n");
exit (1);
}
/* startup the dps */
if (OMPI_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else {
fprintf(test_out, "DPS could not start\n");
exit (1);
}
/* startup the name services */
if (OMPI_SUCCESS == orte_ns_base_open()) {
fprintf(test_out, "NS started\n");
} else {
fprintf(test_out, "NS could not start\n");
exit (1);
}
/* startup the soh */
if (OMPI_SUCCESS == orte_soh_base_open()) {
fprintf(test_out, "SOH started\n");
} else {
fprintf(test_out, "SOH could not start\n");
exit (1);
}
/* startup the rmgr */
if (OMPI_SUCCESS == orte_rmgr_base_open()) {
fprintf(test_out, "RMGR started\n");
} else {
fprintf(test_out, "RMGR could not start\n");
exit (1);
}
/* startup the schema */
if (OMPI_SUCCESS == orte_schema_base_open()) {
fprintf(test_out, "SCHEMA started\n");
} else {
fprintf(test_out, "SCHEMA could not start\n");
exit (1);
}
/* startup the registry */
if (OMPI_SUCCESS == orte_gpr_base_open()) {
fprintf(test_out, "GPR started\n");
} else {
fprintf(test_out, "GPR could not start\n");
exit (1);
}
/* do a select on the registry components */
if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(test_out, "GPR selected\n");
} else {
fprintf(test_out, "GPR could not select\n");
exit (1);
}
fprintf(stderr, "do a put of a value with multiple keyvals\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 20;
val->segment = strdup("test-put-segment");
val->num_tokens = 14;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 14; i++) {
asprintf(&(val->tokens[i]), "dummy%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(20*sizeof(orte_gpr_keyval_t*));
for (i=0; i<20; i++) {
val->keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
asprintf(&((val->keyvals[i])->key), "stupid-test-%lu",
(unsigned long) i);
(val->keyvals[i])->type = ORTE_UINT32;
(val->keyvals[i])->value.ui32 = (uint32_t)i;
}
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(test_out, "gpr_test: put 1 value/multiple keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put 1 value/multiple keyval failed");
test_finalize();
return rc;
} else {
fprintf(test_out, "gpr_test: put 1 value/multiple keyval passed\n");
}
OBJ_RELEASE(val);
fprintf(stderr, "do a get\n");
names[0] = strdup("dummy0");
names[1] = NULL;
keys[0] = strdup("stupid-test-1");
keys[1] = strdup("stupid-test-3");
keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8");
keys[4] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment",
names, keys,
&cnt, &values))) {
fprintf(test_out, "gpr_test: get failed with error code %s\n",
ORTE_ERROR_NAME(rc));
test_failure("gpr_test: get failed");
test_finalize();
return rc;
} else {
fprintf(test_out, "gpr_test: get passed\n");
}
/* cleanup the results */
free(names[0]);
for (i=0; i < 4; i++) free(keys[i]);
for (i=0; i < cnt; i++) {
OBJ_RELEASE(values[i]);
}
free(values);
fprintf(stderr, "put multiple copies of same entry in single container\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 1;
val->segment = strdup("test-put-segment");
val->num_tokens = 5;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 5; i++) {
asprintf(&(val->tokens[i]), "multi-dum-dum-%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
val->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
(val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->type = ORTE_STRING;
(val->keyvals[0])->value.strptr = strdup("try-string-value");
for (i = 0; i < 10; i++) {
fprintf(stderr, "\tputting copy %lu\n", (unsigned long) i);
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(test_out, "gpr_test: put multiple copies of one keyval in a container failed with error code %s\n",
ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put multiple copies of one keyval in a container failed");
test_finalize();
return rc;
}
}
OBJ_RELEASE(val);
fprintf(stderr, "generate a trigger event\n");
fprintf(stderr, "now finalize and see if all memory cleared\n");
orte_gpr_base_close();
orte_dps_close();
orte_sys_info_finalize();
orte_proc_info_finalize();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
fclose( test_out );
/* result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_gpr_replica failed");
}
*/
test_finalize();
return(0);
}

Просмотреть файл

@ -1,425 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include "orte/mca/schema/schema.h"
#include "orte/mca/schema/base/base.h"
#include "orte/mca/ns/base/base.h"
#include "orte/mca/soh/base/base.h"
#include "orte/mca/rmgr/base/base.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "util/proc_info.h"
#include "util/sys_info.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/ns_types.h"
#include "orte/mca/gpr/gpr.h"
#include "dps/dps.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "orte/mca/gpr/replica/functional_layer/gpr_replica_fn.h"
#include "orte/mca/gpr/replica/communications/gpr_replica_comm.h"
#include "orte/mca/gpr/replica/transition_layer/gpr_replica_tl.h"
/* output files needed by the test */
static FILE *test_out=NULL;
/**
* Struct for holding information
*/
struct test_node_t {
/** Base object */
opal_list_item_t super;
/** String node name */
char *node_name;
/** String of the architecture for the node. This is permitted to
be NULL if it is not known. */
char *node_arch;
/** The cell ID of this node */
orte_cellid_t node_cellid;
/** State of this node; see include/orte_types.h */
orte_node_state_t node_state;
/** A "soft" limit on the number of slots available on the node.
This will typically correspond to the number of physical CPUs
that we have been allocated on this note and would be the
"ideal" number of processes for us to launch. */
size_t node_slots;
/** How many processes have already been launched, used by one or
more jobs on this node. */
size_t node_slots_inuse;
/** This represents the number of slots we (the allocator) are
attempting to allocate to the current job - or the number of
slots allocated to a specific job on a query for the jobs
allocations */
size_t node_slots_alloc;
/** A "hard" limit (if set -- a value of 0 implies no hard limit)
on the number of slots that can be allocated on a given
node. This is for some environments (e.g. grid) there may be
fixed limits on the number of slots that can be used.
This value also could have been a boolean - but we may want to
allow the hard limit be different than the soft limit - in
other words allow the node to be oversubscribed up to a
specified limit. For example, if we have two processors, we
may want to allow up to four processes but no more. */
size_t node_slots_max;
};
/**
* Convenience typedef
*/
typedef struct test_node_t test_node_t;
static void test_node_construct(test_node_t* node)
{
node->node_name = NULL;
node->node_arch = NULL;
node->node_cellid = 0;
node->node_state = ORTE_NODE_STATE_UNKNOWN;
node->node_slots = 0;
node->node_slots_alloc = 0;
node->node_slots_inuse = 0;
node->node_slots_max = 0;
}
static void test_node_destruct(test_node_t* node)
{
if (NULL != node->node_name) {
free(node->node_name);
}
if (NULL != node->node_arch) {
free(node->node_arch);
}
}
OBJ_CLASS_INSTANCE(
test_node_t,
opal_list_item_t,
test_node_construct,
test_node_destruct);
static int test_overwrite(opal_list_t* nodes);
int main(int argc, char **argv)
{
opal_list_t nodes;
test_node_t *node;
int i, rc;
/* test_out = fopen( "test_gpr_replica_out", "w+" ); */
test_out = stderr;
if( test_out == NULL ) {
test_failure("gpr_test couldn't open test file failed");
test_finalize();
exit(1);
}
/* ENSURE THE REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* Open up the output streams */
if (!opal_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads -
* and reset otherwise.
*/
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
opal_malloc_init();
/* Ensure the system_info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_sys_info())) {
return rc;
}
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start\n");
exit (1);
}
/* startup the dps */
if (OMPI_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else {
fprintf(test_out, "DPS could not start\n");
exit (1);
}
/* startup the name services */
if (OMPI_SUCCESS == orte_ns_base_open()) {
fprintf(test_out, "NS started\n");
} else {
fprintf(test_out, "NS could not start\n");
exit (1);
}
/* startup the soh */
if (OMPI_SUCCESS == orte_soh_base_open()) {
fprintf(test_out, "SOH started\n");
} else {
fprintf(test_out, "SOH could not start\n");
exit (1);
}
/* startup the rmgr */
if (OMPI_SUCCESS == orte_rmgr_base_open()) {
fprintf(test_out, "RMGR started\n");
} else {
fprintf(test_out, "RMGR could not start\n");
exit (1);
}
/* startup the schema */
if (OMPI_SUCCESS == orte_schema_base_open()) {
fprintf(test_out, "SCHEMA started\n");
} else {
fprintf(test_out, "SCHEMA could not start\n");
exit (1);
}
/* startup the registry */
if (OMPI_SUCCESS == orte_gpr_base_open()) {
fprintf(test_out, "GPR started\n");
} else {
fprintf(test_out, "GPR could not start\n");
exit (1);
}
/* do a select on the registry components */
if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(test_out, "GPR selected\n");
} else {
fprintf(test_out, "GPR could not select\n");
exit (1);
}
/* setup a node list */
OBJ_CONSTRUCT(&nodes, opal_list_t);
for (i=0; i < 5; i++) {
node = OBJ_NEW(test_node_t);
asprintf(&(node->node_name), "node-%d", i);
asprintf(&(node->node_arch), "arch-%d", i);
node->node_cellid = 0;
node->node_state = ORTE_NODE_STATE_UP;
node->node_slots = i;
node->node_slots_alloc = i%2;
node->node_slots_inuse = i % 3;
node->node_slots_max = i * 5;
opal_list_append(&nodes, &node->super);
}
fprintf(test_out, "putting initial set of values on registry\n");
if (ORTE_SUCCESS != (rc = test_overwrite(&nodes))) {
fprintf(test_out, "initial put of values failed with error %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(test_out, "initial put of values successful\n");
}
orte_gpr.dump_all(0);
fprintf(test_out, "changing values for overwrite test\n");
/* change the arch, state, and slots_inuse values */
for (i=0, node = (test_node_t*)opal_list_get_first(&nodes);
node != (test_node_t*)opal_list_get_end(&nodes);
node = (test_node_t*)opal_list_get_next(node), i++) {
free(node->node_arch);
asprintf(&(node->node_arch), "new-arch-%d", i*10);
node->node_state = ORTE_NODE_STATE_DOWN;
node->node_slots_inuse = node->node_slots_inuse * 20;
}
fprintf(test_out, "putting second set of values on registry to test overwrite\n");
if (ORTE_SUCCESS != (rc = test_overwrite(&nodes))) {
fprintf(test_out, "second put of values failed with error %s\n",
ORTE_ERROR_NAME(rc));
return rc;
} else {
fprintf(test_out, "second put of values successful\n");
}
orte_gpr.dump_all(0);
fprintf(stderr, "now finalize and see if all memory cleared\n");
while (NULL != (node = (test_node_t*)opal_list_remove_first(&nodes))) {
OBJ_RELEASE(node);
}
OBJ_DESTRUCT(&nodes);
orte_dps_close();
orte_sys_info_finalize();
orte_proc_info_finalize();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
fclose( test_out );
test_finalize();
return(0);
}
int test_overwrite(opal_list_t* nodes)
{
opal_list_item_t* item;
orte_gpr_value_t **values;
int rc;
test_node_t* node;
size_t i, j, num_values;
num_values = opal_list_get_size(nodes);
if (0 >= num_values) {
return ORTE_ERR_BAD_PARAM;
}
values = (orte_gpr_value_t**)malloc(num_values * sizeof(orte_gpr_value_t*));
if (NULL == values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
for (i=0; i < num_values; i++) {
orte_gpr_value_t* value = values[i] = OBJ_NEW(orte_gpr_value_t);
if (NULL == value) {
for (j=0; j < i; j++) {
OBJ_RELEASE(values[j]);
}
free(values);
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value->addr_mode = ORTE_GPR_OVERWRITE;
value->segment = strdup(ORTE_NODE_SEGMENT);
value->cnt = 6;
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt*sizeof(orte_gpr_keyval_t*));
if (NULL == value->keyvals) {
for (j=0; j < i; j++) {
OBJ_RELEASE(values[j]);
}
free(values);
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
for (j=0; j < value->cnt; j++) {
value->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value->keyvals[j]) {
for (j=0; j <= i; j++) {
OBJ_RELEASE(values[j]);
}
free(values);
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
}
}
for(i=0, item = opal_list_get_first(nodes);
i < num_values && item != opal_list_get_end(nodes);
i++, item = opal_list_get_next(item)) {
orte_gpr_value_t* value = values[i];
node = (test_node_t*)item;
j = 0;
(value->keyvals[j])->key = strdup(ORTE_NODE_NAME_KEY);
(value->keyvals[j])->type = ORTE_STRING;
(value->keyvals[j])->value.strptr = strdup(node->node_name);
++j;
(value->keyvals[j])->key = strdup(ORTE_NODE_ARCH_KEY);
(value->keyvals[j])->type = ORTE_STRING;
if (NULL != node->node_arch) {
(value->keyvals[j])->value.strptr = strdup(node->node_arch);
} else {
(value->keyvals[j])->value.strptr = strdup("");
}
++j;
(value->keyvals[j])->key = strdup(ORTE_NODE_STATE_KEY);
(value->keyvals[j])->type = ORTE_NODE_STATE;
(value->keyvals[j])->value.node_state = node->node_state;
++j;
(value->keyvals[j])->key = strdup(ORTE_CELLID_KEY);
(value->keyvals[j])->type = ORTE_CELLID;
(value->keyvals[j])->value.cellid = node->node_cellid;
++j;
(value->keyvals[j])->key = strdup(ORTE_NODE_SLOTS_KEY);
(value->keyvals[j])->type = ORTE_UINT32;
(value->keyvals[j])->value.ui32 = node->node_slots;
++j;
(value->keyvals[j])->key = strdup(ORTE_NODE_SLOTS_MAX_KEY);
(value->keyvals[j])->type = ORTE_UINT32;
(value->keyvals[j])->value.ui32 = node->node_slots_max;
/* setup index/keys for this node */
rc = orte_schema.get_node_tokens(&value->tokens, &value->num_tokens, node->node_cellid, node->node_name);
if (ORTE_SUCCESS != rc) {
for (j=0; j <= i; j++) {
OBJ_RELEASE(values[j]);
}
free(values);
return rc;
}
}
/* try the insert */
rc = orte_gpr.put(num_values, values);
for (j=0; j < num_values; j++) {
OBJ_RELEASE(values[j]);
}
free(values);
return rc;
}

Просмотреть файл

@ -1,468 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/orte_constants.h"
#include "orte/mca/schema/schema.h"
#include "orte/mca/schema/base/base.h"
#include "orte/mca/ns/base/base.h"
#include "orte/mca/soh/base/base.h"
#include "orte/mca/rmgr/base/base.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/runtime/runtime.h"
#include "orte/util/proc_info.h"
#include "orte/util/sys_info.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "orte/mca/gpr/replica/functional_layer/gpr_replica_fn.h"
#include "orte/mca/gpr/replica/communications/gpr_replica_comm.h"
#include "orte/mca/gpr/replica/transition_layer/gpr_replica_tl.h"
int main(int argc, char **argv)
{
int rc;
size_t i, j, cnt;
char *names[15], *keys[5];
orte_gpr_keyval_t **kvals, *kval;
orte_gpr_value_t **values, *val;
int32_t i32;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* ENSURE THE REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* do a select on the registry components */
if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(stderr, "GPR selected\n");
} else {
fprintf(stderr, "GPR could not select\n");
exit (1);
}
fprintf(stderr, "put one value with single keyval\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 1;
val->segment = strdup("test-put-segment");
val->num_tokens = 14;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 14; i++) {
asprintf(&(val->tokens[i]), "dummy%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
val->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
(val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[0])->value->type = ORTE_INT32;
i32 = 654321;
orte_dss.copy(&(val->keyvals[0]->value->data), &i32, ORTE_INT32);
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put of 1 value/1 keyval failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: put of 1 value/1 keyval passed\n");
}
OBJ_RELEASE(val);
fprintf(stderr, "put one value with multiple keyvals\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 20;
val->segment = strdup("test-put-segment");
val->num_tokens = 14;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 14; i++) {
asprintf(&(val->tokens[i]), "dummy%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(20*sizeof(orte_gpr_keyval_t*));
for (i=0; i<20; i++) {
val->keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
asprintf(&((val->keyvals[i])->key), "stupid-test-%lu",
(unsigned long) i);
(val->keyvals[i])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[i])->value->type = ORTE_UINT32;
i32 = i;
orte_dss.copy(&(val->keyvals[i]->value->data), &i32, ORTE_UINT32);
}
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval passed\n");
}
OBJ_RELEASE(val);
fprintf(stderr, "put 1 value/multiple keyvals - second container\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->segment = strdup("test-put-segment");
val->num_tokens = 10;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < val->num_tokens; i++) {
asprintf(&(val->tokens[i]), "dummy%lu", (unsigned long) i);
}
val->cnt = 20;
val->keyvals = (orte_gpr_keyval_t**)malloc(val->cnt * sizeof(orte_gpr_keyval_t*));
for (i=0; i<val->cnt; i++) {
val->keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
asprintf(&((val->keyvals[i])->key), "stupid-test-%lu",
(unsigned long) i);
(val->keyvals[i])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[i])->value->type = ORTE_UINT32;
i32 = i;
orte_dss.copy(&(val->keyvals[i]->value->data), &i32, ORTE_UINT32);
}
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval in second container failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval in second container passed\n");
}
OBJ_RELEASE(val);
fprintf(stderr, "dump\n");
if (ORTE_SUCCESS != (rc = orte_gpr.dump_all(0))) {
fprintf(stderr, "gpr_test: dump failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: dump passed\n");
}
fprintf(stderr, "get\n");
names[0] = strdup("dummy0");
names[1] = NULL;
keys[0] = strdup("stupid-test-1");
keys[1] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment",
names, keys,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get passed\n");
}
free(keys[0]);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
free(values);
fprintf(stderr, "get multiple in one segment, multiple containers\n");
keys[0] = strdup("stupid-test-1");
keys[1] = strdup("stupid-test-3");
keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8");
keys[4] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment",
names, keys,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get passed\n");
}
for (i=0; i < 4; i++) free(keys[i]);
free(names[0]);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
free(values);
fprintf(stderr, "put multiple copies of same entry in single container\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 1;
val->segment = strdup("test-put-segment");
val->num_tokens = 5;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 5; i++) {
asprintf(&(val->tokens[i]), "multi-dum-dum-%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
val->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
(val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[0])->value->type = ORTE_STRING;
(val->keyvals[0])->value->data = strdup("try-string-value");
for (i = 0; i < 10; i++) {
fprintf(stderr, "\tputting copy %lu\n", (unsigned long) i);
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put multiple copies of one keyval in a container failed with error code %d\n", rc);
return rc;
}
}
OBJ_RELEASE(val);
orte_gpr.dump_all(0);
fprintf(stderr, "put with no tokens puts in every container\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE;
val->cnt = 1;
val->segment = strdup("test-put-segment");
val->num_tokens = 0;
val->tokens = NULL;
val->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
val->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
(val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[0])->value->type = ORTE_STRING;
(val->keyvals[0])->value->data = strdup("try-string-value");
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put with no tokens failed - returned %d\n", rc);
} else {
fprintf(stderr, "gpr_test: put with no tokens passed\n");
}
OBJ_RELEASE(val);
orte_gpr.dump_all(0);
fprintf(stderr, "get with no tokens, KEYS_OR\n");
keys[0] = strdup("stupid-test-1");
keys[1] = strdup("stupid-test-3");
keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8");
keys[4] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment",
NULL, keys,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get with no tokens, KEYS_OR passed\n");
}
for (i=0; i < 4; i++) free(keys[i]);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
free(values);
fprintf(stderr, "get with no tokens, KEYS_AND\n");
keys[0] = strdup("stupid-test-1");
keys[1] = strdup("stupid-test-3");
keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8");
keys[4] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_AND | ORTE_GPR_TOKENS_OR,
"test-put-segment",
NULL, keys,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get with no tokens, KEYS_AND passed\n");
}
for (i=0; i < 4; i++) free(keys[i]);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
free(values);
fprintf(stderr, "overwrite a bunch of values with one\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 1;
val->segment = strdup("test-put-segment");
val->num_tokens = 5;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 5; i++) {
asprintf(&(val->tokens[i]), "multi-dum-dum-%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
val->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
(val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[0])->value->type = ORTE_STRING;
(val->keyvals[0])->value->data = strdup("try-string-value");
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put multiple copies of one keyval in a container failed with error code %d\n", rc);
return rc;
}
OBJ_RELEASE(val);
orte_gpr.dump_all(0);
fprintf(stderr, "get_conditional, KEYS_AND\n");
keys[0] = strdup("stupid-test-1");
keys[1] = strdup("stupid-test-3");
keys[2] = NULL;
kval = OBJ_NEW(orte_gpr_keyval_t);
kval->key = strdup("stupid-test-6");
kval->value = OBJ_NEW(orte_data_value_t);
kval->value->type = ORTE_UINT32;
i32 = 6;
orte_dss.copy(&(kval->value->data), &i32, ORTE_UINT32);
values = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get_conditional(ORTE_GPR_KEYS_AND | ORTE_GPR_TOKENS_OR,
"test-put-segment",
NULL, keys, 1, &kval,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get conditional failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get conditional, KEYS_AND passed\n");
}
for (i=0; i < 2; i++) free(keys[i]);
OBJ_RELEASE(kval);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
if (NULL != values) free(values);
fprintf(stderr, "now finalize and see if all memory cleared\n");
orte_gpr_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return(0);
}

Просмотреть файл

@ -1,170 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/orte_constants.h"
#include "orte/mca/schema/schema.h"
#include "orte/mca/schema/base/base.h"
#include "orte/mca/ns/base/base.h"
#include "orte/mca/soh/base/base.h"
#include "orte/mca/rmgr/base/base.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/runtime/runtime.h"
#include "orte/util/proc_info.h"
#include "orte/util/sys_info.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "orte/mca/gpr/replica/functional_layer/gpr_replica_fn.h"
#include "orte/mca/gpr/replica/communications/gpr_replica_comm.h"
#include "orte/mca/gpr/replica/transition_layer/gpr_replica_tl.h"
int main(int argc, char **argv)
{
int rc;
size_t i;
char *tokens[5], *keys[5];
orte_data_value_t value = ORTE_DATA_VALUE_EMPTY;
orte_data_value_t *values[5];
int32_t i32;
int16_t i16;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* ENSURE THE REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* do a select on the registry components */
if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(stderr, "GPR selected\n");
} else {
fprintf(stderr, "GPR could not select\n");
exit (1);
}
tokens[0] = strdup("test-token-1");
tokens[1] = strdup("test-token-2");
tokens[2] = NULL;
i32 = 123456;
value.type = ORTE_INT32;
value.data = &i32;
fprintf(stderr, "quick-put one value with single keyval\n");
if (ORTE_SUCCESS != (rc = orte_gpr.put_1(ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
"test-key", &value))) {
fprintf(stderr, "gpr_test: put of 1 value/1 keyval failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: quick-put of 1 value/1 keyval passed\n");
}
free(tokens[0]);
free(tokens[1]);
for (i=0; i < 4; i++) {
asprintf(&tokens[i], "test-token-%lu", (unsigned long)i);
asprintf(&keys[i], "test-keys-%lu", (unsigned long)i);
values[i] = OBJ_NEW(orte_data_value_t);
values[i]->type = ORTE_INT16;
i16 = i * 1000;
orte_dss.copy(&(values[i]->data), &i16, ORTE_INT16);
}
tokens[4] = NULL;
keys[4] = NULL;
fprintf(stderr, "quick-put one value with multiple keyvals\n");
if (ORTE_SUCCESS != (rc = orte_gpr.put_N(ORTE_GPR_TOKENS_AND,
"test-put-segment23", tokens, 4,
keys, values))) {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval passed\n");
}
orte_gpr.dump_segment(NULL, 0);
fprintf(stderr, "now finalize and see if all memory cleared\n");
orte_gpr_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return(0);
}

Просмотреть файл

@ -1,263 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/orte_constants.h"
#include "orte/mca/schema/schema.h"
#include "orte/mca/schema/base/base.h"
#include "orte/mca/ns/base/base.h"
#include "orte/mca/soh/base/base.h"
#include "orte/mca/rmgr/base/base.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/runtime/runtime.h"
#include "orte/util/proc_info.h"
#include "orte/util/sys_info.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "orte/mca/gpr/replica/functional_layer/gpr_replica_fn.h"
#include "orte/mca/gpr/replica/communications/gpr_replica_comm.h"
#include "orte/mca/gpr/replica/transition_layer/gpr_replica_tl.h"
static void test_cbfunc1(orte_gpr_notify_data_t *data, void *user_tag);
static int test_cbfunc2(orte_gpr_notify_message_t *msg);
int main(int argc, char **argv)
{
int rc;
orte_gpr_subscription_id_t id;
orte_gpr_trigger_id_t id2;
size_t i;
char *tokens[5], *keys[5];
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* ENSURE THE REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* do a select on the registry components */
if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(stderr, "GPR selected\n");
} else {
fprintf(stderr, "GPR could not select\n");
exit (1);
}
tokens[0] = strdup("test-token-1");
tokens[1] = strdup("test-token-2");
tokens[2] = NULL;
fprintf(stderr, "quick-subscribe one value with single key\n");
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&id,
NULL,
NULL,
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
"test-key", test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of 1 key no names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of 1 key no names passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&id,
NULL,
"orte-std-subscription-single1",
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
"test-key", test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of 1 key sub name failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of 1 key sub name passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&id,
"orte-std-trigger-single",
"orte-std-subscription-single2",
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
"test-key", test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of 1 key trig and sub names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of 1 key trig and sub names passed\n");
}
free(tokens[0]);
free(tokens[1]);
for (i=0; i < 4; i++) {
asprintf(&tokens[i], "test-token-%lu", (unsigned long)i);
asprintf(&keys[i], "test-keys-%lu", (unsigned long)i);
}
tokens[4] = NULL;
keys[4] = NULL;
fprintf(stderr, "quick-subscribe one value with multiple keyvals\n");
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_N(&id,
NULL,
NULL,
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of multi key no names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of multi key no names passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_N(&id,
NULL,
"orte-std-subscription-multi",
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of multi key sub name failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of multi key sub name passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_N(&id,
"orte-std-trigger-multi",
"orte-std-subscription-multi2",
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of multi key trig and sub names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of multi key trig and sub names passed\n");
}
fprintf(stderr, "quick-define-trigger\n");
if (ORTE_SUCCESS != (rc = orte_gpr.define_trigger(&id2,
NULL,
ORTE_GPR_TRIG_INCLUDE_TRIG_CNTRS,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc2, NULL))) {
fprintf(stderr, "gpr_test: define_trigger of multi key no names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of multi key no names passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.define_trigger(&id,
"orte-std-trigger",
ORTE_GPR_TRIG_INCLUDE_TRIG_CNTRS,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc2, NULL))) {
fprintf(stderr, "gpr_test: define_trigger of multi key sub name failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: define_trigger of multi key sub name passed\n");
}
orte_gpr.dump_subscriptions(0, 0);
orte_gpr.dump_triggers(0, 0);
orte_gpr.dump_local_subscriptions(0);
orte_gpr.dump_local_triggers(0);
fprintf(stderr, "now finalize and see if all memory cleared\n");
orte_gpr_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return(0);
}
void test_cbfunc1(orte_gpr_notify_data_t *data, void *tag)
{
fprintf(stderr, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 1\n");
orte_gpr.dump_notify_data(data, 0);
}
int test_cbfunc2(orte_gpr_notify_message_t *msg)
{
fprintf(stderr, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 2\n");
orte_gpr.dump_notify_msg(msg, 0);
return ORTE_SUCCESS;
}

Просмотреть файл

@ -1,265 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/orte_constants.h"
#include "orte/mca/schema/schema.h"
#include "orte/mca/schema/base/base.h"
#include "orte/mca/ns/base/base.h"
#include "orte/mca/soh/base/base.h"
#include "orte/mca/rmgr/base/base.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/runtime/runtime.h"
#include "orte/util/proc_info.h"
#include "orte/util/sys_info.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "orte/mca/gpr/replica/functional_layer/gpr_replica_fn.h"
#include "orte/mca/gpr/replica/communications/gpr_replica_comm.h"
#include "orte/mca/gpr/replica/transition_layer/gpr_replica_tl.h"
static void notify_callback(orte_gpr_notify_data_t *data, void *cbdata)
{
size_t i, j, k;
orte_gpr_value_t **values = (orte_gpr_value_t**)(data->values)->addr;
char *tmp;
fprintf(stderr, "Callback received - with %lu values\n", (unsigned long)data->cnt);
for (i = 0, k=0; k < data->cnt &&
i < (data->values)->size; i++) {
if (NULL != values[i]) {
orte_gpr_value_t *value = values[i];
k++;
fprintf(stderr, "\tData for value %lu - with %lu keyvals\n",
(unsigned long)i, (unsigned long)value->cnt);
for (j = 0; j < value->cnt; j++) {
orte_gpr_keyval_t *keyval = value->keyvals[j];
fprintf(stderr, "\t\tKey number: %lu\tkey = %s\n", (unsigned long)j, keyval->key);
orte_dss.print(&tmp, NULL, keyval->value, ORTE_DATA_VALUE);
fprintf(stderr, "\t\t%s\n", tmp);
free(tmp);
}
}
}
}
int main(int argc, char **argv)
{
int i, rc;
orte_gpr_subscription_t sub, *subs;
orte_gpr_value_t value, *values;
char *keys[] = {
ORTE_NODE_STATE_KEY,
"stupid-value-one",
"stupid-value-two",
"stupid-value-three",
"stupid-value-four"};
int32_t i32;
int16_t i16;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* ENSURE THE REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* do a select on the registry components */
if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(stderr, "GPR selected\n");
} else {
fprintf(stderr, "GPR could not select\n");
exit (1);
}
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
sub.action = ORTE_GPR_NOTIFY_VALUE_CHG;
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
values = &value;
sub.values = &values;
sub.cnt = 1; /* number of values */
value.addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR;
value.segment = strdup(ORTE_NODE_SEGMENT);
value.cnt = 5; /* number of keyvals */
value.keyvals = (orte_gpr_keyval_t**)malloc(value.cnt * sizeof(orte_gpr_keyval_t*));
for (i=0; i < 5; i++) {
value.keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
value.keyvals[i]->key = strdup(keys[i]);
}
/* Any token */
value.tokens = NULL;
value.num_tokens = 0;
sub.cbfunc = notify_callback;
sub.user_tag = NULL;
subs = &sub;
rc = orte_gpr.subscribe(1, &subs, 0, NULL);
if (ORTE_SUCCESS != rc) {
return 1;
}
OBJ_DESTRUCT(&value);
/* now let's write something into those locations */
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
value.addr_mode = ORTE_GPR_NO_OVERWRITE |
ORTE_GPR_TOKENS_XAND |
ORTE_GPR_KEYS_OR;
value.segment = strdup(ORTE_NODE_SEGMENT);
value.num_tokens = 2;
value.tokens = (char**)malloc(value.num_tokens * sizeof(char*));
for (i=0; i < 2; i++) {
asprintf(&(value.tokens[i]), "dummy-token-%d", i);
}
value.cnt = 5;
value.keyvals = (orte_gpr_keyval_t**)malloc(5*sizeof(orte_gpr_keyval_t*));
for (i=0; i < 5; i++) {
value.keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
(value.keyvals[i])->key = strdup(keys[i]);
value.keyvals[i]->value = OBJ_NEW(orte_data_value_t);
}
(value.keyvals[0])->value->type = ORTE_INT32;
i32 = 654321;
orte_dss.copy(&(value.keyvals[0]->value->data), &i32, ORTE_INT32);
(value.keyvals[1])->value->type = ORTE_INT16;
i16 = 128;
orte_dss.copy(&(value.keyvals[1]->value->data), &i16, ORTE_INT16);
for (i=2; i < 5; i++) {
(value.keyvals[i])->value->type = ORTE_INT32;
i32 = i * 10;
orte_dss.copy(&(value.keyvals[i]->value->data), &i32, ORTE_INT32);
}
values = &value;
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) {
OBJ_DESTRUCT(&value);
return rc;
}
OBJ_DESTRUCT(&value); /* clean up */
/* now let's update a few of them */
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
value.addr_mode = ORTE_GPR_OVERWRITE |
ORTE_GPR_TOKENS_XAND |
ORTE_GPR_KEYS_OR;
value.segment = strdup(ORTE_NODE_SEGMENT);
value.num_tokens = 2;
value.tokens = (char**)malloc(value.num_tokens * sizeof(char*));
for (i=0; i < 2; i++) {
asprintf(&(value.tokens[i]), "dummy-token-%d", i);
}
value.cnt = 3;
value.keyvals = (orte_gpr_keyval_t**)malloc(3*sizeof(orte_gpr_keyval_t*));
for (i=0; i < 3; i++) {
value.keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
(value.keyvals[i])->key = strdup(keys[i]);
value.keyvals[i]->value = OBJ_NEW(orte_data_value_t);
}
(value.keyvals[0])->value->type = ORTE_INT32;
i32 = 123456;
orte_dss.copy(&(value.keyvals[0]->value->data), &i32, ORTE_INT32);
(value.keyvals[1])->value->type = ORTE_INT16;
i16 = 904;
orte_dss.copy(&(value.keyvals[1]->value->data), &i16, ORTE_INT16);
(value.keyvals[2])->value->type = ORTE_STRING;
(value.keyvals[2])->value->data = strdup("idiot-string");
values = &value;
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) {
fprintf(stderr, "Error in put %d\n", rc);
OBJ_DESTRUCT(&value);
return rc;
}
OBJ_DESTRUCT(&value); /* clean up */
orte_gpr_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return(0);
}

Просмотреть файл

@ -1,148 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include "orte/mca/schema/schema.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "runtime/runtime.h"
#include "opal/threads/threads.h"
#include "util/proc_info.h"
#include "util/sys_info.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/ns_types.h"
#include "orte/mca/gpr/gpr.h"
#include "dps/dps.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "orte/mca/gpr/replica/functional_layer/gpr_replica_fn.h"
#include "orte/mca/gpr/replica/communications/gpr_replica_comm.h"
#include "orte/mca/gpr/replica/transition_layer/gpr_replica_tl.h"
/* output files needed by the test */
static FILE *test_out=NULL;
/* function for exercising the registry */
void *thread_fn(opal_object_t *object);
#if !OMPI_HAVE_THREAD_SUPPORT
/* If we don't have thread support, there's no point in running this
test */
int main(int argc, char *argv[])
{
printf("OMPI was compiled without thread support -- skipping this test\n");
return 77;
}
#else
/* Only have the body of this test if we have thread support */
int main(int argc, char **argv)
{
int i, rc, num_threads;
opal_thread_t **threads;
union {
int ivalue;
void *vvalue;
} value;
/* protect against sizeof mismatches */
if (sizeof(i) > sizeof (void*)) {
fprintf(stderr, "cannot run this test on this machine\n");
exit(77);
}
test_init("test_gpr_threads");
if (getenv("TEST_WRITE_TO_FILE") != NULL) {
test_out = fopen( "test_gpr_threads", "w+" );
} else {
test_out = stderr;
}
if( test_out == NULL ) {
test_failure("gpr_threads couldn't open test file failed");
test_finalize();
exit(1);
}
if (1 < argc) { /* number of threads to run provided on cmd line */
num_threads = strtol(argv[1], NULL, 0);
} else { /* default to 2 */
num_threads = 2;
}
/* setup the runtime environment */
if (ORTE_SUCCESS != (rc = orte_init())) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* setup the threads */
threads = (opal_thread_t**)malloc(num_threads * sizeof(opal_thread_t*));
if (NULL == threads) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
for (i=0; i < num_threads; i++) {
threads[i] = OBJ_NEW(opal_thread_t);
if (NULL == threads[i]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
threads[i]->t_run = thread_fn;
value.ivalue = i;
threads[i]->t_arg = value.vvalue;
}
/* run the threads */
for (i=0; i < num_threads; i++) {
if (OMPI_SUCCESS != (rc = opal_thread_start(threads[i]))) {
ORTE_ERROR_LOG(rc);
exit(rc);
}
}
/* finalize things */
orte_finalize();
fclose( test_out );
test_finalize();
return(0);
}
void *thread_fn(opal_object_t *obj)
{
return NULL;
}
#endif /* OMPI_HAVE_THREAD_SUPPORT */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,54 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
TESTS_ENVIRONMENT = TEST_WRITE_TO_FILE=1
check_PROGRAMS = \
gpr_put_get \
gpr_quick_put \
gpr_quick_triggers \
gpr_sub_test
TESTS =
gpr_put_get_SOURCES = gpr_put_get.c
gpr_put_get_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_put_get_DEPENDENCIES = $(gpr_put_get_LDADD)
gpr_quick_put_SOURCES = gpr_quick_put.c
gpr_quick_put_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_quick_put_DEPENDENCIES = $(gpr_quick_put_LDADD)
gpr_quick_triggers= gpr_quick_triggers.c
gpr_quick_triggers_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_quick_triggers_DEPENDENCIES = $(gpr_quick_triggers_LDADD)
gpr_sub_test= gpr_sub_test.c
gpr_sub_test_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
gpr_sub_test_DEPENDENCIES = $(gpr_sub_test_LDADD)

Просмотреть файл

@ -1,400 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "orte/runtime/runtime.h"
#include "orte/mca/gpr/gpr.h"
int main(int argc, char **argv)
{
int rc;
size_t i, j, cnt;
char *names[15], *keys[5];
orte_gpr_keyval_t **kvals, *kval;
orte_gpr_value_t **values, *val;
int32_t i32;
/* initialize system */
if (ORTE_SUCCESS != (rc = orte_init(true))) {
fprintf(stderr, "couldn't complete init of system - error code %d\n", rc);
exit(1);
}
fprintf(stderr, "put one value with single keyval\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 1;
val->segment = strdup("test-put-segment");
val->num_tokens = 14;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 14; i++) {
asprintf(&(val->tokens[i]), "dummy%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
val->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
(val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[0])->value->type = ORTE_INT32;
i32 = 654321;
orte_dss.copy(&(val->keyvals[0]->value->data), &i32, ORTE_INT32);
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put of 1 value/1 keyval failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: put of 1 value/1 keyval passed\n");
}
OBJ_RELEASE(val);
fprintf(stderr, "put one value with multiple keyvals\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 20;
val->segment = strdup("test-put-segment");
val->num_tokens = 14;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 14; i++) {
asprintf(&(val->tokens[i]), "dummy%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(20*sizeof(orte_gpr_keyval_t*));
for (i=0; i<20; i++) {
val->keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
asprintf(&((val->keyvals[i])->key), "stupid-test-%lu",
(unsigned long) i);
(val->keyvals[i])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[i])->value->type = ORTE_UINT32;
i32 = i;
orte_dss.copy(&(val->keyvals[i]->value->data), &i32, ORTE_UINT32);
}
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval passed\n");
}
OBJ_RELEASE(val);
fprintf(stderr, "put 1 value/multiple keyvals - second container\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->segment = strdup("test-put-segment");
val->num_tokens = 10;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < val->num_tokens; i++) {
asprintf(&(val->tokens[i]), "dummy%lu", (unsigned long) i);
}
val->cnt = 20;
val->keyvals = (orte_gpr_keyval_t**)malloc(val->cnt * sizeof(orte_gpr_keyval_t*));
for (i=0; i<val->cnt; i++) {
val->keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
asprintf(&((val->keyvals[i])->key), "stupid-test-%lu",
(unsigned long) i);
(val->keyvals[i])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[i])->value->type = ORTE_UINT32;
i32 = i;
orte_dss.copy(&(val->keyvals[i]->value->data), &i32, ORTE_UINT32);
}
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval in second container failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval in second container passed\n");
}
OBJ_RELEASE(val);
fprintf(stderr, "dump\n");
if (ORTE_SUCCESS != (rc = orte_gpr.dump_all(0))) {
fprintf(stderr, "gpr_test: dump failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: dump passed\n");
}
fprintf(stderr, "get\n");
names[0] = strdup("dummy0");
names[1] = NULL;
keys[0] = strdup("stupid-test-1");
keys[1] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment",
names, keys,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get passed\n");
}
free(keys[0]);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
free(values);
fprintf(stderr, "get multiple in one segment, multiple containers\n");
keys[0] = strdup("stupid-test-1");
keys[1] = strdup("stupid-test-3");
keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8");
keys[4] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment",
names, keys,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get passed\n");
}
for (i=0; i < 4; i++) free(keys[i]);
free(names[0]);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
free(values);
fprintf(stderr, "put multiple copies of same entry in single container\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 1;
val->segment = strdup("test-put-segment");
val->num_tokens = 5;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 5; i++) {
asprintf(&(val->tokens[i]), "multi-dum-dum-%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
val->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
(val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[0])->value->type = ORTE_STRING;
(val->keyvals[0])->value->data = strdup("try-string-value");
for (i = 0; i < 10; i++) {
fprintf(stderr, "\tputting copy %lu\n", (unsigned long) i);
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put multiple copies of one keyval in a container failed with error code %d\n", rc);
return rc;
}
}
OBJ_RELEASE(val);
orte_gpr.dump_all(0);
fprintf(stderr, "put with no tokens puts in every container\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_NO_OVERWRITE;
val->cnt = 1;
val->segment = strdup("test-put-segment");
val->num_tokens = 0;
val->tokens = NULL;
val->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
val->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
(val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[0])->value->type = ORTE_STRING;
(val->keyvals[0])->value->data = strdup("try-string-value");
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put with no tokens failed - returned %d\n", rc);
} else {
fprintf(stderr, "gpr_test: put with no tokens passed\n");
}
OBJ_RELEASE(val);
orte_gpr.dump_all(0);
fprintf(stderr, "get with no tokens, KEYS_OR\n");
keys[0] = strdup("stupid-test-1");
keys[1] = strdup("stupid-test-3");
keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8");
keys[4] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment",
NULL, keys,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get with no tokens, KEYS_OR passed\n");
}
for (i=0; i < 4; i++) free(keys[i]);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
free(values);
fprintf(stderr, "get with no tokens, KEYS_AND\n");
keys[0] = strdup("stupid-test-1");
keys[1] = strdup("stupid-test-3");
keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8");
keys[4] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_AND | ORTE_GPR_TOKENS_OR,
"test-put-segment",
NULL, keys,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get with no tokens, KEYS_AND passed\n");
}
for (i=0; i < 4; i++) free(keys[i]);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
free(values);
fprintf(stderr, "overwrite a bunch of values with one\n");
val = OBJ_NEW(orte_gpr_value_t);
val->addr_mode = ORTE_GPR_OVERWRITE | ORTE_GPR_TOKENS_XAND;
val->cnt = 1;
val->segment = strdup("test-put-segment");
val->num_tokens = 5;
val->tokens = (char**)malloc(val->num_tokens * sizeof(char*));
for (i=0; i < 5; i++) {
asprintf(&(val->tokens[i]), "multi-dum-dum-%lu", (unsigned long) i);
}
val->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
val->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
(val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->value = OBJ_NEW(orte_data_value_t);
(val->keyvals[0])->value->type = ORTE_STRING;
(val->keyvals[0])->value->data = strdup("try-string-value");
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(stderr, "gpr_test: put multiple copies of one keyval in a container failed with error code %d\n", rc);
return rc;
}
OBJ_RELEASE(val);
orte_gpr.dump_all(0);
fprintf(stderr, "get_conditional, KEYS_AND\n");
keys[0] = strdup("stupid-test-1");
keys[1] = strdup("stupid-test-3");
keys[2] = NULL;
kval = OBJ_NEW(orte_gpr_keyval_t);
kval->key = strdup("stupid-test-6");
kval->value = OBJ_NEW(orte_data_value_t);
kval->value->type = ORTE_UINT32;
i32 = 6;
orte_dss.copy(&(kval->value->data), &i32, ORTE_UINT32);
values = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get_conditional(ORTE_GPR_KEYS_AND | ORTE_GPR_TOKENS_OR,
"test-put-segment",
NULL, keys, 1, &kval,
&cnt, &values))) {
fprintf(stderr, "gpr_test: get conditional failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: get conditional, KEYS_AND passed\n");
}
for (i=0; i < 2; i++) free(keys[i]);
OBJ_RELEASE(kval);
fprintf(stderr, "get results:\n");
for (j=0; j < cnt; j++) {
fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n",
(unsigned long) j, (unsigned long) values[j]->cnt,
values[j]->segment, (unsigned long) values[j]->num_tokens);
for (i=0; i < values[j]->num_tokens; i++) {
fprintf(stderr, "token: %lu %s\n", (unsigned long) i,
values[j]->tokens[i]);
}
kvals = values[j]->keyvals;
for (i=0; i < values[j]->cnt; i++) {
fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->value->type);
}
OBJ_RELEASE(values[j]);
}
if (NULL != values) free(values);
fprintf(stderr, "now finalize and see if all memory cleared\n");
if (ORTE_SUCCESS != (rc = orte_finalize())) {
fprintf(stderr, "couldn't complete finalize - error code %d\n", rc);
exit(1);
}
return(0);
}

Просмотреть файл

@ -1,102 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "orte/runtime/runtime.h"
#include "orte/mca/gpr/gpr.h"
int main(int argc, char **argv)
{
int rc;
size_t i;
char *tokens[5], *keys[5];
orte_data_value_t value = ORTE_DATA_VALUE_EMPTY;
orte_data_value_t *values[5];
int32_t i32;
int16_t i16;
/* initialize system */
if (ORTE_SUCCESS != (rc = orte_init(true))) {
fprintf(stderr, "couldn't complete init of system - error code %d\n", rc);
exit(1);
}
tokens[0] = strdup("test-token-1");
tokens[1] = strdup("test-token-2");
tokens[2] = NULL;
i32 = 123456;
value.type = ORTE_INT32;
value.data = &i32;
fprintf(stderr, "quick-put one value with single keyval\n");
if (ORTE_SUCCESS != (rc = orte_gpr.put_1(ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
"test-key", &value))) {
fprintf(stderr, "gpr_test: put of 1 value/1 keyval failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: quick-put of 1 value/1 keyval passed\n");
}
free(tokens[0]);
free(tokens[1]);
for (i=0; i < 4; i++) {
asprintf(&tokens[i], "test-token-%lu", (unsigned long)i);
asprintf(&keys[i], "test-keys-%lu", (unsigned long)i);
values[i] = OBJ_NEW(orte_data_value_t);
values[i]->type = ORTE_INT16;
i16 = i * 1000;
orte_dss.copy(&(values[i]->data), &i16, ORTE_INT16);
}
tokens[4] = NULL;
keys[4] = NULL;
fprintf(stderr, "quick-put one value with multiple keyvals\n");
if (ORTE_SUCCESS != (rc = orte_gpr.put_N(ORTE_GPR_TOKENS_AND,
"test-put-segment23", tokens, 4,
keys, values))) {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: put 1 value/multiple keyval passed\n");
}
orte_gpr.dump_segment(NULL, 0);
fprintf(stderr, "now finalize and see if all memory cleared\n");
if (ORTE_SUCCESS != (rc = orte_finalize())) {
fprintf(stderr, "couldn't complete finalize - error code %d\n", rc);
exit(1);
}
return(0);
}

Просмотреть файл

@ -1,195 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "orte/runtime/runtime.h"
#include "orte/mca/gpr/gpr.h"
static void test_cbfunc1(orte_gpr_notify_data_t *data, void *user_tag);
static int test_cbfunc2(orte_gpr_notify_message_t *msg);
int main(int argc, char **argv)
{
int rc;
orte_gpr_subscription_id_t id;
orte_gpr_trigger_id_t id2;
size_t i;
char *tokens[5], *keys[5];
/* initialize system */
if (ORTE_SUCCESS != (rc = orte_init(true))) {
fprintf(stderr, "couldn't complete init of system - error code %d\n", rc);
exit(1);
}
tokens[0] = strdup("test-token-1");
tokens[1] = strdup("test-token-2");
tokens[2] = NULL;
fprintf(stderr, "quick-subscribe one value with single key\n");
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&id,
NULL,
NULL,
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
"test-key", test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of 1 key no names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of 1 key no names passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&id,
NULL,
"orte-std-subscription-single1",
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
"test-key", test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of 1 key sub name failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of 1 key sub name passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&id,
"orte-std-trigger-single",
"orte-std-subscription-single2",
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
"test-key", test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of 1 key trig and sub names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of 1 key trig and sub names passed\n");
}
free(tokens[0]);
free(tokens[1]);
for (i=0; i < 4; i++) {
asprintf(&tokens[i], "test-token-%lu", (unsigned long)i);
asprintf(&keys[i], "test-keys-%lu", (unsigned long)i);
}
tokens[4] = NULL;
keys[4] = NULL;
fprintf(stderr, "quick-subscribe one value with multiple keyvals\n");
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_N(&id,
NULL,
NULL,
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of multi key no names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of multi key no names passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_N(&id,
NULL,
"orte-std-subscription-multi",
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of multi key sub name failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of multi key sub name passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_N(&id,
"orte-std-trigger-multi",
"orte-std-subscription-multi2",
ORTE_GPR_NOTIFY_VALUE_CHG,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc1, NULL))) {
fprintf(stderr, "gpr_test: subscribe of multi key trig and sub names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of multi key trig and sub names passed\n");
}
fprintf(stderr, "quick-define-trigger\n");
if (ORTE_SUCCESS != (rc = orte_gpr.define_trigger(&id2,
NULL,
ORTE_GPR_TRIG_INCLUDE_TRIG_CNTRS,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc2, NULL))) {
fprintf(stderr, "gpr_test: define_trigger of multi key no names failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: subscribe of multi key no names passed\n");
}
if (ORTE_SUCCESS != (rc = orte_gpr.define_trigger(&id,
"orte-std-trigger",
ORTE_GPR_TRIG_INCLUDE_TRIG_CNTRS,
ORTE_GPR_TOKENS_AND,
"test-put-segment", tokens,
4, keys, test_cbfunc2, NULL))) {
fprintf(stderr, "gpr_test: define_trigger of multi key sub name failed with error code %d\n", rc);
return rc;
} else {
fprintf(stderr, "gpr_test: define_trigger of multi key sub name passed\n");
}
orte_gpr.dump_subscriptions(0, 0);
orte_gpr.dump_triggers(0, 0);
orte_gpr.dump_local_subscriptions(0);
orte_gpr.dump_local_triggers(0);
fprintf(stderr, "now finalize and see if all memory cleared\n");
if (ORTE_SUCCESS != (rc = orte_finalize())) {
fprintf(stderr, "couldn't complete finalize - error code %d\n", rc);
exit(1);
}
return(0);
}
void test_cbfunc1(orte_gpr_notify_data_t *data, void *tag)
{
fprintf(stderr, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 1\n");
orte_gpr.dump_notify_data(data, 0);
}
int test_cbfunc2(orte_gpr_notify_message_t *msg)
{
fprintf(stderr, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 2\n");
orte_gpr.dump_notify_msg(msg, 0);
return ORTE_SUCCESS;
}

Просмотреть файл

@ -1,197 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "orte/runtime/runtime.h"
#include "orte/mca/gpr/gpr.h"
static void notify_callback(orte_gpr_notify_data_t *data, void *cbdata)
{
size_t i, j, k;
orte_gpr_value_t **values = (orte_gpr_value_t**)(data->values)->addr;
char *tmp;
fprintf(stderr, "Callback received - with %lu values\n", (unsigned long)data->cnt);
for (i = 0, k=0; k < data->cnt &&
i < (data->values)->size; i++) {
if (NULL != values[i]) {
orte_gpr_value_t *value = values[i];
k++;
fprintf(stderr, "\tData for value %lu - with %lu keyvals\n",
(unsigned long)i, (unsigned long)value->cnt);
for (j = 0; j < value->cnt; j++) {
orte_gpr_keyval_t *keyval = value->keyvals[j];
fprintf(stderr, "\t\tKey number: %lu\tkey = %s\n", (unsigned long)j, keyval->key);
orte_dss.print(&tmp, NULL, keyval->value, ORTE_DATA_VALUE);
fprintf(stderr, "\t\t%s\n", tmp);
free(tmp);
}
}
}
}
int main(int argc, char **argv)
{
int i, rc;
orte_gpr_subscription_t sub, *subs;
orte_gpr_value_t value, *values;
char *keys[] = {
ORTE_NODE_STATE_KEY,
"stupid-value-one",
"stupid-value-two",
"stupid-value-three",
"stupid-value-four"};
int32_t i32;
int16_t i16;
/* initialize system */
if (ORTE_SUCCESS != (rc = orte_init(true))) {
fprintf(stderr, "couldn't complete init of system - error code %d\n", rc);
exit(1);
}
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
sub.action = ORTE_GPR_NOTIFY_VALUE_CHG;
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
values = &value;
sub.values = &values;
sub.cnt = 1; /* number of values */
value.addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR;
value.segment = strdup(ORTE_NODE_SEGMENT);
value.cnt = 5; /* number of keyvals */
value.keyvals = (orte_gpr_keyval_t**)malloc(value.cnt * sizeof(orte_gpr_keyval_t*));
for (i=0; i < 5; i++) {
value.keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
value.keyvals[i]->key = strdup(keys[i]);
}
/* Any token */
value.tokens = NULL;
value.num_tokens = 0;
sub.cbfunc = notify_callback;
sub.user_tag = NULL;
subs = &sub;
rc = orte_gpr.subscribe(1, &subs, 0, NULL);
if (ORTE_SUCCESS != rc) {
return 1;
}
OBJ_DESTRUCT(&value);
/* now let's write something into those locations */
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
value.addr_mode = ORTE_GPR_NO_OVERWRITE |
ORTE_GPR_TOKENS_XAND |
ORTE_GPR_KEYS_OR;
value.segment = strdup(ORTE_NODE_SEGMENT);
value.num_tokens = 2;
value.tokens = (char**)malloc(value.num_tokens * sizeof(char*));
for (i=0; i < 2; i++) {
asprintf(&(value.tokens[i]), "dummy-token-%d", i);
}
value.cnt = 5;
value.keyvals = (orte_gpr_keyval_t**)malloc(5*sizeof(orte_gpr_keyval_t*));
for (i=0; i < 5; i++) {
value.keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
(value.keyvals[i])->key = strdup(keys[i]);
value.keyvals[i]->value = OBJ_NEW(orte_data_value_t);
}
(value.keyvals[0])->value->type = ORTE_INT32;
i32 = 654321;
orte_dss.copy(&(value.keyvals[0]->value->data), &i32, ORTE_INT32);
(value.keyvals[1])->value->type = ORTE_INT16;
i16 = 128;
orte_dss.copy(&(value.keyvals[1]->value->data), &i16, ORTE_INT16);
for (i=2; i < 5; i++) {
(value.keyvals[i])->value->type = ORTE_INT32;
i32 = i * 10;
orte_dss.copy(&(value.keyvals[i]->value->data), &i32, ORTE_INT32);
}
values = &value;
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) {
OBJ_DESTRUCT(&value);
return rc;
}
OBJ_DESTRUCT(&value); /* clean up */
/* now let's update a few of them */
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
value.addr_mode = ORTE_GPR_OVERWRITE |
ORTE_GPR_TOKENS_XAND |
ORTE_GPR_KEYS_OR;
value.segment = strdup(ORTE_NODE_SEGMENT);
value.num_tokens = 2;
value.tokens = (char**)malloc(value.num_tokens * sizeof(char*));
for (i=0; i < 2; i++) {
asprintf(&(value.tokens[i]), "dummy-token-%d", i);
}
value.cnt = 3;
value.keyvals = (orte_gpr_keyval_t**)malloc(3*sizeof(orte_gpr_keyval_t*));
for (i=0; i < 3; i++) {
value.keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
(value.keyvals[i])->key = strdup(keys[i]);
value.keyvals[i]->value = OBJ_NEW(orte_data_value_t);
}
(value.keyvals[0])->value->type = ORTE_INT32;
i32 = 123456;
orte_dss.copy(&(value.keyvals[0]->value->data), &i32, ORTE_INT32);
(value.keyvals[1])->value->type = ORTE_INT16;
i16 = 904;
orte_dss.copy(&(value.keyvals[1]->value->data), &i16, ORTE_INT16);
(value.keyvals[2])->value->type = ORTE_STRING;
(value.keyvals[2])->value->data = strdup("idiot-string");
values = &value;
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) {
fprintf(stderr, "Error in put %d\n", rc);
OBJ_DESTRUCT(&value);
return rc;
}
OBJ_DESTRUCT(&value); /* clean up */
if (ORTE_SUCCESS != (rc = orte_finalize())) {
fprintf(stderr, "couldn't complete finalize - error code %d\n", rc);
exit(1);
}
return(0);
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,410 +0,0 @@
/*
* unit test for gpr proxy.
--------------------------------------------------------------------------
Authors: Ralph H. Castain <rhc@lanl.gov>
Tim S. Woodall <twoodall@lanl.gov>
--------------------------------------------------------------------------
*/
#include "ompi_config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "support.h"
#include "include/constants.h"
#include "util/sys_info.h"
#include "util/proc_info.h"
#include "opal/util/output.h"
#include "opal/event/event.h"
#include "runtime/runtime.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "orte/mca/ns/base/base.h"
#include "orte/mca/oob/base/base.h"
#include "orte/mca/gpr/gpr.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/replica/gpr_replica.h"
#include "orte/mca/gpr/replica/gpr_replica_internals.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_gpr_proxy_out ./test_gpr_replica_out_std";
static int run_test(void);
static int exec_client(int argc, char** argv);
int main(int argc, char **argv)
{
bool multi, hidden;
char *seed;
test_init("test_gpr_proxy");
test_out = fopen( "test_ns_proxy_out", "w+" );
if( test_out == NULL ) {
test_failure("test_ns_proxy couldn't open test file failed");
test_finalize();
exit(1);
}
/* setup environment for rte */
seed = getenv("OMPI_DAEMON_SEED");
setenv("OMPI_MCA_pcmclient_env_num_procs", "2", 1);
setenv("OMPI_MCA_pcmclient_env_vpid_start", "0", 1);
setenv("OMPI_MCA_pcmclient_env_cellid", "0", 1);
setenv("OMPI_MCA_pcmclient_env_jobid", "0", 1);
if(seed == NULL || atoi(seed) != 0) {
ompi_process_info.seed = true;
setenv("OMPI_MCA_pcmclient_env_procid", "0", 1);
} else {
ompi_process_info.seed = false;
setenv("OMPI_MCA_pcmclient_env_procid", "1", 1);
}
/* require tcp oob */
setenv("OMPI_MCA_oob_base_include", "tcp", 1);
/* basic ompi init */
if (OMPI_SUCCESS != ompi_init(argc, argv)) {
fprintf(test_out, "ompi_init failed - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* initialize event library */
if (OMPI_SUCCESS != opal_event_init()) {
fprintf(test_out, "opal_event_init failed - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* initialize the rte - including ns and oob */
if(OMPI_SUCCESS == ompi_rte_init(NULL, &multi, &hidden)) {
fprintf(test_out, "NS opened\n");
fprintf(test_out, "NS started\n");
} else {
fprintf(test_out, "RTE could not start - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* if daemon seed - just wait for requests */
if(ompi_process_info.seed) {
#if 1
/* wait on child to exit */
int pid = exec_client(argc, argv);
while(true) {
int status;
if(waitpid(pid, &status, WNOHANG) != 0)
break;
opal_event_loop(OPAL_EVLOOP_NONBLOCK);
}
#else
fprintf(stderr, "setenv OMPI_MCA_oob_base_seed %s\n", mca_oob_get_contact_info());
opal_event_loop(0);
#endif
return(0);
} else {
return run_test();
}
}
int exec_client(int argc, char** argv)
{
int pid;
pid = fork();
if(pid < 0) {
fprintf(test_out, "fork() failed with errno=%d\n", errno);
exit(1);
} else if (pid == 0) {
/* child process should not be a daemon */
static char seed_flag[] = "OMPI_DAEMON_SEED=0";
static char seed_addr[128];
char* argp[] = {
seed_flag,
seed_addr,
NULL
};
/* setup seed address for child process */
sprintf(seed_addr, "OMPI_MCA_oob_base_seed=%s", mca_oob_get_contact_info());
execve(argv[0], argv, argp);
}
return pid;
}
int run_test()
{
opal_list_t *test_list, *internal_tests;
ompi_registry_index_value_t *ptr;
ompi_registry_internal_test_results_t *ptri;
ompi_registry_object_t test_buffer;
uint8_t *test_buf;
ompi_registry_object_size_t input_size;
ompi_registry_mode_t mode;
opal_list_t *answer;
ompi_registry_value_t *ans;
bool multi, hidden;
int i, j;
bool success;
char name[30], *name2[30], *name3[30];
int put_test; /* result from system call */
test_init("test_gpr_replica");
test_out = fopen( "test_gpr_replica_out", "w+" );
if( test_out == NULL ) {
test_failure("test_gpr_replica couldn't open test file failed");
test_finalize();
exit(1);
}
ompi_process_info.seed = true;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* open the GPR */
if (OMPI_SUCCESS == mca_gpr_base_open()) {
fprintf(test_out, "GPR opened\n");
test_success();
} else {
fprintf(test_out, "GPR could not open\n");
test_failure("test_gpr_replica mca_gpr_base_open failed");
test_finalize();
exit(1);
}
/* startup the GPR replica */
if (OMPI_SUCCESS != mca_gpr_base_select(&multi, &hidden)) {
fprintf(test_out, "GPR replica could not start\n");
test_failure("test_gpr_replica mca_gpr_base_select failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "GPR replica started\n");
test_success();
}
/* check internals */
internal_tests = ompi_registry.test_internals(1);
if (0 == opal_list_get_size(internal_tests)) { /* should have been something in list */
fprintf(test_out, "internal tests failed\n");
test_failure("test_gpr_replica internal_tests failed\n");
test_finalize();
exit(1);
} else {
fprintf(test_out, "internal test results list\n");
for (ptri = (ompi_registry_internal_test_results_t*)opal_list_get_first(internal_tests);
ptri != (ompi_registry_internal_test_results_t*)opal_list_get_end(internal_tests);
ptri = (ompi_registry_internal_test_results_t*)opal_list_get_next(ptri)) {
fprintf(test_out, "\t%s\n", ptri->test);
fprintf(test_out, "\t%s\n", ptri->message);
}
test_success();
}
/* check index */
test_list = ompi_registry.index(NULL);
if (0 == opal_list_get_size(test_list)) { /* should have been something in dictionary */
fprintf(test_out, "GPR replica: index function failed\n");
test_failure("test_gpr_replica index_global_dictionary failed\n");
test_finalize();
exit(1);
} else {
fprintf(test_out, "GPR index returned list\n");
for (ptr = (ompi_registry_index_value_t*)opal_list_get_first(test_list);
ptr != (ompi_registry_index_value_t*)opal_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)opal_list_get_next(ptr)) {
fprintf(test_out, "\t%s\n", ptr->token);
}
test_success();
}
/* test the put function */
success = true;
input_size = 10000;
test_buffer = (ompi_registry_object_t)malloc(input_size);
test_buf = (uint8_t*)test_buffer;
for (i=0; i<input_size; i++) {
*test_buf = i % 256;
test_buf++;
}
for (j=0; j<10; j++) {
asprintf(&name2[j], "test-key%d", j);
name3[j] = strdup(name2[j]);
}
name2[j] = NULL;
for (j=10; j<20; j++) {
asprintf(&name3[j], "dummy-key%d", j);
}
name3[j] = NULL;
for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i);
if (OMPI_SUCCESS != ompi_registry.put(OMPI_REGISTRY_NONE, name,
name2, test_buffer, input_size)) {
fprintf(test_out, "put test failed for segment %s\n", name);
for (j=0; j<10; j++) {
fprintf(test_out, "\t%s\n", name2[j]);
}
success = false;
}
}
if (success) {
fprintf(test_out, "put test: success\n");
test_success();
} else {
fprintf(test_out, "put test failed\n");
test_failure("test_gpr_replica put_test failed\n");
test_finalize();
exit(1);
}
/* test the put overwrite function */
success = true;
for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i);
if (10 % i) {
mode = OMPI_REGISTRY_OVERWRITE;
} else {
mode = OMPI_REGISTRY_NONE;
}
put_test = ompi_registry.put(mode, name, name2, test_buffer, input_size);
if ((OMPI_REGISTRY_OVERWRITE == mode && OMPI_SUCCESS != put_test) ||
(OMPI_REGISTRY_NONE == mode && OMPI_SUCCESS == put_test)) {
fprintf(test_out, "put test failed for segment %s\n", name);
for (j=0; j<10; j++) {
fprintf(test_out, "\t%s\n", name2[j]);
}
success = false;
}
}
if (success) {
fprintf(test_out, "put overwrite test: success\n");
test_success();
} else {
fprintf(test_out, "put overwrite test failed\n");
test_failure("test_gpr_replica put_test failed\n");
test_finalize();
exit(1);
}
/* test the get function */
success = true;
for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i);
if (10 % i) {
mode = OMPI_REGISTRY_AND;
answer = ompi_registry.get(mode, name, name2);
for (ans = (ompi_registry_value_t*)opal_list_get_first(answer);
ans != (ompi_registry_value_t*)opal_list_get_end(answer);
ans = (ompi_registry_value_t*)opal_list_get_next(ans)) {
if (ans->object_size != input_size) {
success = false;
}
}
} else {
mode = OMPI_REGISTRY_XAND;
answer = ompi_registry.get(mode, name, name3);
if (0 < opal_list_get_size(answer)) { /* should not have gotten a result */
success = false;
}
}
}
if (success) {
fprintf(test_out, "get test: success\n");
test_success();
} else {
fprintf(test_out, "get test failed\n");
test_failure("test_gpr_replica get_test failed\n");
test_finalize();
exit(1);
}
/* test the delete object function */
success = true;
for (i=0; i<5 && success; i+=2) {
sprintf(name, "test-def-seg%d", i);
mode = OMPI_REGISTRY_AND;
if (OMPI_SUCCESS != ompi_registry.delete_object(mode, name, name2)) {
success = false;
}
}
if (success) {
mode = OMPI_REGISTRY_XAND;
if (OMPI_SUCCESS == ompi_registry.delete_object(mode, name, name3)) {
success = false;
}
}
if (success) {
fprintf(test_out, "delete object test: success\n");
test_success();
} else {
fprintf(test_out, "delete_object test failed\n");
test_failure("test_gpr_replica delete_object_test failed\n");
test_finalize();
exit(1);
}
/* check index */
for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i);
test_list = ompi_registry.index(name);
if (0 == opal_list_get_size(test_list)) { /* should have been something in dictionary */
fprintf(test_out, "GPR replica: index function failed\n");
test_failure("test_gpr_replica index_global_dictionary failed\n");
test_finalize();
exit(1);
} else {
fprintf(test_out, "GPR index returned list for segment %s\n", name);
for (ptr = (ompi_registry_index_value_t*)opal_list_get_first(test_list);
ptr != (ompi_registry_index_value_t*)opal_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)opal_list_get_next(ptr)) {
fprintf(test_out, "\t%s\n", ptr->token);
}
}
}
test_success();
/* check the universe segment - should have a key value of "1" */
fclose( test_out );
/* result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_gpr_replica ompi_registry init, etc failed");
}
*/
test_finalize();
unlink("test_gpr_replica_out");
return(0);
}

Просмотреть файл

@ -1,352 +0,0 @@
/*
* unit test for General Purpose Registry replica.
--------------------------------------------------------------------------
Authors: Ralph H. Castain <rhc@lanl.gov>
--------------------------------------------------------------------------
*/
#include "ompi_config.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "include/constants.h"
#include "util/sys_info.h"
#include "util/proc_info.h"
#include "opal/util/output.h"
#include "runtime/runtime.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/gpr/replica/gpr_replica.h"
#include "orte/mca/gpr/replica/gpr_replica_internals.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std";
static void test_cbfunc(ompi_registry_notify_message_t *notify_msg, void *user_tag);
int main(int argc, char **argv)
{
bool multi_thread = false;
bool hidden_thread = false;
opal_list_t *test_list, *internal_tests;
ompi_registry_index_value_t *ptr;
ompi_registry_internal_test_results_t *ptri;
ompi_registry_object_t test_buffer;
uint8_t *test_buf;
ompi_registry_object_size_t input_size;
ompi_registry_mode_t mode;
opal_list_t *answer;
ompi_registry_value_t *ans;
bool multi, hidden;
int i, j, result;
bool success;
char name[30], *name2[30], *name3[30];
int put_test; /* result from system call */
test_init("test_gpr_replica");
/* test_out = fopen( "test_gpr_replica_out", "w+" ); */
test_out = stderr;
if( test_out == NULL ) {
test_failure("test_gpr_replica couldn't open test file failed");
test_finalize();
exit(1);
}
ompi_init(argc, argv);
ompi_process_info.seed = true;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start - please report error to bugs@open-mpi.org\n");
exit (1);
}
fprintf(test_out, "\n\nstarting rte\n");
if (OMPI_SUCCESS != ompi_rte_init(NULL, &multi_thread, &hidden_thread)) {
/* JMS show_help */
printf("show_help: test_gpr_replica failed in ompi_rte_init\n");
test_failure("test_gpr_replica: couldn't start rte");
test_finalize();
exit(1);
}
fprintf(test_out, "\n\ntesting internals\n");
/* check internals */
internal_tests = ompi_registry.test_internals(1);
if (0 == opal_list_get_size(internal_tests)) { /* should have been something in list */
fprintf(test_out, "internal tests failed\n");
test_failure("test_gpr_replica internal_tests failed\n");
test_finalize();
exit(1);
} else {
fprintf(test_out, "internal test results list\n");
for (ptri = (ompi_registry_internal_test_results_t*)opal_list_get_first(internal_tests);
ptri != (ompi_registry_internal_test_results_t*)opal_list_get_end(internal_tests);
ptri = (ompi_registry_internal_test_results_t*)opal_list_get_next(ptri)) {
fprintf(test_out, "\t%s\n", ptri->test);
fprintf(test_out, "\t%s\n", ptri->message);
}
test_success();
}
fprintf(test_out, "\n\ntesting index\n");
/* check index */
test_list = ompi_registry.index(NULL);
if (0 == opal_list_get_size(test_list)) { /* should have been something in dictionary */
fprintf(test_out, "GPR replica: index function failed\n");
test_failure("test_gpr_replica index_global_dictionary failed\n");
test_finalize();
exit(1);
} else {
fprintf(test_out, "GPR index returned list\n");
for (ptr = (ompi_registry_index_value_t*)opal_list_get_first(test_list);
ptr != (ompi_registry_index_value_t*)opal_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)opal_list_get_next(ptr)) {
fprintf(test_out, "\t%s\n", ptr->token);
}
test_success();
}
fprintf(test_out, "\n\ntesting put function\n");
/* test the put function */
success = true;
input_size = 10000;
test_buffer = (ompi_registry_object_t)malloc(input_size);
test_buf = (uint8_t*)test_buffer;
for (i=0; i<input_size; i++) {
*test_buf = i % 256;
test_buf++;
}
for (j=0; j<10; j++) {
asprintf(&name2[j], "test-key%d", j);
name3[j] = strdup(name2[j]);
}
name2[j] = NULL;
for (j=10; j<20; j++) {
asprintf(&name3[j], "dummy-key%d", j);
}
name3[j] = NULL;
for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i);
fprintf(test_out, "\ttesting seg %s\n", name);
if (OMPI_SUCCESS != ompi_registry.put(OMPI_REGISTRY_NONE, name,
name2, test_buffer, input_size)) {
fprintf(test_out, "put test failed for segment %s\n", name);
for (j=0; j<10; j++) {
fprintf(test_out, "\t%s\n", name2[j]);
}
success = false;
}
}
if (success) {
fprintf(test_out, "put test: success\n");
test_success();
} else {
fprintf(test_out, "put test failed\n");
test_failure("test_gpr_replica put_test failed\n");
test_finalize();
exit(1);
}
ompi_registry.dump(0);
fprintf(test_out, "\n\ntesting overwrite function\n");
/* test the put overwrite function */
success = true;
for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i);
if (10 % i) {
mode = OMPI_REGISTRY_OVERWRITE;
} else {
mode = OMPI_REGISTRY_NONE;
}
if (OMPI_REGISTRY_OVERWRITE == mode) {
fprintf(test_out, "\toverwrite on - testing segment %s\n", name);
} else if (OMPI_REGISTRY_NONE == mode) {
fprintf(test_out, "\toverwrite off - testing segment %s\n", name);
}
put_test = ompi_registry.put(mode, name, name2, test_buffer, input_size);
fprintf(test_out, "\t result %d\n", put_test);
if ((OMPI_REGISTRY_OVERWRITE == mode && OMPI_SUCCESS != put_test) ||
(OMPI_REGISTRY_NONE == mode && OMPI_SUCCESS == put_test)) {
fprintf(test_out, "put overwrite test failed for segment %s\n", name);
for (j=0; j<10; j++) {
fprintf(test_out, "\t%s\n", name2[j]);
}
success = false;
}
}
if (success) {
fprintf(test_out, "put overwrite test: success\n");
test_success();
} else {
fprintf(test_out, "put overwrite test failed\n");
test_failure("test_gpr_replica put_test failed\n");
test_finalize();
exit(1);
}
ompi_registry.dump(0);
fprintf(test_out, "\n\ntesting register function\n");
/* test register */
success = true;
if (OMPI_SUCCESS != ompi_registry.rte_register()) {
fprintf(test_out, "register failed\n");
success = false;
} else {
fprintf(test_out, "register succeeded\n");
ompi_registry.dump(0);
}
fprintf(test_out, "\n\ntesting subscription and synchro functions\n");
/* test subscribe and synchro functions */
success = true;
if (OMPI_SUCCESS != ompi_registry.subscribe(OMPI_REGISTRY_AND,
OMPI_REGISTRY_NOTIFY_MODIFICATION,
name, name2, test_cbfunc, NULL)) {
fprintf(test_out, "subscribe to %s with key %s failed\n", name, *name2);
success = false;
} else {
fprintf(test_out, "subscribe to %s with key %s succeeded\n", name, *name2);
if (OMPI_SUCCESS != ompi_registry.synchro(OMPI_REGISTRY_SYNCHRO_MODE_LEVEL,
OMPI_REGISTRY_AND,
name, name2, 10,
test_cbfunc, NULL)) {
fprintf(test_out, "synchro to %s with key %s failed\n", name, *name2);
success = false;
} else {
fprintf(test_out, "synchro to %s with key %s succeeded\n", name, *name2);
ompi_registry.dump(0);
}
}
fprintf(test_out, "\n\ntesting unregister function\n");
/* test unregister */
success = true;
if (OMPI_SUCCESS != ompi_registry.rte_unregister(OMPI_REGISTRY_UNREGISTER_NORMAL, ompi_process_info.name)) {
fprintf(test_out, "unregister of self failed\n");
success = false;
} else {
fprintf(test_out, "unregister of self succeeded\n");
ompi_registry.dump(0);
}
fprintf(test_out, "\n\ntesting get function\n");
/* test the get function */
success = true;
for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i);
if (10 % i) {
mode = OMPI_REGISTRY_AND;
answer = ompi_registry.get(mode, name, name2);
for (ans = (ompi_registry_value_t*)opal_list_get_first(answer);
ans != (ompi_registry_value_t*)opal_list_get_end(answer);
ans = (ompi_registry_value_t*)opal_list_get_next(ans)) {
if (ans->object_size != input_size) {
success = false;
}
}
} else {
mode = OMPI_REGISTRY_XAND;
answer = ompi_registry.get(mode, name, name3);
if (0 < opal_list_get_size(answer)) { /* should not have gotten a result */
success = false;
}
}
}
if (success) {
fprintf(test_out, "get test: success\n");
test_success();
} else {
fprintf(test_out, "get test failed\n");
test_failure("test_gpr_replica get_test failed\n");
test_finalize();
exit(1);
}
fprintf(test_out, "\n\ntesting delete object function\n");
/* test the delete object function */
success = true;
for (i=0; i<5 && success; i+=2) {
sprintf(name, "test-def-seg%d", i);
mode = OMPI_REGISTRY_AND;
if (OMPI_SUCCESS != ompi_registry.delete_object(mode, name, name2)) {
success = false;
}
}
if (success) {
mode = OMPI_REGISTRY_XAND;
if (OMPI_SUCCESS == ompi_registry.delete_object(mode, name, name3)) {
success = false;
}
}
if (success) {
fprintf(test_out, "delete object test: success\n");
test_success();
} else {
fprintf(test_out, "delete_object test failed\n");
test_failure("test_gpr_replica delete_object_test failed\n");
test_finalize();
exit(1);
}
ompi_registry.dump(0);
fprintf(test_out, "\n\ntesting index function\n");
/* check index */
for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i);
test_list = ompi_registry.index(name);
if (0 == opal_list_get_size(test_list)) { /* should have been something in dictionary */
fprintf(test_out, "GPR replica: index function failed\n");
test_failure("test_gpr_replica index_global_dictionary failed\n");
test_finalize();
exit(1);
} else {
fprintf(test_out, "GPR index returned list for segment %s\n", name);
for (ptr = (ompi_registry_index_value_t*)opal_list_get_first(test_list);
ptr != (ompi_registry_index_value_t*)opal_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)opal_list_get_next(ptr)) {
fprintf(test_out, "\t%s\n", ptr->token);
}
}
}
test_success();
/* check the universe segment - should have a key value of "1" */
fclose( test_out );
result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_gpr_replica ompi_registry init, etc failed");
}
test_finalize();
return(0);
}
static void test_cbfunc(ompi_registry_notify_message_t *notify_msg, void *user_tag)
{
return;
}

Просмотреть файл

@ -1,89 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
AM_CPPFLAGS = -I$(top_srcdir)/test/support
check_PROGRAMS = \
ns_replica \
ns_proxy \
ns_nds \
ns_dt_buffer \
ns_dt_compare \
ns_dt_print \
ns_dt_size \
ns_dt_release \
ns_dt_copy
TESTS = \
$(check_PROGRAMS)
ns_replica_SOURCES = ns_replica.c
ns_replica_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
ns_replica_DEPENDENCIES = $(ns_replica_LDADD)
ns_proxy_SOURCES = ns_proxy.c
ns_proxy_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
ns_proxy_DEPENDENCIES = $(ns_proxy_LDADD)
ns_nds_SOURCES = ns_nds.c
ns_nds_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
ns_nds_DEPENDENCIES = $(ns_nds_LDADD)
ns_dt_buffer_SOURCES = ns_dt_buffer.c
ns_dt_buffer_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
ns_dt_buffer_DEPENDENCIES = $(ns_dt_buffer_LDADD)
ns_dt_copy_SOURCES = ns_dt_copy.c
ns_dt_copy_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
ns_dt_copy_DEPENDENCIES = $(ns_dt_copy_LDADD)
ns_dt_compare_SOURCES = ns_dt_compare.c
ns_dt_compare_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
ns_dt_compare_DEPENDENCIES = $(ns_dt_compare_LDADD)
ns_dt_print_SOURCES = ns_dt_print.c
ns_dt_print_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
ns_dt_print_DEPENDENCIES = $(ns_dt_print_LDADD)
ns_dt_size_SOURCES = ns_dt_size.c
ns_dt_size_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
ns_dt_size_DEPENDENCIES = $(ns_dt_size_LDADD)
ns_dt_release_SOURCES = ns_dt_release.c
ns_dt_release_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
ns_dt_release_DEPENDENCIES = $(ns_dt_release_LDADD)

Просмотреть файл

@ -1,263 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_name(void); /* buffer actions */
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_ns_base_open()) {
fprintf(stderr, "NS opened\n");
} else {
fprintf(stderr, "NS could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_name\n");
if (test_name()) {
fprintf(stderr, "Test_name succeeded\n");
}
else {
fprintf(stderr, "Test_name failed\n");
}
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_ns_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_name(void) /* buffer actions */
{
orte_buffer_t *bufA;
int rc;
size_t i;
orte_process_name_t src[NUM_ELEMS];
orte_process_name_t dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
src[i].cellid = 1000+i;
src[i].jobid = 100+i;
src[i].vpid = i;
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(stderr, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_NAME);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
size_t count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_NAME);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(stderr, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src[j].cellid != dst[j].cellid ||
src[j].jobid != dst[j].jobid ||
src[j].vpid != dst[j].vpid) {
fprintf(stderr, "test5: invalid results from unpack\n");
return(false);
}
}
}
/* cleanup */
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(stderr, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return(true);
}
static bool test_unstruct(void)
{
orte_buffer_t *bufA;
int rc;
orte_cellid_t scell[NUM_ELEMS], dcell[NUM_ELEMS];
orte_vpid_t svpid[NUM_ELEMS], dvpid[NUM_ELEMS];
orte_jobid_t sjobid[NUM_ELEMS], djobid[NUM_ELEMS];
int i;
for (i=0; i < NUM_ELEMS; i++) {
scell[i] = i + 1000;
svpid[i] = 208*i;
sjobid[i] = i;
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(stderr, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, scell, NUM_ELEMS, ORTE_CELLID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, svpid, NUM_ELEMS, ORTE_VPID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, sjobid, NUM_ELEMS, ORTE_JOBID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
size_t count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dcell, &count, ORTE_CELLID);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(stderr, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dvpid, &count, ORTE_VPID);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(stderr, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, djobid, &count, ORTE_JOBID);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(stderr, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(scell[j] != dcell[j] ||
sjobid[j] != djobid[j] ||
svpid[j] != dvpid[j]) {
fprintf(stderr, "test5: invalid results from unpack\n");
return(false);
}
}
}
/* cleanup */
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(stderr, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return(true);
}

Просмотреть файл

@ -1,201 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/base/base.h"
static bool test_name(void); /* buffer actions */
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
stderr = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_ns_base_open()) {
fprintf(stderr, "NS opened\n");
} else {
fprintf(stderr, "NS could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_name\n");
if (test_name()) {
fprintf(stderr, "Test_name succeeded\n");
}
else {
fprintf(stderr, "Test_name failed\n");
}
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_ns_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_name(void) /* buffer actions */
{
int rc;
orte_process_name_t src;
orte_process_name_t *dst;
src.cellid = 1000;
src.jobid = 100;
src.vpid = 150;
rc = orte_dss.copy((void**)&dst, &src, ORTE_NAME);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if(ORTE_EQUAL != orte_dss.compare(dst, &src, ORTE_NAME)) {
fprintf(stderr, "orte_dss.compare: invalid results from copy\n");
return(false);
}
return(true);
}
static bool test_unstruct(void)
{
int rc;
orte_cellid_t scell, *dcell;
orte_vpid_t svpid, *dvpid;
orte_jobid_t sjobid, *djobid;
scell = 1000;
svpid = 208;
sjobid = 5;
rc = orte_dss.copy((void**)&dcell, &scell, ORTE_CELLID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.copy((void**)&djobid, &sjobid, ORTE_JOBID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.copy((void**)&dvpid, &svpid, ORTE_VPID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if(ORTE_EQUAL != orte_dss.compare(dcell, &scell, ORTE_CELLID) ||
ORTE_EQUAL != orte_dss.compare(djobid, &sjobid, ORTE_JOBID) ||
ORTE_EQUAL != orte_dss.compare(dvpid, &svpid, ORTE_VPID)) {
fprintf(stderr, "test_unstruct: failed comparison\n");
return(false);
}
scell++;
sjobid++;
svpid++;
if (ORTE_VALUE2_GREATER != orte_dss.compare(dcell, &scell, ORTE_CELLID) ||
ORTE_VALUE2_GREATER != orte_dss.compare(djobid, &sjobid, ORTE_JOBID) ||
ORTE_VALUE2_GREATER != orte_dss.compare(dvpid, &svpid, ORTE_VPID)) {
fprintf(stderr, "test_unstruct: failed comparison\n");
return(false);
}
scell -= 2;
sjobid -= 2;
svpid -= 2;
if (ORTE_VALUE1_GREATER != orte_dss.compare(dcell, &scell, ORTE_CELLID) ||
ORTE_VALUE1_GREATER != orte_dss.compare(djobid, &sjobid, ORTE_JOBID) ||
ORTE_VALUE1_GREATER != orte_dss.compare(dvpid, &svpid, ORTE_VPID)) {
fprintf(stderr, "test_unstruct: failed comparison\n");
return(false);
}
return(true);
}

Просмотреть файл

@ -1,185 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/base/base.h"
#define NUM_ELEMS 10
static bool test_name(void); /* buffer actions */
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
stderr = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_ns_base_open()) {
fprintf(stderr, "NS opened\n");
} else {
fprintf(stderr, "NS could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_name\n");
if (test_name()) {
fprintf(stderr, "Test_name succeeded\n");
}
else {
fprintf(stderr, "Test_name failed\n");
}
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_ns_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_name(void) /* buffer actions */
{
int rc;
orte_process_name_t src;
orte_process_name_t *dst;
src.cellid = 1000;
src.jobid = 100;
src.vpid = 150;
rc = orte_dss.copy((void**)&dst, &src, ORTE_NAME);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if(src.cellid != dst->cellid ||
src.jobid != dst->jobid ||
src.vpid != dst->vpid) {
fprintf(stderr, "test5: invalid results from copy");
return(false);
}
return(true);
}
static bool test_unstruct(void)
{
int rc;
orte_cellid_t scell, *dcell;
orte_vpid_t svpid, *dvpid;
orte_jobid_t sjobid, *djobid;
scell = 1000;
svpid = 208;
sjobid = 5;
rc = orte_dss.copy((void**)&dcell, &scell, ORTE_CELLID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.copy((void**)&djobid, &sjobid, ORTE_JOBID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.copy((void**)&dvpid, &svpid, ORTE_VPID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if(scell != *dcell ||
sjobid != *djobid ||
svpid != *dvpid) {
fprintf(stderr, "test_unstruct: invalid results from copy");
return(false);
}
return(true);
}

Просмотреть файл

@ -1,191 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/base/base.h"
static bool test_name(void); /* buffer actions */
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
stderr = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_ns_base_open()) {
fprintf(stderr, "NS opened\n");
} else {
fprintf(stderr, "NS could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_name\n");
if (test_name()) {
fprintf(stderr, "Test_name succeeded\n");
}
else {
fprintf(stderr, "Test_name failed\n");
}
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_ns_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_name(void) /* buffer actions */
{
orte_process_name_t src;
char *output;
src.cellid = 1000;
src.jobid = 100;
src.vpid = 150;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &src, ORTE_NAME)) {
fprintf(stderr, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_NAME value\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_NAME value: %s\n", output);
free(output);
return(true);
}
static bool test_unstruct(void)
{
orte_cellid_t scell;
orte_vpid_t svpid;
orte_jobid_t sjobid;
char *output;
scell = 1000;
svpid = 208;
sjobid = 5;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &scell, ORTE_CELLID)) {
fprintf(stderr, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_CELLID value\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_CELLID value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &sjobid, ORTE_JOBID)) {
fprintf(stderr, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_JOBID value\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_JOBID value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &svpid, ORTE_VPID)) {
fprintf(stderr, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_VPID value\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_VPID value: %s\n", output);
free(output);
return(true);
}

Просмотреть файл

@ -1,249 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/base/base.h"
static bool test_name(void); /* buffer actions */
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
stderr = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_ns_base_open()) {
fprintf(stderr, "NS opened\n");
} else {
fprintf(stderr, "NS could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_name\n");
if (test_name()) {
fprintf(stderr, "Test_name succeeded\n");
}
else {
fprintf(stderr, "Test_name failed\n");
}
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_ns_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_name(void) /* buffer actions */
{
orte_process_name_t src;
orte_process_name_t *dst;
orte_data_value_t *dval2, dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
src.cellid = 1000;
src.jobid = 100;
src.vpid = 150;
dval2 = OBJ_NEW(orte_data_value_t);
dval2->type = ORTE_NAME;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval2->data), &src, ORTE_NAME)) {
fprintf(stderr, "orte_dss.copy ORTE_NAME returned error\n");
return(false);
}
orte_dss.release(dval2);
if (NULL != dval2->data) {
fprintf(stderr, "orte_dss.release ORTE_NAME failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, &src, ORTE_NAME)) {
fprintf(stderr, "orte_dss.copy ORTE_NAME returned error\n");
return(false);
}
dval.type = ORTE_NAME;
dval.data = dst;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(stderr, "orte_dss.release ORTE_NAME failed to NULL pointer\n");
return(false);
}
return(true);
}
static bool test_unstruct(void)
{
orte_cellid_t scell, *dcell;
orte_vpid_t svpid, *dvpid;
orte_jobid_t sjobid, *djobid;
orte_data_value_t *dval2, dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
scell = 1000;
svpid = 208;
sjobid = 5;
dval2 = OBJ_NEW(orte_data_value_t);
dval2->type = ORTE_CELLID;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval2->data), &scell, ORTE_CELLID)) {
fprintf(stderr, "orte_dss.copy ORTE_CELLID returned error\n");
return(false);
}
orte_dss.release(dval2);
if (NULL != dval2->data) {
fprintf(stderr, "orte_dss.release ORTE_CELLID failed to NULL pointer\n");
return(false);
}
OBJ_RELEASE(dval2);
if (ORTE_SUCCESS != orte_dss.copy((void**)&dcell, &scell, ORTE_CELLID)) {
fprintf(stderr, "orte_dss.copy ORTE_CELLID returned error\n");
return(false);
}
dval.type = ORTE_CELLID;
dval.data = dcell;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(stderr, "orte_dss.release ORTE_CELLID failed to NULL pointer\n");
return(false);
}
dval2 = OBJ_NEW(orte_data_value_t);
dval2->type = ORTE_JOBID;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval2->data), &sjobid, ORTE_JOBID)) {
fprintf(stderr, "orte_dss.copy ORTE_JOBID returned error\n");
return(false);
}
orte_dss.release(dval2);
if (NULL != dval2->data) {
fprintf(stderr, "orte_dss.release ORTE_JOBID failed to NULL pointer\n");
return(false);
}
OBJ_RELEASE(dval2);
if (ORTE_SUCCESS != orte_dss.copy((void**)&djobid, &sjobid, ORTE_JOBID)) {
fprintf(stderr, "orte_dss.copy ORTE_JOBID returned error\n");
return(false);
}
dval.type = ORTE_JOBID;
dval.data = djobid;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(stderr, "orte_dss.release ORTE_JOBID failed to NULL pointer\n");
return(false);
}
dval2 = OBJ_NEW(orte_data_value_t);
dval2->type = ORTE_VPID;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval2->data), &svpid, ORTE_VPID)) {
fprintf(stderr, "orte_dss.copy ORTE_VPID returned error\n");
return(false);
}
orte_dss.release(dval2);
if (NULL != dval2->data) {
fprintf(stderr, "orte_dss.release ORTE_VPID failed to NULL pointer\n");
return(false);
}
OBJ_RELEASE(dval2);
if (ORTE_SUCCESS != orte_dss.copy((void**)&dvpid, &svpid, ORTE_VPID)) {
fprintf(stderr, "orte_dss.copy ORTE_VPID returned error\n");
return(false);
}
dval.type = ORTE_VPID;
dval.data = dvpid;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(stderr, "orte_dss.release ORTE_VPID failed to NULL pointer\n");
return(false);
}
return(true);
}

Просмотреть файл

@ -1,229 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/base/base.h"
static bool test_name(void); /* buffer actions */
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
stderr = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_ns_base_open()) {
fprintf(stderr, "NS opened\n");
} else {
fprintf(stderr, "NS could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_name\n");
if (test_name()) {
fprintf(stderr, "Test_name succeeded\n");
}
else {
fprintf(stderr, "Test_name failed\n");
}
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_ns_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_name(void) /* buffer actions */
{
int rc;
orte_process_name_t src;
size_t sz;
src.cellid = 1000;
src.jobid = 100;
src.vpid = 150;
rc = orte_dss.size(&sz, &src, ORTE_NAME);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
if(sz != sizeof(orte_process_name_t)) {
fprintf(stderr, "orte_dss.size: invalid results\n");
return(false);
}
rc = orte_dss.size(&sz, NULL, ORTE_NAME);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size with NULL failed with return code %d\n", rc);
return(false);
}
if(sz != sizeof(orte_process_name_t)) {
fprintf(stderr, "orte_dss.size: with NULL invalid results\n");
return(false);
}
return(true);
}
static bool test_unstruct(void)
{
int rc;
orte_cellid_t scell;
orte_vpid_t svpid;
orte_jobid_t sjobid;
size_t sz;
scell = 1000;
svpid = 208;
sjobid = 5;
rc = orte_dss.size(&sz, &scell, ORTE_CELLID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
if(sz != sizeof(orte_cellid_t)) {
fprintf(stderr, "orte_dss.size: invalid results\n");
return(false);
}
rc = orte_dss.size(&sz, NULL, ORTE_CELLID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size with NULL failed with return code %d\n", rc);
return(false);
}
if(sz != sizeof(orte_cellid_t)) {
fprintf(stderr, "orte_dss.size: with NULL invalid results\n");
return(false);
}
rc = orte_dss.size(&sz, &sjobid, ORTE_JOBID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
if(sz != sizeof(orte_jobid_t)) {
fprintf(stderr, "orte_dss.size: invalid results\n");
return(false);
}
rc = orte_dss.size(&sz, NULL, ORTE_JOBID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size with NULL failed with return code %d\n", rc);
return(false);
}
if(sz != sizeof(orte_jobid_t)) {
fprintf(stderr, "orte_dss.size: with NULL invalid results\n");
return(false);
}
rc = orte_dss.size(&sz, &svpid, ORTE_VPID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
if(sz != sizeof(orte_vpid_t)) {
fprintf(stderr, "orte_dss.size: invalid results\n");
return(false);
}
rc = orte_dss.size(&sz, NULL, ORTE_VPID);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size with NULL failed with return code %d\n", rc);
return(false);
}
if(sz != sizeof(orte_vpid_t)) {
fprintf(stderr, "orte_dss.size: with NULL invalid results\n");
return(false);
}
return(true);
}

Просмотреть файл

@ -1,225 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "support.h"
#include "components.h"
#include "include/constants.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include "runtime/runtime.h"
#include "util/proc_info.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "opal/mca/base/base.h"
#include "orte/mca/ns/ns.h"
#include "orte/mca/ns/base/base.h"
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static FILE *test_out;
static mca_ns_base_module_t *ns_module = NULL;
int main (int argc, char* argv[])
{
test_component_handle_t ns_handle;
mca_ns_base_component_t *ns_component = NULL;
int priority;
test_init("orte_ns_nds");
test_out = stderr;
/* Open up the output streams */
if (!opal_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads -
* and reset otherwise.
*/
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
opal_malloc_init();
/* set seed to true to force replica selection */
orte_process_info.seed = true;
/* ensure the replica is isolated */
setenv("OMPI_MCA_ns_replica_isolate", "1", 1);
/* init the proc info structure */
orte_proc_info();
/* startup the MCA */
if (OMPI_SUCCESS != mca_base_open()) {
fprintf(stderr, "can't open mca\n");
exit (1);
}
/* Open the ns replica component and initialize a module */
if (OMPI_SUCCESS !=
test_component_open("ns", "replica", &ns_handle,
(mca_base_component_t**) &ns_component) ||
NULL == ns_component) {
test_fail_stop("Could not open ns replica\n", 1);
}
ns_module = ns_component->ns_init(&priority);
if (NULL == ns_module) {
test_fail_stop("NS replica component did not return a module\n", 1);
}
fprintf(test_out, "executing test1\n");
if (test1()) {
test_success();
}
else {
test_failure("orte_dps test1 failed");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
test_success();
}
else {
test_failure("orte_dps test2 failed");
}
/* finalize and see if memory cleared */
if (NULL != ns_component->ns_finalize) {
ns_component->ns_finalize();
}
test_component_close(&ns_handle);
orte_proc_info_finalize();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
fclose( test_out );
test_finalize();
return (0);
}
static bool test1(void) /* check seed/singleton name discovery */
{
orte_process_name_t seed={0,0,0};
int rc;
orte_process_info.seed = true;
if (ORTE_SUCCESS != (rc = ns_module->set_my_name())) {
test_comment("set_my_name failed for seed/singleton case");
fprintf(test_out, "set_my_name failed for seed/singleton case with return %s\n",
ORTE_ERROR_NAME(rc));
return false;
}
if (NULL == orte_process_info.my_name) {
test_comment("name_discovery failed for seed/singleton case - NULL name");
fprintf(test_out, "name_discovery failed for seed/singleton case - NULL name\n");
return false;
}
if (0 != ns_module->compare(ORTE_NS_CMP_ALL, orte_process_info.my_name, &seed)) {
test_comment("name_discovery failed for seed/singleton case - name mismatch");
fprintf(test_out, "name_discovery failed for seed/singleton case - name mismatch\n");
return false;
}
return (true);
}
/*
* check environment name discovery
*/
static bool test2(void)
{
int rc;
orte_process_name_t dummy={2,5,21456};
if (NULL != orte_process_info.my_name) { /* cleanup from prior test */
free(orte_process_info.my_name);
orte_process_info.my_name = NULL;
}
orte_process_info.seed = false;
if (ORTE_SUCCESS != (rc = ns_module->copy_process_name(&orte_process_info.ns_replica, &dummy))) {
test_comment("unable to copy name");
fprintf(test_out, "unable to copy name with return %s\n",
ORTE_ERROR_NAME(rc));
return false;
}
setenv("OMPI_MCA_ns_nds", "env", 1);
setenv("OMPI_MCA_ns_nds_cellid", "2", 1);
setenv("OMPI_MCA_ns_nds_jobid", "5", 1);
setenv("OMPI_MCA_ns_nds_vpid", "21456", 1);
setenv("OMPI_MCA_ns_nds_vpid_start", "0", 1);
setenv("OMPI_MCA_ns_nds_num_procs", "100000", 1);
if (ORTE_SUCCESS != (rc = ns_module->set_my_name())) {
test_comment("set_my_name failed for env case");
fprintf(test_out, "set_my_name failed for env case with return %s\n",
ORTE_ERROR_NAME(rc));
return false;
}
if (NULL == orte_process_info.my_name) {
test_comment("name_discovery failed for env case - NULL name");
fprintf(test_out, "name_discovery failed for env case - NULL name\n");
return false;
}
if (0 != ns_module->compare(ORTE_NS_CMP_ALL, orte_process_info.my_name, &dummy)) {
test_comment("name_discovery failed for env case - name mismatch");
fprintf(test_out, "name_discovery failed for env case - name mismatch\n");
return false;
}
if (0 != orte_process_info.vpid_start) {
test_comment("name_discovery failed for env case - wrong vpid_start");
fprintf(test_out, "name_discovery failed for env case - wrong vpid_start\n");
return false;
}
if (100000 != orte_process_info.num_procs) {
test_comment("name_discovery failed for env case - wrong num_procs");
fprintf(test_out, "name_discovery failed for env case - wrong num_procs\n");
return false;
}
return (true);
}

Просмотреть файл

@ -1,263 +0,0 @@
/*
* unit test for name server proxy.
--------------------------------------------------------------------------
Authors: Ralph H. Castain <rhc@lanl.gov>
Tim S. Woodall <twoodall@lanl.gov>
--------------------------------------------------------------------------
*/
#include "ompi_config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "support.h"
#include "include/constants.h"
#include "util/sys_info.h"
#include "util/proc_info.h"
#include "opal/util/output.h"
#include "opal/event/event.h"
#include "runtime/runtime.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "orte/mca/ns/base/base.h"
#include "orte/mca/oob/base/base.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_ns_proxy_out ./test_ns_replica_out_std";
static void run_test(void);
static int exec_client(int argc, char** argv);
int main(int argc, char **argv)
{
printf("Test test_ns_proxy disabled. Does not compile.\n");
return 77;
#if 0
bool multi, hidden;
char *seed;
test_init("test_ns_proxy");
test_out = fopen( "test_ns_proxy_out", "w+" );
if( test_out == NULL ) {
test_failure("test_ns_proxy couldn't open test file failed");
test_finalize();
exit(1);
}
/* setup environment for rte */
seed = getenv("OMPI_DAEMON_SEED");
setenv("OMPI_MCA_pcmclient_env_num_procs", "2", 1);
setenv("OMPI_MCA_pcmclient_env_vpid_start", "0", 1);
setenv("OMPI_MCA_pcmclient_env_cellid", "0", 1);
setenv("OMPI_MCA_pcmclient_env_jobid", "0", 1);
if(seed == NULL || atoi(seed) != 0) {
ompi_process_info.seed = true;
setenv("OMPI_MCA_pcmclient_env_procid", "0", 1);
} else {
ompi_process_info.seed = false;
setenv("OMPI_MCA_pcmclient_env_procid", "1", 1);
}
/* require tcp oob */
setenv("OMPI_MCA_oob_base_include", "tcp", 1);
/* basic ompi init */
if (OMPI_SUCCESS != ompi_init(argc, argv)) {
fprintf(test_out, "ompi_init failed - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* initialize event library */
if (OMPI_SUCCESS != opal_event_init()) {
fprintf(test_out, "opal_event_init failed - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* initialize the rte - including ns and oob */
if(OMPI_SUCCESS == ompi_rte_init(&multi, &hidden)) {
fprintf(test_out, "NS opened\n");
fprintf(test_out, "NS started\n");
} else {
fprintf(test_out, "RTE could not start - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* if daemon seed - just wait for requests */
if(ompi_process_info.seed) {
#if 0
/* wait on child to exit */
int pid = exec_client(argc, argv);
while(true) {
int status;
if(waitpid(pid, &status, WNOHANG) != 0)
break;
opal_event_loop(OPAL_EVLOOP_NONBLOCK);
}
#else
fprintf(stderr, "OMPI_MCA_oob_base_seed=%s", mca_oob_get_contact_info());
opal_event_loop(0);
#endif
} else {
run_test();
}
return(0);
}
int exec_client(int argc, char** argv)
{
int pid;
pid = fork();
if(pid < 0) {
fprintf(test_out, "fork() failed with errno=%d\n", errno);
exit(1);
} else if (pid == 0) {
/* child process should not be a daemon */
static char seed_flag[] = "OMPI_DAEMON_SEED=0";
static char seed_addr[128];
char* argp[] = {
seed_flag,
seed_addr,
NULL
};
/* setup seed address for child process */
sprintf(seed_addr, "OMPI_MCA_oob_base_seed=%s", mca_oob_get_contact_info());
execve(argv[0], argv, argp);
}
return pid;
}
void run_test(void)
{
ompi_process_name_t *test_name;
mca_ns_base_cellid_t cell;
mca_ns_base_jobid_t job;
mca_ns_base_vpid_t vpid;
int i, j;
char *tmp;
int result; /* result from system call */
/* create a name */
test_name = ompi_name_server.create_process_name(0, 1, 1);
if (NULL == test_name) { /* got error */
fprintf(test_out, "create process name failed\n");
test_failure("test_ns_replica ompi_name_server create_process_name failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "got process name: %0X %0X %0X\n",
test_name->cellid, test_name->jobid, test_name->vpid);
test_success();
}
/* convert a string to a name */
tmp = strdup("1234.5678.9AEF");
test_name = ompi_name_server.convert_string_to_process_name(tmp);
if (NULL == test_name) { /* got error */
fprintf(test_out, "convert string to process name failed\n");
test_failure("test_ns_replica ompi_name_server convert_string_to_process_name failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "got process name: %0X(%ld) %0X(%ld) %0X(%ld)\n",
(int)test_name->cellid, (long int)test_name->cellid, (int)test_name->jobid,
(long int)test_name->jobid, (unsigned int)test_name->vpid,
(long int)test_name->vpid);
test_success();
}
/* create a cellid */
cell = ompi_name_server.create_cellid();
if (0 == cell) { /* got error */
test_failure("test_ns_replica ompi_name_server test create_cellid");
fprintf(test_out, "create cellid: error\n");
test_finalize();
exit(1);
} else {
fprintf(test_out, "cellid created: %d\n", cell);
test_success();
}
for (i=0; i<10; i++) { /* loop through */
/* create jobid */
job = ompi_name_server.create_jobid();
if (0 == job) { /* got error */
fprintf(test_out, "create jobid: error\n");
test_failure("test_ns_replica ompi_name_server create_jobid failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "jobid created: %d\n", job);
test_success();
}
for (j=0; j<5; j++) { /* loop through several vpid ranges */
/* get range of vpids */
vpid = ompi_name_server.reserve_range(job, 250);
if (0 == vpid) { /* got error */
fprintf(test_out, "get range: error\n");
test_failure("test_ns_replica ompi_name_server reserve_range failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "range reserved: %d\n", vpid);
test_success();
}
/* create a name */
test_name = ompi_name_server.create_process_name((mca_ns_base_cellid_t)i,
job, vpid);
/* get and print its string values */
tmp = ompi_name_server.get_proc_name_string(test_name);
fprintf(test_out, "(%d) strings: name - %s\n", i, tmp);
tmp = ompi_name_server.get_vpid_string(test_name);
fprintf(test_out, "\tvpid: %s\n", tmp);
tmp = ompi_name_server.get_jobid_string(test_name);
fprintf(test_out, "\tjobid: %s\n", tmp);
tmp = ompi_name_server.get_cellid_string(test_name);
fprintf(test_out, "\tcellid: %s\n", tmp);
/* get and print its numeric values */
vpid = ompi_name_server.get_vpid(test_name);
job = ompi_name_server.get_jobid(test_name);
cell = ompi_name_server.get_cellid(test_name);
fprintf(test_out, "(%d) ints cell %0X(%ld) job %0X(%ld) vpid %0x(%ld)\n\n",
i, cell, (long int)cell, job, (long int)job, vpid, (long int)vpid);
}
}
fclose( test_out );
result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_ns_replica ompi_name_server get_proc_name_string, etc failed");
}
test_finalize();
#endif
}

Просмотреть файл

@ -1,278 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "components.h"
#include "orte/orte_constants.h"
#include "orte/mca/schema/schema.h"
#include "util/proc_info.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "orte/mca/ns/base/base.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std";
int main(int argc, char **argv)
{
orte_process_name_t *test_name;
orte_cellid_t cell;
orte_jobid_t job;
orte_vpid_t vpid;
int i, j, rc;
char *tmp, *site, *resource;
test_component_handle_t ns_handle;
mca_ns_base_component_t *ns_component = NULL;
mca_ns_base_module_t *ns_module = NULL;
int priority;
test_init("test_ns_replica");
test_out = fopen( "test_ns_replica_out", "w+" );
if( test_out == NULL ) {
test_failure("test_ns_replica couldn't open test file failed");
test_finalize();
exit(1);
}
/* Open up the output streams */
if (!opal_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads -
* and reset otherwise.
*/
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
opal_malloc_init();
/* set seed to true to force replica selection */
orte_process_info.seed = true;
/* ensure the replica is isolated */
setenv("OMPI_MCA_ns_replica_isolate", "1", 1);
/* init the proc info structure */
orte_proc_info();
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* Open the ns replica component and initialize a module */
if (OMPI_SUCCESS !=
test_component_open("ns", "replica", &ns_handle,
(mca_base_component_t**) &ns_component) ||
NULL == ns_component) {
test_fail_stop("Could not open ns replica\n", 1);
}
ns_module = ns_component->ns_init(&priority);
if (NULL == ns_module) {
test_fail_stop("NS replica component did not return a module\n", 1);
}
/* create a name */
if (ORTE_SUCCESS != (rc = ns_module->create_process_name(&test_name, 0, 1, 1))) { /* got error */
fprintf(test_out, "create process name failed with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica orte_ns create_process_name failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "got process name: %lu %lu %lu\n", ORTE_NAME_ARGS(test_name));
test_success();
}
free(test_name);
/* convert a string to a name */
tmp = strdup("1234.5678.9AEF");
if (ORTE_SUCCESS != (rc = ns_module->convert_string_to_process_name(&test_name, tmp))) { /* got error */
fprintf(test_out, "convert string to process name failed with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica orte_ns convert_string_to_process_name failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "got process name: %lu %lu %lu\n",
ORTE_NAME_ARGS(test_name));
test_success();
}
free(tmp);
free(test_name);
/* create a cellid */
if (ORTE_SUCCESS != (rc = ns_module->create_cellid(&cell, "dummy-site", "dummy-resource"))) { /* got error */
test_failure("test_ns_replica orte_ns test create_cellid failed");
fprintf(test_out, "create cellid: error with error %s\n", ORTE_ERROR_NAME(rc));
test_finalize();
exit(1);
} else {
fprintf(test_out, "cellid created: %lu\n", (unsigned long) cell);
test_success();
}
/* get cellid info */
if (ORTE_SUCCESS != (rc = ns_module->get_cell_info(cell, &site, &resource))) { /* got error */
test_failure("test_ns_replica orte_ns test get_cell_info failed");
fprintf(test_out, "get_cell_info: error with error %s\n", ORTE_ERROR_NAME(rc));
test_finalize();
exit(1);
} else {
fprintf(test_out, "get_cell_info: %lu %s %s\n", (unsigned long) cell, site, resource);
test_success();
}
for (i=0; i<10; i++) { /* loop through */
/* create jobid */
if (ORTE_SUCCESS != (rc = ns_module->create_jobid(&job))) { /* got error */
fprintf(test_out, "create jobid: error with error %s\n", ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica orte_ns create_jobid failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "jobid created: %lu\n", (unsigned long) job);
test_success();
}
for (j=0; j<5; j++) { /* loop through several vpid ranges */
/* get range of vpids */
if (ORTE_SUCCESS != (rc = ns_module->reserve_range(job, 250, &vpid))) { /* got error */
fprintf(test_out, "get range: error with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica orte_ns reserve_range failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "range reserved: %lu\n",
(unsigned long) vpid);
test_success();
}
/* create a name */
if (ORTE_SUCCESS != (rc = ns_module->create_process_name(&test_name, (orte_cellid_t)i,
job, vpid))) {
fprintf(test_out, "test_ns_replica: failed to create proc name after vpid range with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica: failed to create proc name after vpid range");
test_finalize();
exit(1);
}
/* get and print its string values */
if (ORTE_SUCCESS != (rc = ns_module->get_proc_name_string(&tmp, test_name))) {
fprintf(test_out, "test_ns_replica: failed to get proc_name_string with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica: failed to get proc_name_string");
test_finalize();
exit(1);
} else {
fprintf(test_out, "(%d) strings: name - %s\n", i, tmp);
}
free(tmp);
if (ORTE_SUCCESS != (rc = ns_module->get_vpid_string(&tmp, test_name))) {
fprintf(test_out, "test_ns_replica: failed to get vpid_string with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica: failed to get vpid_string");
test_finalize();
exit(1);
} else {
fprintf(test_out, "(%d) strings: vpid - %s\n", i, tmp);
}
free(tmp);
if (ORTE_SUCCESS != (rc = ns_module->get_jobid_string(&tmp, test_name))) {
fprintf(test_out, "test_ns_replica: failed to get jobid_string with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica: failed to get jobid_string");
test_finalize();
exit(1);
} else {
fprintf(test_out, "(%d) strings: jobid - %s\n", i, tmp);
}
free(tmp);
if (ORTE_SUCCESS != (rc = ns_module->get_cellid_string(&tmp, test_name))) {
fprintf(test_out, "test_ns_replica: failed to get cellid_string with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica: failed to get cellid_string");
test_finalize();
exit(1);
} else {
fprintf(test_out, "(%d) strings: cellid - %s\n", i, tmp);
}
free(tmp);
/* get and print its numeric values */
if (ORTE_SUCCESS != (rc = ns_module->get_vpid(&vpid, test_name))) {
fprintf(test_out, "test_ns_replica: failed to get vpid with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica: failed to get vpid");
test_finalize();
exit(1);
}
if (ORTE_SUCCESS != (rc = ns_module->get_jobid(&job, test_name))) {
fprintf(test_out, "test_ns_replica: failed to get jobid with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica: failed to get jobid");
test_finalize();
exit(1);
}
if (ORTE_SUCCESS != (rc = ns_module->get_cellid(&cell, test_name))) {
fprintf(test_out, "test_ns_replica: failed to get cellid with error %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_ns_replica: failed to get cellid");
test_finalize();
exit(1);
}
fprintf(test_out, "(%d) ints cell %lu job %lu vpid %lu\n\n",
i, (unsigned long) cell, (unsigned long) job,
(unsigned long) vpid);
free(test_name);
}
}
/* finalize and see if memory cleared */
if (NULL != ns_component->ns_finalize) {
ns_component->ns_finalize();
}
test_component_close(&ns_handle);
orte_proc_info_finalize();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
fclose( test_out );
test_finalize();
return(0);
}

Просмотреть файл

@ -1,366 +0,0 @@
MCA started
NS opened
NS started
got process name: 0 1 1
got process name: 1234(4660) 5678(22136) 9AEF(39663)
cellid created: 1
jobid created: 1
range reserved: 1
(0) strings: name - 0.1.1
vpid: 1
jobid: 1
cellid: 0
(0) ints cell 0(0) job 1(1) vpid 1(1)
range reserved: 251
(0) strings: name - 0.1.FB
vpid: FB
jobid: 1
cellid: 0
(0) ints cell 0(0) job 1(1) vpid fb(251)
range reserved: 501
(0) strings: name - 0.1.1F5
vpid: 1F5
jobid: 1
cellid: 0
(0) ints cell 0(0) job 1(1) vpid 1f5(501)
range reserved: 751
(0) strings: name - 0.1.2EF
vpid: 2EF
jobid: 1
cellid: 0
(0) ints cell 0(0) job 1(1) vpid 2ef(751)
range reserved: 1001
(0) strings: name - 0.1.3E9
vpid: 3E9
jobid: 1
cellid: 0
(0) ints cell 0(0) job 1(1) vpid 3e9(1001)
jobid created: 2
range reserved: 1
(1) strings: name - 1.2.1
vpid: 1
jobid: 2
cellid: 1
(1) ints cell 1(1) job 2(2) vpid 1(1)
range reserved: 251
(1) strings: name - 1.2.FB
vpid: FB
jobid: 2
cellid: 1
(1) ints cell 1(1) job 2(2) vpid fb(251)
range reserved: 501
(1) strings: name - 1.2.1F5
vpid: 1F5
jobid: 2
cellid: 1
(1) ints cell 1(1) job 2(2) vpid 1f5(501)
range reserved: 751
(1) strings: name - 1.2.2EF
vpid: 2EF
jobid: 2
cellid: 1
(1) ints cell 1(1) job 2(2) vpid 2ef(751)
range reserved: 1001
(1) strings: name - 1.2.3E9
vpid: 3E9
jobid: 2
cellid: 1
(1) ints cell 1(1) job 2(2) vpid 3e9(1001)
jobid created: 3
range reserved: 1
(2) strings: name - 2.3.1
vpid: 1
jobid: 3
cellid: 2
(2) ints cell 2(2) job 3(3) vpid 1(1)
range reserved: 251
(2) strings: name - 2.3.FB
vpid: FB
jobid: 3
cellid: 2
(2) ints cell 2(2) job 3(3) vpid fb(251)
range reserved: 501
(2) strings: name - 2.3.1F5
vpid: 1F5
jobid: 3
cellid: 2
(2) ints cell 2(2) job 3(3) vpid 1f5(501)
range reserved: 751
(2) strings: name - 2.3.2EF
vpid: 2EF
jobid: 3
cellid: 2
(2) ints cell 2(2) job 3(3) vpid 2ef(751)
range reserved: 1001
(2) strings: name - 2.3.3E9
vpid: 3E9
jobid: 3
cellid: 2
(2) ints cell 2(2) job 3(3) vpid 3e9(1001)
jobid created: 4
range reserved: 1
(3) strings: name - 3.4.1
vpid: 1
jobid: 4
cellid: 3
(3) ints cell 3(3) job 4(4) vpid 1(1)
range reserved: 251
(3) strings: name - 3.4.FB
vpid: FB
jobid: 4
cellid: 3
(3) ints cell 3(3) job 4(4) vpid fb(251)
range reserved: 501
(3) strings: name - 3.4.1F5
vpid: 1F5
jobid: 4
cellid: 3
(3) ints cell 3(3) job 4(4) vpid 1f5(501)
range reserved: 751
(3) strings: name - 3.4.2EF
vpid: 2EF
jobid: 4
cellid: 3
(3) ints cell 3(3) job 4(4) vpid 2ef(751)
range reserved: 1001
(3) strings: name - 3.4.3E9
vpid: 3E9
jobid: 4
cellid: 3
(3) ints cell 3(3) job 4(4) vpid 3e9(1001)
jobid created: 5
range reserved: 1
(4) strings: name - 4.5.1
vpid: 1
jobid: 5
cellid: 4
(4) ints cell 4(4) job 5(5) vpid 1(1)
range reserved: 251
(4) strings: name - 4.5.FB
vpid: FB
jobid: 5
cellid: 4
(4) ints cell 4(4) job 5(5) vpid fb(251)
range reserved: 501
(4) strings: name - 4.5.1F5
vpid: 1F5
jobid: 5
cellid: 4
(4) ints cell 4(4) job 5(5) vpid 1f5(501)
range reserved: 751
(4) strings: name - 4.5.2EF
vpid: 2EF
jobid: 5
cellid: 4
(4) ints cell 4(4) job 5(5) vpid 2ef(751)
range reserved: 1001
(4) strings: name - 4.5.3E9
vpid: 3E9
jobid: 5
cellid: 4
(4) ints cell 4(4) job 5(5) vpid 3e9(1001)
jobid created: 6
range reserved: 1
(5) strings: name - 5.6.1
vpid: 1
jobid: 6
cellid: 5
(5) ints cell 5(5) job 6(6) vpid 1(1)
range reserved: 251
(5) strings: name - 5.6.FB
vpid: FB
jobid: 6
cellid: 5
(5) ints cell 5(5) job 6(6) vpid fb(251)
range reserved: 501
(5) strings: name - 5.6.1F5
vpid: 1F5
jobid: 6
cellid: 5
(5) ints cell 5(5) job 6(6) vpid 1f5(501)
range reserved: 751
(5) strings: name - 5.6.2EF
vpid: 2EF
jobid: 6
cellid: 5
(5) ints cell 5(5) job 6(6) vpid 2ef(751)
range reserved: 1001
(5) strings: name - 5.6.3E9
vpid: 3E9
jobid: 6
cellid: 5
(5) ints cell 5(5) job 6(6) vpid 3e9(1001)
jobid created: 7
range reserved: 1
(6) strings: name - 6.7.1
vpid: 1
jobid: 7
cellid: 6
(6) ints cell 6(6) job 7(7) vpid 1(1)
range reserved: 251
(6) strings: name - 6.7.FB
vpid: FB
jobid: 7
cellid: 6
(6) ints cell 6(6) job 7(7) vpid fb(251)
range reserved: 501
(6) strings: name - 6.7.1F5
vpid: 1F5
jobid: 7
cellid: 6
(6) ints cell 6(6) job 7(7) vpid 1f5(501)
range reserved: 751
(6) strings: name - 6.7.2EF
vpid: 2EF
jobid: 7
cellid: 6
(6) ints cell 6(6) job 7(7) vpid 2ef(751)
range reserved: 1001
(6) strings: name - 6.7.3E9
vpid: 3E9
jobid: 7
cellid: 6
(6) ints cell 6(6) job 7(7) vpid 3e9(1001)
jobid created: 8
range reserved: 1
(7) strings: name - 7.8.1
vpid: 1
jobid: 8
cellid: 7
(7) ints cell 7(7) job 8(8) vpid 1(1)
range reserved: 251
(7) strings: name - 7.8.FB
vpid: FB
jobid: 8
cellid: 7
(7) ints cell 7(7) job 8(8) vpid fb(251)
range reserved: 501
(7) strings: name - 7.8.1F5
vpid: 1F5
jobid: 8
cellid: 7
(7) ints cell 7(7) job 8(8) vpid 1f5(501)
range reserved: 751
(7) strings: name - 7.8.2EF
vpid: 2EF
jobid: 8
cellid: 7
(7) ints cell 7(7) job 8(8) vpid 2ef(751)
range reserved: 1001
(7) strings: name - 7.8.3E9
vpid: 3E9
jobid: 8
cellid: 7
(7) ints cell 7(7) job 8(8) vpid 3e9(1001)
jobid created: 9
range reserved: 1
(8) strings: name - 8.9.1
vpid: 1
jobid: 9
cellid: 8
(8) ints cell 8(8) job 9(9) vpid 1(1)
range reserved: 251
(8) strings: name - 8.9.FB
vpid: FB
jobid: 9
cellid: 8
(8) ints cell 8(8) job 9(9) vpid fb(251)
range reserved: 501
(8) strings: name - 8.9.1F5
vpid: 1F5
jobid: 9
cellid: 8
(8) ints cell 8(8) job 9(9) vpid 1f5(501)
range reserved: 751
(8) strings: name - 8.9.2EF
vpid: 2EF
jobid: 9
cellid: 8
(8) ints cell 8(8) job 9(9) vpid 2ef(751)
range reserved: 1001
(8) strings: name - 8.9.3E9
vpid: 3E9
jobid: 9
cellid: 8
(8) ints cell 8(8) job 9(9) vpid 3e9(1001)
jobid created: 10
range reserved: 1
(9) strings: name - 9.A.1
vpid: 1
jobid: A
cellid: 9
(9) ints cell 9(9) job A(10) vpid 1(1)
range reserved: 251
(9) strings: name - 9.A.FB
vpid: FB
jobid: A
cellid: 9
(9) ints cell 9(9) job A(10) vpid fb(251)
range reserved: 501
(9) strings: name - 9.A.1F5
vpid: 1F5
jobid: A
cellid: 9
(9) ints cell 9(9) job A(10) vpid 1f5(501)
range reserved: 751
(9) strings: name - 9.A.2EF
vpid: 2EF
jobid: A
cellid: 9
(9) ints cell 9(9) job A(10) vpid 2ef(751)
range reserved: 1001
(9) strings: name - 9.A.3E9
vpid: 3E9
jobid: A
cellid: 9
(9) ints cell 9(9) job A(10) vpid 3e9(1001)

Просмотреть файл

@ -1,50 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
AM_CPPFLAGS="-I$(top_srcdir)/test/support"
check_PROGRAMS = \
oob_test \
oob_test_self \
oob_test_packed
TESTS = \
$(check_PROGRAMS)
oob_test_SOURCES = oob_test.c
oob_test_LDADD = \
$(top_builddir)/test/support/libsupport.a \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
oob_test_DEPENDENCIES = $(oob_test_LDADD)
oob_test_self_SOURCES = oob_test_self.c
oob_test_self_LDADD = \
$(top_builddir)/test/support/libsupport.a \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
oob_test_self_DEPENDENCIES = $(oob_test_LDADD)
oob_test_packed_SOURCES = oob_test_packed.c
oob_test_packed_LDADD = \
$(top_builddir)/test/support/libsupport.a \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
oob_test_packed_DEPENDENCIES = $(oob_test_LDADD)

Просмотреть файл

@ -1,270 +0,0 @@
/*
* Basic test for the oob.
* The idea is to try most combinations of sending and recieving
* to run:
* mpirun -np 2 -- oob_test
*/
#include "ompi_config.h"
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "mpi.h"
#include "support.h"
#include "orte/mca/oob/oob.h"
int main(int argc, char **argv)
{
printf("Test oob_test disabled. Does not compile.\n");
return 77;
}
#if 0
#define MSG_TYPE_1 1
#define MSG_TYPE_2 2
#define NUM_TESTS 8
#define NUM_TIMES 1
int i;
int testdone = 0;
void do_sends(ompi_process_name_t * peer);
void do_recvs(ompi_process_name_t * peer);
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2, int n);
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2,
int n) {
int i;
for(i = 0; i < n; i++) {
if(msg1[i].iov_len != msg2[i].iov_len) {
return false;
}
if(0 != memcmp(msg1[i].iov_base, msg2[i].iov_base, msg1[i].iov_len)) {
return false;
}
}
return true;
}
void callback(int status, ompi_process_name_t * peer,
struct iovec * msg, int count, int tag, void * cbdata);
void callback(int status, ompi_process_name_t * peer,
struct iovec * msg, int count, int tag, void * cbdata)
{
if(0 != tag) {
test_failure("Bad tag.");
}
testdone++;
}
/* data */
/* setup message */
uint32_t msg_type_1 = MSG_TYPE_1;
uint32_t msg_type_2 = MSG_TYPE_2;
char send1[] = "hello";
uint32_t send2[] = {3, 5, 5, 9, 20};
uint16_t send3[] = {32, 4, 23};
/* now we set up the send iovect */
struct iovec send_msg1[4] = {{(void *) &msg_type_1, sizeof(msg_type_1)},
{(void *) &send1, sizeof(send1)},
{(void *) &send2, sizeof(send2)},
{(void *) &send3, sizeof(send3)}};
struct iovec send_msg2[3] = {{(void *) &msg_type_2, sizeof(msg_type_2)},
{(void *) &send2, sizeof(send2)},
{(void *) &send3, sizeof(send3)}};
/* we'll pass the array an identical iovec */
uint32_t msg_type;
char recv1[6];
uint32_t recv2[5];
uint16_t recv3[3];
struct iovec recv_msg1[4] = {{(void *) &msg_type, sizeof(msg_type)},
{(void *) &recv1, sizeof(recv1)},
{(void *) &recv2, sizeof(recv2)},
{(void *) &recv3, sizeof(recv3)}};
struct iovec recv_msg2[3] = {{(void *) &msg_type, sizeof(msg_type)},
{(void *) &recv2, sizeof(recv2)},
{(void *) &recv3, sizeof(recv3)}};
int main(int argc, char ** argv)
{
ompi_process_name_t peer;
bool all_complete = false;
int n;
MPI_Init(&argc, &argv);
/* setup peer address */
peer = mca_oob_name_self;
fprintf(stderr, "my vpid %d my jobid %d my cellid %d my pid %d\n",
peer.vpid, peer.jobid, peer.cellid, getpid());
if(peer.vpid == 1) {
test_init("oob send then receive");
/* local vpid is 1 - peer is 0 */
peer.vpid = 0;
for(i = 0; i < NUM_TIMES; i++) {
do_sends(&peer);
do_recvs(&peer);
}
} else {
test_init("oob receive then send");
/* local vpid is 0 - peer is 1 */
peer.vpid = 1;
for(i = 0; i < NUM_TIMES; i++) {
do_recvs(&peer);
do_sends(&peer);
}
}
/* now we want to make sure all the tests have completed */
/* done */
n = 0;
while(!all_complete && n < 10) {
if(testdone == NUM_TIMES*4) {
all_complete = true;
}
if(!all_complete) {
sleep(1);
}
n++;
}
if(!all_complete) {
test_failure("not all sends or receives were completed");
fprintf(stderr, "%d != %d\n", testdone, NUM_TIMES);
}
test_finalize();
/* this is to give the oob time to finish all sends */
MPI_Finalize();
return 0;
}
void do_sends(ompi_process_name_t * peer) {
/* non blocking send without doing any packing */
if( 0 > mca_oob_send_nb(peer, send_msg1, 4, 0, 0, &callback, (void *) (0 + (NUM_TESTS * i)))) {
test_failure("mca_oob_send_nb.");
} else {
test_success();
}
if( 0 > mca_oob_send_nb(peer, send_msg1, 4, 0, 0, &callback,
(void *) (1 + (NUM_TESTS * i)))) {
test_failure("mca_oob_send_nb.");
} else {
test_success();
}
/* blocking send */
if( 0 > mca_oob_send(peer, send_msg2, 3, 0, 0)) {
test_failure("mca_oob_send.");
} else {
test_success();
}
if( 0 > mca_oob_send(peer, send_msg2, 3, 0, 0)) {
test_failure("mca_oob_send.");
} else {
test_success();
}
if( 0 > mca_oob_send(peer, send_msg2, 3, 0, 0)) {
test_failure("mca_oob_send.");
} else {
test_success();
}
}
void do_recvs(ompi_process_name_t * peer) {
struct iovec iov[1];
int index;
unsigned char* ptr;
/* first, we'll receive the nonpacked send - assuming we know the
* message type */
if( 0 > mca_oob_recv_nb(peer, recv_msg1, 4, 0, 0, &callback,
(void *) (4 + (NUM_TESTS * i)))) {
test_failure("mca_oob_recv_nb.");
} else {
test_success();
}
if( 0 > mca_oob_recv(peer, recv_msg1, 4, 0, 0)) {
test_failure("mca_oob_recv.");
} else {
test_success();
}
if(!compare_iovec(recv_msg1, send_msg1, 4)) {
test_failure("compare 1 is wrong");
}
/* now we'll do a blocking recv - waiting for the 3rd message to arrive
* - and peek the first element of the iovec array to determine
* the message type. */
if( 0 > mca_oob_recv(peer, recv_msg2, 1, 0, MCA_OOB_PEEK)) {
test_failure("mca_oob_recv w/peek.");
} else {
test_success();
}
/* check the type of message - before doing the actual receive */
switch(msg_type) {
case MSG_TYPE_1:
if( 0 > mca_oob_recv(peer, recv_msg1, 4, 0, 0)) {
test_failure("mca_oob_recv of peeked message.");
} else {
test_success();
}
if(!compare_iovec(recv_msg1, send_msg1, 4)) {
test_failure("compare 3 is wrong");
}
break;
case MSG_TYPE_2:
if( 0 > mca_oob_recv(peer, recv_msg2, 3, 0, 0)) {
test_failure("mca_oob_recv of peeked message.");
} else {
test_success();
}
if(!compare_iovec(recv_msg2, send_msg2, 3)) {
test_failure("compare 4 is wrong");
}
break;
default:
test_failure("Message peek did not return a valid type number.");
break;
}
/* now we'll do a blocking recv - and have the buffer allocated and returned */
if( 0 > mca_oob_recv(peer, iov, 1, NULL, MCA_OOB_ALLOC)) {
test_failure("mca_oob_recv(MCA_OOB_ALLOC)");
} else {
test_success();
}
/* validate the data received with an allocated buffer */
ptr = iov->iov_base;
for(index=0; index < (sizeof(send_msg2) / sizeof(struct iovec)); index++) {
struct iovec *iov = &send_msg2[index];
if(memcmp(iov->iov_base, ptr, iov->iov_len) != 0) {
test_failure("mca_oob_recv(MCA_OOB_ALLOC)");
} else {
test_success();
}
ptr += iov->iov_len;
}
if( 0 > mca_oob_recv_nb(peer, recv_msg2, 3, 0, 0, &callback, 0)) {
test_failure("mca_oob_recv_nb.");
} else {
test_success();
}
/* validate the data */
}
#endif

Просмотреть файл

@ -1,209 +0,0 @@
/*
* Basic test for the oob when sending packed buffers.
* The idea is to try most combinations of sending and recieving
* to run:
* mpirun -np 2 -- oob_test
*/
#include "ompi_config.h"
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "mpi.h"
#include "support.h"
#include "orte/mca/oob/oob.h"
int main(int argc, char **argv)
{
printf("Test oob_test disabled. Does not compile.\n");
return 77;
}
#if 0
#define TAG 11011
int i;
void do_sends(ompi_process_name_t * peer);
void do_recvs(ompi_process_name_t * peer);
void do_compare ();
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2, int n);
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2,
int n) {
int i;
for(i = 0; i < n; i++) {
if(msg1[i].iov_len != msg2[i].iov_len) {
return false;
}
if(0 != memcmp(msg1[i].iov_base, msg2[i].iov_base, msg1[i].iov_len)) {
return false;
}
}
return true;
}
/* */
/* void callback(int status, const ompi_process_name_t * peer, */
/* const struct iovec * msg, int count, int tag, void * cbdata); */
/* */
/* void callback(int status, const ompi_process_name_t * peer, */
/* const struct iovec * msg, int count, int tag, void * cbdata) */
/* { */
/* if(0 != tag) { */
/* test_failure("Bad tag."); */
/* } */
/* if(((int) cbdata) >= NUM_TESTS * NUM_TIMES) { */
/* test_failure("Bad value in callback function."); */
/* } else if (testdone[(int) cbdata]) { */
/* test_failure("Callback function called on an already completed test."); */
/* } else { */
/* testdone[(int) cbdata] = true; */
/* test_success(); */
/* } */
/* } */
/* data */
/* setup message */
char data0[] = "hello";
uint32_t data1[] = {1};
uint16_t data2[] = {32};
char data3[] = "world";
uint16_t data4[] = {1, 2, 3, 4, 5};
uint32_t data5[] = {101, 102, 103};
int datalens[] = {6, 1, 1, 6, 5, 3};
/* recv data minibuffers */
char rdata0[128];
uint32_t rdata1[128];
uint16_t rdata2[128];
char rdata3[128];
uint16_t rdata4[128];
uint32_t rdata5[128];
int main(int argc, char ** argv)
{
ompi_process_name_t me;
ompi_process_name_t them;
MPI_Init(&argc, &argv);
/* setup peer address */
me = mca_oob_name_self;
fprintf(stderr, "my vpid %d my jobid %d my cellid %d my pid %d\n",
me.vpid, me.jobid, me.cellid, getpid());
if(me.vpid == 1) {
test_init("oob packed send then recieve");
/* local vpid is 1 - peer is 0 */
them = me;
them.vpid = 0;
do_sends(&them);
do_recvs(&them);
do_compare();
} else {
test_init("oob packed recieve then send");
/* local vpid is 0 - peer is 1 */
them = me;
them.vpid = 1;
do_recvs(&them);
do_compare();
do_sends(&them);
}
test_finalize();
/* this is to give the oob time to finish all sends */
MPI_Finalize();
return 0;
}
void do_sends(ompi_process_name_t * peer) {
/* non blocking send without doing any packing */
/* if( 0 > mca_oob_send_nb(peer, send_msg1, 4, 0, 0, &callback, */
/* (void *) (0 + (NUM_TESTS * i)))) { */
/* test_failure("mca_oob_send_nb."); */
/* } else { */
/* test_success(); */
/* } */
/* if( 0 > mca_oob_send_nb(peer, send_msg1, 4, 0, 0, &callback, */
/* (void *) (1 + (NUM_TESTS * i)))) { */
/* test_failure("mca_oob_send_nb."); */
/* } else { */
/* test_success(); */
/* } */
ompi_buffer_t sendbuf;
ompi_buffer_init (&sendbuf,0);
/* pack complex data buffer */
ompi_pack (sendbuf, data0, datalens[0], OMPI_STRING);
ompi_pack (sendbuf, data1, datalens[1], OMPI_INT32);
ompi_pack (sendbuf, data2, datalens[2], OMPI_INT16);
ompi_pack (sendbuf, data3, datalens[3], OMPI_STRING);
ompi_pack (sendbuf, data4, datalens[4], OMPI_INT16);
ompi_pack (sendbuf, data5, datalens[5], OMPI_INT32);
/* blocking packed send */
if( 0 > mca_oob_send_packed(peer, sendbuf, TAG, 0)) {
test_failure("mca_oob_send_packed.");
return;
}
ompi_buffer_free (sendbuf); /* can only free send buffer as a blocking send */
test_success();
}
void do_recvs(ompi_process_name_t * peer) {
/*first, we'll recieve the nonpacked send - assuming we know the
* message type */
/* if( 0 > mca_oob_recv_nb(peer, recv_msg1, 4, 0, 0, &callback, */
/* (void *) (4 + (NUM_TESTS * i)))) { */
/* test_failure("mca_oob_recv_nb."); */
/* } else { */
/* test_success(); */
/* } */
ompi_buffer_t recvbuf;
int tag = TAG;
if( 0 > mca_oob_recv_packed (peer, &recvbuf, &tag)) {
test_failure("mca_oob_recv_packed.");
return;
}
ompi_unpack (recvbuf, rdata0, datalens[0], OMPI_STRING);
ompi_unpack (recvbuf, rdata1, datalens[1], OMPI_INT32);
ompi_unpack (recvbuf, rdata2, datalens[2], OMPI_INT16);
ompi_unpack (recvbuf, rdata3, datalens[3], OMPI_STRING);
ompi_unpack (recvbuf, rdata4, datalens[4], OMPI_INT16);
ompi_unpack (recvbuf, rdata5, datalens[5], OMPI_INT32);
ompi_buffer_free (recvbuf);
test_success();
}
void do_compare () {
int rc=0;
int i;
rc = test_verify_str(data0, rdata0);
for(i=0;i<datalens[1];i++) rc = test_verify_int(data1[i], rdata1[i]);
for(i=0;i<datalens[2];i++) rc = test_verify_int(data2[i], rdata2[i]);
rc = test_verify_str(data3, rdata3);
for(i=0;i<datalens[4];i++) rc = test_verify_int(data4[i], rdata4[i]);
for(i=0;i<datalens[5];i++) rc = test_verify_int(data5[i], rdata5[i]);
test_success();
}
#endif

Просмотреть файл

@ -1,173 +0,0 @@
/**
* In this test we try using oob to send messages to the same process.
* to run: mpirun -np 1 -- oob_test_self
*/
#include "ompi_config.h"
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "mpi.h"
#include "support.h"
#include "orte/mca/oob/oob.h"
int main(int argc, char **argv)
{
printf("Test oob_test disabled. Does not compile.\n");
return 77;
}
#if 0
#define MSG_TYPE_1 1
#define MSG_TYPE_2 2
#define NUM_TESTS 5
/* setup message */
uint32_t msg_type_1 = MSG_TYPE_1;
uint32_t msg_type_2 = MSG_TYPE_2;
char send1[] = "hello";
uint32_t send2[] = {3, 5, 5, 9, 20};
uint16_t send3[] = {32, 4, 23};
/* now we set up the send iovect */
struct iovec send_msg1[4] = {{(void *) &msg_type_1, sizeof(msg_type_1)},
{(void *) &send1, sizeof(send1)},
{(void *) &send2, sizeof(send2)},
{(void *) &send3, sizeof(send3)}};
struct iovec send_msg2[3] = {{(void *) &msg_type_2, sizeof(msg_type_2)},
{(void *) &send2, sizeof(send2)},
{(void *) &send3, sizeof(send3)}};
/* if we want the send/ recieve functions to do the packing for us,
* we have to provide an array that describes our data types
*/
/* mca_oob_base_type_t types[] = {MCA_OOB_BASE_INT32, MCA_OOB_BASE_BYTE, */
/* MCA_OOB_BASE_INT32, MCA_OOB_BASE_INT16}; */
/* we'll pass the array an identical iovec */
uint32_t msg_type;
char recv1[6];
uint32_t recv2[5];
uint16_t recv3[3];
struct iovec recv_msg1[4] = {{(void *) &msg_type, sizeof(msg_type)},
{(void *) &recv1, sizeof(recv1)},
{(void *) &recv2, sizeof(recv2)},
{(void *) &recv3, sizeof(recv3)}};
struct iovec recv_msg2[3] = {{(void *) &msg_type, sizeof(msg_type)},
{(void *) &recv2, sizeof(recv2)},
{(void *) &recv3, sizeof(recv3)}};
bool testdone[NUM_TESTS];
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2, int n);
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2,
int n) {
int i;
for(i = 0; i < n; i++) {
if(msg1[i].iov_len != msg2[i].iov_len) {
return false;
}
if(0 != memcmp(msg1[i].iov_base, msg2[i].iov_base, msg1[i].iov_len)) {
return false;
}
}
return true;
}
void callback(int status, ompi_process_name_t * peer,
struct iovec * msg, int count, int tag, void * cbdata);
void callback(int status, ompi_process_name_t * peer,
struct iovec * msg, int count, int tag, void * cbdata)
{
if(0 != tag) {
test_failure("Bad tag.");
}
if((int) cbdata >= NUM_TESTS) {
test_failure("Bad value in callback function.");
} else if (testdone[(int) cbdata]) {
test_failure("Callback function called on an already completed test.");
} else {
testdone[(int) cbdata] = true;
test_success();
}
}
int main(int argc, char ** argv)
{
ompi_process_name_t peer;
MPI_Init(&argc, &argv);
/* setup peer address */
peer = mca_oob_name_self;
fprintf(stderr, "my vpid %d my jobid %d my cellid %d my pid %d\n",
peer.vpid, peer.jobid, peer.cellid, getpid());
test_init("oob self");
/* do a non blocking send without packing followed by a
* non blocking recieve */
if( 0 > mca_oob_send_nb(&peer, send_msg1, 4, 0, 0, &callback, (void *) 0)){
test_failure("mca_oob_send_nb.");
} else {
test_success();
}
if( 0 > mca_oob_recv_nb(&peer, recv_msg1, 4, 0, 0, &callback, (void *) 2)) {
test_failure("mca_oob_recv_nb.");
} else {
test_success();
}
/* non blocking send of message type 2 followed by blocking recieve*/
if( 0 > mca_oob_send_nb(&peer, send_msg2, 3, 0, 0, &callback,
(void *) 4)) {
test_failure("mca_oob_send.");
} else {
test_success();
}
/* check the type of message - before doing the actual receive */
if( 0 > mca_oob_recv(&peer, recv_msg1, 1, 0, MCA_OOB_PEEK)) {
test_failure("mca_oob_recv w/peek.");
} else {
test_success();
}
switch(msg_type) {
case MSG_TYPE_1:
if( 0 > mca_oob_recv(&peer, recv_msg1, 4, 0, 0)) {
test_failure("mca_oob_recv_nb of peeked message.");
} else {
test_success();
}
if(!compare_iovec(recv_msg1, send_msg1, 4)) {
test_failure("compare 2 is wrong");
}
break;
case MSG_TYPE_2:
if( 0 > mca_oob_recv(&peer, recv_msg2, 3, 0, 0)) {
test_failure("mca_oob_recv_nb of peeked message.");
} else {
test_success();
}
if(!compare_iovec(recv_msg2, send_msg2, 3)) {
test_failure("compare 3 is wrong");
}
break;
default:
test_failure("Message peek did not return a valid type number.");
break;
}
test_finalize();
MPI_Finalize();
return 0;
}
#endif

Просмотреть файл

@ -1,33 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
check_PROGRAMS = \
test_ras
TESTS = \
$(check_PROGRAMS)
test_ras_SOURCES = test_ras.c
test_ras_LDADD = \
$(top_builddir)/test/support/libsupport.a \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
test_ras_DEPENDENCIES = $(test_ras_LDADD)

Просмотреть файл

@ -1,179 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "components.h"
#include "orte/orte_constants.h"
#include "dps/dps.h"
#include "runtime/runtime.h"
#include "util/proc_info.h"
#include "util/sys_info.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/ras/base/base.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std";
int
main(int argc, char **argv)
{
int rc;
bool allow, have;
int priority;
test_component_handle_t gpr_handle;
mca_gpr_base_component_t *gpr_component = NULL;
orte_gpr_base_module_t *gpr_module = NULL;
test_component_handle_t ras_handle;
orte_ras_base_component_t *ras_component = NULL;
orte_ras_base_module_t *ras_module = NULL;
test_init("test_ras_fn");
if (getenv("TEST_WRITE_TO_FILE") != NULL) {
test_out = fopen( "test_ras_fn", "w+" );
} else {
test_out = stderr;
}
if( test_out == NULL ) {
test_failure("ras_fn couldn't open test file failed");
test_finalize();
exit(1);
}
/* ENSURE THE GPR REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* Open up the output streams */
if (!opal_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads -
* and reset otherwise.
*/
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
opal_malloc_init();
/* Ensure the system_info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_sys_info())) {
return rc;
}
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start\n");
exit (1);
}
/* Open the gpr replica component and initialize a module */
if (OMPI_SUCCESS !=
test_component_open("gpr", "replica", &gpr_handle,
(mca_base_component_t**) &gpr_component) ||
NULL == gpr_component) {
test_fail_stop("Could not open GPR replica\n", 1);
}
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (NULL == gpr_module) {
test_fail_stop("GPR replica component did not return a module\n", 1);
}
fprintf(test_out, "GPR replica started\n");
/* dps */
if (ORTE_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else {
fprintf(test_out, "DPS could not start\n");
exit (1);
}
/* setup the ras */
if (OMPI_SUCCESS !=
test_component_open("ras", "host", &ras_handle,
(mca_base_component_t**) &ras_component) ||
NULL == ras_component) {
test_fail_stop("Could not open ras host component\n", 1);
}
ras_module = ras_component->ras_init(&priority);
if (NULL == ras_module) {
test_fail_stop("ras host component did not return a module\n", 1);
}
fprintf(test_out, "RAS host component started\n");
fprintf(stderr, "now finalize and see if all memory cleared\n");
if (NULL != ras_module->finalize) {
ras_module->finalize();
}
test_component_close(&ras_handle);
orte_dps_close();
if (NULL != gpr_component->gpr_finalize) {
gpr_component->gpr_finalize();
}
test_component_close(&gpr_handle);
orte_sys_info_finalize();
orte_proc_info_finalize();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
fclose( test_out );
/* result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_ras failed");
}
*/
test_finalize();
exit (0);
}

Просмотреть файл

@ -1,41 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
check_PROGRAMS = \
test_rds
TESTS = \
$(check_PROGRAMS)
test_rds_SOURCES = test_rds.c
test_rds_LDADD = \
$(top_builddir)/test/support/libsupport.a \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
test_rds_DEPENDENCIES = $(test_rds_LDADD)
# JMS Temporarily commented out -- this test only checks the selection
# logic, which is not [yet] well supported by the unit test infrastructure
#test_rds2_SOURCES = test_rds2.c
#test_rds2_LDADD = \
# $(top_builddir)/test/support/libsupport.a \
# $(top_builddir)/src/libmpi.la
#test_rds2_DEPENDENCIES = $(test_rds2_LDADD)

Просмотреть файл

@ -1,219 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "components.h"
#include "orte/orte_constants.h"
#include "dps/dps.h"
#include "runtime/runtime.h"
#include "util/proc_info.h"
#include "util/sys_info.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/ns/base/base.h"
#include "orte/mca/rds/base/base.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std";
int
main(int argc, char **argv)
{
int rc;
bool allow, have;
int priority;
test_component_handle_t gpr_handle, ns_handle;
mca_gpr_base_component_t *gpr_component = NULL;
orte_gpr_base_module_t *gpr_module = NULL;
mca_ns_base_component_t *ns_component = NULL;
mca_ns_base_module_t *ns_module = NULL;
test_component_handle_t rds_handle;
orte_rds_base_component_t *rds_component = NULL;
orte_rds_base_module_t *rds_module = NULL;
test_init("test_rds_fn");
if (getenv("TEST_WRITE_TO_FILE") != NULL) {
test_out = fopen( "test_rds_fn", "w+" );
} else {
test_out = stderr;
}
if( test_out == NULL ) {
test_failure("rds_fn couldn't open test file failed");
test_finalize();
exit(1);
}
/* ENSURE THE GPR REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* ensure the NS replica is isolated */
setenv("OMPI_MCA_ns_replica_isolate", "1", 1);
/* Open up the output streams */
if (!opal_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads -
* and reset otherwise.
*/
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
opal_malloc_init();
/* Ensure the system_info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_sys_info())) {
return rc;
}
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start\n");
exit (1);
}
/* Open the ns replica component and initialize a module */
if (OMPI_SUCCESS !=
test_component_open("ns", "replica", &ns_handle,
(mca_base_component_t**) &ns_component) ||
NULL == ns_component) {
test_fail_stop("Could not open ns replica\n", 1);
}
ns_module = ns_component->ns_init(&priority);
if (NULL == ns_module) {
test_fail_stop("NS replica component did not return a module\n", 1);
}
/* Open the gpr replica component and initialize a module */
if (OMPI_SUCCESS !=
test_component_open("gpr", "replica", &gpr_handle,
(mca_base_component_t**) &gpr_component) ||
NULL == gpr_component) {
test_fail_stop("Could not open GPR replica\n", 1);
}
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (NULL == gpr_module) {
test_fail_stop("GPR replica did not return a component\n", 1);
}
fprintf(test_out, "GPR replica started\n");
if (ORTE_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else {
test_fail_stop("DPS could not start\n", 1);
}
/* setup the RDS */
if (OMPI_SUCCESS !=
test_component_open("rds", "hostfile", &rds_handle,
(mca_base_component_t**) &rds_component) ||
NULL == rds_component) {
test_fail_stop("Could not open rds hostfile\n", 1);
}
rds_module = rds_component->rds_init();
if (NULL == rds_module) {
test_fail_stop("rds hostfile component did not return a module\n", 1);
}
// rds_module->query();
fprintf(test_out, "RDS hostfile component executed\n");
if (NULL != rds_module->finalize) {
rds_module->finalize();
}
test_component_close(&rds_handle);
fprintf(stderr, "test the resource file component\n");
if (OMPI_SUCCESS !=
test_component_open("rds", "resfile", &rds_handle,
(mca_base_component_t**) &rds_component) ||
NULL == rds_component) {
test_fail_stop("Could not open rds resource file component\n", 1);
}
rds_module = rds_component->rds_init();
if (NULL == rds_module) {
test_fail_stop("rds resource file component did not return a module\n", 1);
}
rds_module->query();
fprintf(test_out, "RDS resource file component executed\n");
gpr_module->dump_segments(0);
if (NULL != rds_module->finalize) {
rds_module->finalize();
}
test_component_close(&rds_handle);
orte_dps_close();
if (NULL != gpr_component->gpr_finalize) {
gpr_component->gpr_finalize();
}
test_component_close(&gpr_handle);
orte_sys_info_finalize();
orte_proc_info_finalize();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
fclose( test_out );
/* result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_rds failed");
}
*/
test_finalize();
exit (0);
}

Просмотреть файл

@ -1,76 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "components.h"
#include "orte/orte_constants.h"
#include "runtime/runtime.h"
#include "orte/mca/gpr/gpr.h"
#include "orte/mca/rds/base/base.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std";
int
main(int argc, char **argv)
{
int rc;
test_init("test_rds_fn");
if (getenv("TEST_WRITE_TO_FILE") != NULL) {
test_out = fopen( "test_rds_fn", "w+" );
} else {
test_out = stderr;
}
if( test_out == NULL ) {
test_failure("rds_fn couldn't open test file failed");
test_finalize();
exit(1);
}
orte_init();
orte_rds_base_query();
orte_gpr.dump_segments(0);
orte_finalize();
fclose( test_out );
/* result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_rds failed");
}
*/
test_finalize();
exit (0);
}

Просмотреть файл

@ -1,33 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
check_PROGRAMS = \
test_rmaps
TESTS = \
$(check_PROGRAMS)
test_rmaps_SOURCES = test_rmaps.c
test_rmaps_LDADD = \
$(top_builddir)/test/support/libsupport.a \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
test_rmaps_DEPENDENCIES = $(test_rmaps_LDADD)

Просмотреть файл

@ -1,179 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "components.h"
#include "orte/orte_constants.h"
#include "dps/dps.h"
#include "runtime/runtime.h"
#include "util/proc_info.h"
#include "util/sys_info.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/mca/gpr/base/base.h"
#include "orte/mca/rmaps/base/base.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std";
int
main(int argc, char **argv)
{
int rc;
bool allow, have;
int priority;
test_component_handle_t gpr_handle;
mca_gpr_base_component_t *gpr_component = NULL;
orte_gpr_base_module_t *gpr_module = NULL;
test_component_handle_t rmaps_handle;
orte_rmaps_base_component_t *rmaps_component = NULL;
orte_rmaps_base_module_t *rmaps_module = NULL;
test_init("test_rmaps_fn");
if (getenv("TEST_WRITE_TO_FILE") != NULL) {
test_out = fopen( "test_rmaps_fn", "w+" );
} else {
test_out = stderr;
}
if( test_out == NULL ) {
test_failure("rmaps_fn couldn't open test file failed");
test_finalize();
exit(1);
}
/* ENSURE THE GPR REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* Open up the output streams */
if (!opal_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads -
* and reset otherwise.
*/
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
opal_malloc_init();
/* Ensure the system_info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_sys_info())) {
return rc;
}
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start\n");
exit (1);
}
/* Open the gpr replica component and initialize a module */
if (OMPI_SUCCESS !=
test_component_open("gpr", "replica", &gpr_handle,
(mca_base_component_t**) &gpr_component) ||
NULL == gpr_component) {
test_fail_stop("Could not open replica\n", 1);
}
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (NULL == gpr_module) {
test_fail_stop("replica component did not return a module\n", 1);
}
fprintf(test_out, "GPR replica started\n");
/* dps */
if (ORTE_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else {
fprintf(test_out, "DPS could not start\n");
exit (1);
}
/* setup the RMAPS */
if (OMPI_SUCCESS !=
test_component_open("rmaps", "round_robin", &rmaps_handle,
(mca_base_component_t**) &rmaps_component) ||
NULL == rmaps_component) {
test_fail_stop("Could not open rmaps round_robin component\n", 1);
}
rmaps_module = rmaps_component->rmaps_init(&priority);
if (NULL == rmaps_module) {
test_fail_stop("rmaps round_robin component did not return a module\n", 1);
}
fprintf(test_out, "RMAPS host component started\n");
fprintf(stderr, "now finalize and see if all memory cleared\n");
if (NULL != rmaps_module->finalize) {
rmaps_module->finalize();
}
test_component_close(&rmaps_handle);
orte_dps_close();
if (NULL != gpr_component->gpr_finalize) {
gpr_component->gpr_finalize();
}
test_component_close(&gpr_handle);
orte_sys_info_finalize();
orte_proc_info_finalize();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
fclose( test_out );
/* result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_rmaps failed");
}
*/
test_finalize();
exit (0);
}

Просмотреть файл

@ -1,68 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
AM_CPPFLAGS = -I$(top_srcdir)/test/support
check_PROGRAMS = \
rmgr_dt_buffer \
rmgr_dt_compare \
rmgr_dt_print \
rmgr_dt_size \
rmgr_dt_release \
rmgr_dt_copy
TESTS = \
$(check_PROGRAMS)
rmgr_dt_buffer_SOURCES = rmgr_dt_buffer.c
rmgr_dt_buffer_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
rmgr_dt_buffer_DEPENDENCIES = $(rmgr_dt_buffer_LDADD)
rmgr_dt_copy_SOURCES = rmgr_dt_copy.c
rmgr_dt_copy_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
rmgr_dt_copy_DEPENDENCIES = $(rmgr_dt_copy_LDADD)
rmgr_dt_compare_SOURCES = rmgr_dt_compare.c
rmgr_dt_compare_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
rmgr_dt_compare_DEPENDENCIES = $(rmgr_dt_compare_LDADD)
rmgr_dt_print_SOURCES = rmgr_dt_print.c
rmgr_dt_print_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
rmgr_dt_print_DEPENDENCIES = $(rmgr_dt_print_LDADD)
rmgr_dt_size_SOURCES = rmgr_dt_size.c
rmgr_dt_size_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
rmgr_dt_size_DEPENDENCIES = $(rmgr_dt_size_LDADD)
rmgr_dt_release_SOURCES = rmgr_dt_release.c
rmgr_dt_release_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
rmgr_dt_release_DEPENDENCIES = $(rmgr_dt_release_LDADD)

Просмотреть файл

@ -1,260 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The OpenRTE Resource Manager data type function unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/argv.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/rmgr/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_ac(void); /* includes app_context_map */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the rmgr to register data types */
if (ORTE_SUCCESS == orte_rmgr_base_open()) {
fprintf(stderr, "RMGR opened\n");
} else {
fprintf(stderr, "RMGR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_ac\n");
if (test_ac()) {
fprintf(stderr, "test_ac succeeded\n");
}
else {
fprintf(stderr, "test_ac failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_ac(void) /* buffer actions */
{
orte_buffer_t *bufA;
int rc, n, count;
size_t i, j, k;
orte_app_context_t *src[NUM_ELEMS];
orte_app_context_t *dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_app_context_t);
src[i]->idx = i;
src[i]->app = strdup("test-application-name");
src[i]->num_procs = i; /* test between 0 and NUM_ELEMS-1 proc counts */
/* test arg counts of 1 to NUM_ELEMS+1 */
count = i;
if (count) { /* if to allow testing of argv count of zero */
src[i]->argv = (char**)malloc((count+1) * sizeof(char*));
for (n=0; n < count-1; n++) {
src[i]->argv[n] = strdup("test-argv");
}
src[i]->argv[count] = NULL; /* be sure to null terminate the list */
}
/* test env counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of num_env count of zero */
src[i]->env = (char**)malloc((count+1) * sizeof(char*));
for (n=0; n < count-1; n++) {
src[i]->env[n] = strdup("test-env");
}
src[i]->env[count] = NULL; /* be sure to null terminate the list */
}
src[i]->cwd = strdup ("test-cwd");
/* test imap data for map count = num_procs */
src[i]->num_map = i+1;
if (src[i]->num_map) { /* if to allow testing of map count of zero */
src[i]->map_data = (orte_app_context_map_t**)malloc(src[i]->num_map * sizeof(orte_app_context_map_t *)); /* map data type */
for (j=0; j < src[i]->num_map; j++) {
src[i]->map_data[j] = OBJ_NEW(orte_app_context_map_t); /* assume we create with new rather than malloc? */
src[i]->map_data[j]->map_type = (uint8_t) j;
src[i]->map_data[j]->map_data = strdup("test-map-data");
}
}
}
/* source data set, now create buffer and pack source data */
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(stderr, "orte_buffer failed init in OBJ_NEW");
fprintf(stderr, "OBJ_NEW failed\n");
return false;
}
/* fprintf(stderr,"New buffer ready\n"); */
/* fflush(stderr); */
/* orte_dss_dump_buffer_simple (bufA, 0); */
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_APP_CONTEXT);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.pack failed");
fprintf(stderr, "orte_pack_value failed with return code %d\n", rc);
return(false);
}
/* fprintf(stderr,"Packed iter %d\n", i); */
/* fflush(stderr); */
/* orte_dss_dump_buffer_simple (bufA, 0); */
}
for (i=0; i<NUM_ITERS; i++) {
count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &j, ORTE_APP_CONTEXT);
if (ORTE_SUCCESS != rc || j != NUM_ELEMS) {
fprintf(stderr, "orte_dss.unpack failed");
fprintf(stderr, "orte_unpack_value failed with return code %d (count=%lu)\n", rc, (unsigned long) j);
return(false);
}
/* fprintf(stderr,"Unpacked iter %d\n", i); */
/* fflush(stderr); */
/* orte_dss_dump_buffer_simple (bufA, 0); */
for(j=0; j<NUM_ELEMS; j++) {
if (
src[j]->idx != dst[j]->idx ||
0 != strcmp(src[j]->app, dst[j]->app) ||
src[j]->num_procs != dst[j]->num_procs ||
0 != strcmp(src[j]->cwd, dst[j]->cwd) ||
src[j]->num_map != dst[j]->num_map
) {
fprintf(stderr, "test12: invalid results from unpack");
return(false);
}
/* now compare each of the size/cnt depedant values */
if (opal_argv_count(dst[j]->argv) != (count = opal_argv_count(src[j]->argv))) {
fprintf(stderr, "test12: invalid results (num argv) from unpack");
return(false);
}
for (n=0; n < count; n++) {
if (0 != strcmp(src[j]->argv[n], dst[j]->argv[n])) {
fprintf(stderr, "test12: invalid results (argv) from unpack");
return(false);
}
}
if (opal_argv_count(dst[j]->env) != (count = opal_argv_count(src[j]->env))) {
fprintf(stderr, "test12: invalid results (num env) from unpack");
return(false);
}
for (k=0; k < (size_t)count; k++) {
if (0 != strcmp(src[j]->env[k], dst[j]->env[k])) {
fprintf(stderr, "test12: invalid results (envs) from unpack");
return(false);
}
}
for (k=0; k< src[j]->num_map; k++) {
if ((src[j]->map_data[k])->map_type != (dst[j]->map_data[k])->map_type) {
fprintf(stderr, "test12: invalid results (map_data types) from unpack");
return(false);
}
if (0 != strcmp((src[j]->map_data[k])->map_data,
(dst[j]->map_data[k])->map_data)) {
fprintf(stderr, "test12: invalid results (map_data data) from unpack");
return(false);
}
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(stderr, "OBJ_RELEASE did not NULL the buffer pointer");
fprintf(stderr, "OBJ_RELEASE did not NULL the buffer pointer");
return false;
}
return (true);
}

Просмотреть файл

@ -1,179 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The OpenRTE Resource Manager data type function unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/rmgr/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_ac(void); /* includes app_context_map */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the rmgr to register data types */
if (ORTE_SUCCESS == orte_rmgr_base_open()) {
fprintf(stderr, "RMGR opened\n");
} else {
fprintf(stderr, "RMGR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_ac\n");
if (test_ac()) {
fprintf(stderr, "test_ac succeeded\n");
}
else {
fprintf(stderr, "test_ac failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_ac(void) /* buffer actions */
{
int n, rc, count;
size_t i, j;
orte_app_context_t *src[NUM_ELEMS];
orte_app_context_t *dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_app_context_t);
src[i]->idx = i;
src[i]->app = strdup("test-application-name");
src[i]->num_procs = i; /* test between 0 and NUM_ELEMS-1 proc counts */
/* test arg counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of argv count of zero */
src[i]->argv = (char**)malloc(count * sizeof(char*));
for (n=0; n < count-1; n++) {
src[i]->argv[n] = strdup("test-argv");
}
}
src[i]->argv[count-1] = NULL;
/* test env counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of num_env count of zero */
src[i]->env = (char**)malloc(count * sizeof(char*));
for (n=0; n < count; n++) {
src[i]->env[n] = strdup("test-env");
}
}
src[i]->env[count-1] = NULL;
src[i]->cwd = strdup ("test-cwd");
/* test imap data for map count = num_procs */
src[i]->num_map = i+1;
if (src[i]->num_map) { /* if to allow testing of map count of zero */
src[i]->map_data = (orte_app_context_map_t**)malloc(src[i]->num_map * sizeof(orte_app_context_map_t *)); /* map data type */
for (j=0; j < src[i]->num_map; j++) {
src[i]->map_data[j] = OBJ_NEW(orte_app_context_map_t); /* assume we create with new rather than malloc? */
src[i]->map_data[j]->map_type = (uint8_t) j;
src[i]->map_data[j]->map_data = strdup("test-map-data");
}
}
}
/* source data set, now copy them */
for (i=0;i<NUM_ELEMS;i++) {
rc = orte_dss.copy((void**)&dst[i], src[i], ORTE_APP_CONTEXT);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
}
for(j=0; j<NUM_ELEMS; j++) {
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_APP_CONTEXT)) {
fprintf(stderr, "orte_dss.compare failed\n");
return(false);
}
}
return (true);
}

Просмотреть файл

@ -1,211 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The OpenRTE Resource Manager data type function unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/rmgr/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_ac(void); /* includes app_context_map */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the rmgr to register data types */
if (ORTE_SUCCESS == orte_rmgr_base_open()) {
fprintf(stderr, "RMGR opened\n");
} else {
fprintf(stderr, "RMGR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_ac\n");
if (test_ac()) {
fprintf(stderr, "test_ac succeeded\n");
}
else {
fprintf(stderr, "test_ac failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_ac(void) /* buffer actions */
{
int rc, n, count;
size_t i, j, k;
orte_app_context_t *src[NUM_ELEMS];
orte_app_context_t *dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_app_context_t);
src[i]->idx = i;
src[i]->app = strdup("test-application-name");
src[i]->num_procs = i; /* test between 0 and NUM_ELEMS-1 proc counts */
/* test arg counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of argv count of zero */
src[i]->argv = (char**)malloc(count * sizeof(char*));
for (n=0; n < count-1; n++) {
src[i]->argv[n] = strdup("test-argv");
}
}
src[i]->argv[count-1] = NULL;
/* test env counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of num_env count of zero */
src[i]->env = (char**)malloc(count * sizeof(char*));
for (j=0; j < count; j++) {
src[i]->env[j] = strdup("test-env");
}
}
src[i]->env[count-1] = NULL;
src[i]->cwd = strdup ("test-cwd");
/* test imap data for map count = num_procs */
src[i]->num_map = i+1;
if (src[i]->num_map) { /* if to allow testing of map count of zero */
src[i]->map_data = (orte_app_context_map_t**)malloc(src[i]->num_map * sizeof(orte_app_context_map_t *)); /* map data type */
for (j=0; j < src[i]->num_map; j++) {
src[i]->map_data[j] = OBJ_NEW(orte_app_context_map_t); /* assume we create with new rather than malloc? */
src[i]->map_data[j]->map_type = (uint8_t) j;
src[i]->map_data[j]->map_data = strdup("test-map-data");
}
}
}
/* source data set, now copy them */
for (i=0;i<NUM_ELEMS;i++) {
rc = orte_dss.copy((void**)&dst[i], src[i], ORTE_APP_CONTEXT);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
}
for(j=0; j<NUM_ELEMS; j++) {
if (
src[j]->idx != dst[j]->idx ||
0 != strcmp(src[j]->app, dst[j]->app) ||
src[j]->num_procs != dst[j]->num_procs ||
0 != strcmp(src[j]->cwd, dst[j]->cwd) ||
src[j]->num_map != dst[j]->num_map
) {
fprintf(stderr, "invalid results from copy\n");
return(false);
}
/* now compare each of the size/cnt depedant values */
for (n=0; NULL != src[j]->argv[n]; n++) {
if (0 != strcmp(src[j]->argv[n], dst[j]->argv[n])) {
fprintf(stderr, "invalid results (argv) from copy\n");
return(false);
}
}
for (k=0; NULL != src[j]->env[k]; k++) {
if (0 != strcmp(src[j]->env[k], dst[j]->env[k])) {
fprintf(stderr, "invalid results (envs) from copy\n");
return(false);
}
}
for (k=0; k< src[j]->num_map; k++) {
if ((src[j]->map_data[k])->map_type != (dst[j]->map_data[k])->map_type) {
fprintf(stderr, "invalid results (map_data types) from copy\n");
return(false);
}
if (0 != strcmp((src[j]->map_data[k])->map_data,
(dst[j]->map_data[k])->map_data)) {
fprintf(stderr, "invalid results (map_data data) from copy\n");
return(false);
}
}
}
return (true);
}

Просмотреть файл

@ -1,182 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The OpenRTE Resource Manager data type function unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/rmgr/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_ac(void); /* includes app_context_map */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the rmgr to register data types */
if (ORTE_SUCCESS == orte_rmgr_base_open()) {
fprintf(stderr, "RMGR opened\n");
} else {
fprintf(stderr, "RMGR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_ac\n");
if (test_ac()) {
fprintf(stderr, "test_ac succeeded\n");
}
else {
fprintf(stderr, "test_ac failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_ac(void) /* buffer actions */
{
int rc, n, count;
size_t i, j;
orte_app_context_t *src[NUM_ELEMS];
char *output;
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_app_context_t);
src[i]->idx = i;
src[i]->app = strdup("test-application-name");
src[i]->num_procs = i; /* test between 0 and NUM_ELEMS-1 proc counts */
/* test arg counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of argv count of zero */
src[i]->argv = (char**)malloc(count * sizeof(char*));
for (n=0; n < count-1; n++) {
src[i]->argv[n] = strdup("test-argv");
}
}
src[i]->argv[count-1] = NULL;
/* test env counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of num_env count of zero */
src[i]->env = (char**)malloc(count * sizeof(char*));
for (n=0; n < count; n++) {
src[i]->env[n] = strdup("test-env");
}
}
src[i]->env[count-1] = NULL;
src[i]->cwd = strdup ("test-cwd");
/* test imap data for map count = num_procs */
src[i]->num_map = i+1;
if (src[i]->num_map) { /* if to allow testing of map count of zero */
src[i]->map_data = (orte_app_context_map_t**)malloc(src[i]->num_map * sizeof(orte_app_context_map_t *)); /* map data type */
for (j=0; j < src[i]->num_map; j++) {
src[i]->map_data[j] = OBJ_NEW(orte_app_context_map_t); /* assume we create with new rather than malloc? */
src[i]->map_data[j]->map_type = (uint8_t) j;
src[i]->map_data[j]->map_data = strdup("test-map-data");
}
}
}
/* source data set, now print them */
for (i=0;i<NUM_ELEMS;i++) {
if (0 == i) {
rc = orte_dss.print(&output, NULL, src[i], ORTE_APP_CONTEXT);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with NULL prefix return code %d\n", rc);
return(false);
}
} else {
rc = orte_dss.print(&output, "dumb-prefix", src[i], ORTE_APP_CONTEXT);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with non-NULL prefix return code %d\n", rc);
return(false);
}
}
fprintf(stderr, "%s\n\n", output);
free(output);
output = NULL;
}
return (true);
}

Просмотреть файл

@ -1,174 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The OpenRTE Resource Manager data type function unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/rmgr/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_ac(void); /* includes app_context_map */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the rmgr to register data types */
if (ORTE_SUCCESS == orte_rmgr_base_open()) {
fprintf(stderr, "RMGR opened\n");
} else {
fprintf(stderr, "RMGR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_ac\n");
if (test_ac()) {
fprintf(stderr, "test_ac succeeded\n");
}
else {
fprintf(stderr, "test_ac failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_ac(void) /* buffer actions */
{
int n, count;
size_t i, j;
orte_app_context_t *src[NUM_ELEMS];
orte_data_value_t dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_app_context_t);
src[i]->idx = i;
src[i]->app = strdup("test-application-name");
src[i]->num_procs = i; /* test between 0 and NUM_ELEMS-1 proc counts */
/* test arg counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of argv count of zero */
src[i]->argv = (char**)malloc(count * sizeof(char*));
for (n=0; n < count-1; n++) {
src[i]->argv[n] = strdup("test-argv");
}
}
src[i]->argv[count-1] = NULL;
/* test env counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of num_env count of zero */
src[i]->env = (char**)malloc(count * sizeof(char*));
for (n=0; n < count; n++) {
src[i]->env[n] = strdup("test-env");
}
}
src[i]->env[count-1] = NULL;
src[i]->cwd = strdup ("test-cwd");
/* test imap data for map count = num_procs */
src[i]->num_map = i+1;
if (src[i]->num_map) { /* if to allow testing of map count of zero */
src[i]->map_data = (orte_app_context_map_t**)malloc(src[i]->num_map * sizeof(orte_app_context_map_t *)); /* map data type */
for (j=0; j < src[i]->num_map; j++) {
src[i]->map_data[j] = OBJ_NEW(orte_app_context_map_t); /* assume we create with new rather than malloc? */
src[i]->map_data[j]->map_type = (uint8_t) j;
src[i]->map_data[j]->map_data = strdup("test-map-data");
}
}
}
/* source data set, now release them */
for (i=0;i<NUM_ELEMS;i++) {
dval.type = ORTE_APP_CONTEXT;
dval.data = src[i];
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(stderr, "data pointer did not get null'd\n");
return(false);
}
}
return (true);
}

Просмотреть файл

@ -1,180 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The OpenRTE Resource Manager data type function unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/rmgr/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_ac(void); /* includes app_context_map */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the rmgr to register data types */
if (ORTE_SUCCESS == orte_rmgr_base_open()) {
fprintf(stderr, "RMGR opened\n");
} else {
fprintf(stderr, "RMGR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_ac\n");
if (test_ac()) {
fprintf(stderr, "test_ac succeeded\n");
}
else {
fprintf(stderr, "test_ac failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_ac(void) /* buffer actions */
{
int rc, n, count;
size_t i, j, sz;
orte_app_context_t *src[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_app_context_t);
src[i]->idx = i;
src[i]->app = strdup("test-application-name");
src[i]->num_procs = i; /* test between 0 and NUM_ELEMS-1 proc counts */
/* test arg counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of argv count of zero */
src[i]->argv = (char**)malloc(count * sizeof(char*));
for (n=0; n < count-1; n++) {
src[i]->argv[n] = strdup("test-argv");
}
}
src[i]->argv[count-1] = NULL;
/* test env counts of 1 to NUM_ELEMS+1 */
count = i+1;
if (count) { /* if to allow testing of num_env count of zero */
src[i]->env = (char**)malloc(count * sizeof(char*));
for (n=0; n < count; n++) {
src[i]->env[n] = strdup("test-env");
}
}
src[i]->env[count-1] = NULL;
src[i]->cwd = strdup ("test-cwd");
/* test imap data for map count = num_procs */
src[i]->num_map = i+1;
if (src[i]->num_map) { /* if to allow testing of map count of zero */
src[i]->map_data = (orte_app_context_map_t**)malloc(src[i]->num_map * sizeof(orte_app_context_map_t *)); /* map data type */
for (j=0; j < src[i]->num_map; j++) {
src[i]->map_data[j] = OBJ_NEW(orte_app_context_map_t); /* assume we create with new rather than malloc? */
src[i]->map_data[j]->map_type = (uint8_t) j;
src[i]->map_data[j]->map_data = strdup("test-map-data");
}
}
}
/* source data set, now size them */
for (i=0;i<NUM_ELEMS;i++) {
rc = orte_dss.size(&sz, src[i], ORTE_APP_CONTEXT);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
}
/* now size the object itself */
rc = orte_dss.size(&sz, NULL, ORTE_APP_CONTEXT);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
if (sz != sizeof(orte_app_context_t)) {
fprintf(stderr, "orte_dss.size returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}

Просмотреть файл

@ -1,34 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
AM_CPPFLAGS = -I$(top_srcdir)/opal/libltdl -I$(top_srcdir)/test/support
check_PROGRAMS = \
test_schema
TESTS = \
$(check_PROGRAMS)
test_schema_SOURCES = test_schema.c
test_schema_LDADD = \
$(top_builddir)/test/support/libsupport.a \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
test_schema_DEPENDENCIES = $(test_schema_LDADD)

Просмотреть файл

@ -1,177 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "components.h"
#include "orte/orte_constants.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std";
int
main(int argc, char **argv)
{
printf("schema test not implemented\n");
return 77;
}
#if 0
int rc;
bool allow, have;
int priority;
test_component_handle_t gpr_handle;
mca_gpr_base_component_t *gpr_component = NULL;
orte_gpr_base_module_t *gpr_module = NULL;
test_component_handle_t ras_handle;
orte_ras_base_component_t *ras_component = NULL;
orte_ras_base_module_t *ras_module = NULL;
test_init("test_ras_fn");
if (getenv("TEST_WRITE_TO_FILE") != NULL) {
test_out = fopen( "test_ras_fn", "w+" );
} else {
test_out = stderr;
}
if( test_out == NULL ) {
test_failure("ras_fn couldn't open test file failed");
test_finalize();
exit(1);
}
/* ENSURE THE GPR REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* Open up the output streams */
if (!opal_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads -
* and reset otherwise.
*/
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
ompi_malloc_init();
/* Ensure the system_info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_sys_info())) {
return rc;
}
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start\n");
exit (1);
}
/* Open the gpr replica component and initialize a module */
if (OMPI_SUCCESS !=
test_component_open("gpr", "replica", &gpr_handle,
(mca_base_component_t**) &gpr_component) ||
NULL == gpr_component) {
test_fail_stop("Could not open GPR replica\n", 1);
}
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (NULL == gpr_module) {
test_fail_stop("GPR replica component did not return a module\n", 1);
}
fprintf(test_out, "GPR replica started\n");
/* dps */
if (ORTE_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else {
fprintf(test_out, "DPS could not start\n");
exit (1);
}
/* setup the ras */
if (OMPI_SUCCESS !=
test_component_open("ras", "host", &ras_handle,
(mca_base_component_t**) &ras_component) ||
NULL == ras_component) {
test_fail_stop("Could not open ras host component\n", 1);
}
ras_module = ras_component->ras_init(&priority);
if (NULL == ras_module) {
test_fail_stop("ras host component did not return a module\n", 1);
}
fprintf(test_out, "RAS host component started\n");
fprintf(stderr, "now finalize and see if all memory cleared\n");
if (NULL != ras_module->finalize) {
ras_module->finalize();
}
test_component_close(&ras_handle);
orte_dps_close();
if (NULL != gpr_component->gpr_finalize) {
gpr_component->gpr_finalize();
}
test_component_close(&gpr_handle);
orte_sys_info_finalize();
orte_proc_info_finalize();
mca_base_close();
ompi_malloc_finalize();
opal_output_finalize();
ompi_class_finalize();
fclose( test_out );
/* result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_ras failed");
}
*/
test_finalize();
exit (0);
}
#endif

Просмотреть файл

@ -1,68 +0,0 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
AM_CPPFLAGS = -I$(top_srcdir)/test/support
check_PROGRAMS = \
smr_dt_buffer \
smr_dt_compare \
smr_dt_print \
smr_dt_size \
smr_dt_release \
smr_dt_copy
TESTS = \
$(check_PROGRAMS)
smr_dt_buffer_SOURCES = smr_dt_buffer.c
smr_dt_buffer_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
smr_dt_buffer_DEPENDENCIES = $(smr_dt_buffer_LDADD)
smr_dt_copy_SOURCES = smr_dt_copy.c
smr_dt_copy_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
smr_dt_copy_DEPENDENCIES = $(smr_dt_copy_LDADD)
smr_dt_compare_SOURCES = smr_dt_compare.c
smr_dt_compare_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
smr_dt_compare_DEPENDENCIES = $(smr_dt_compare_LDADD)
smr_dt_print_SOURCES = smr_dt_print.c
smr_dt_print_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
smr_dt_print_DEPENDENCIES = $(smr_dt_print_LDADD)
smr_dt_size_SOURCES = smr_dt_size.c
smr_dt_size_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
smr_dt_size_DEPENDENCIES = $(smr_dt_size_LDADD)
smr_dt_release_SOURCES = smr_dt_release.c
smr_dt_release_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
smr_dt_release_DEPENDENCIES = $(smr_dt_release_LDADD)

Просмотреть файл

@ -1,209 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/soh/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_soh_base_open()) {
fprintf(stderr, "SOH opened\n");
} else {
fprintf(stderr, "SOH could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_soh_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_buffer_t *bufA;
int rc;
orte_exit_code_t sec[NUM_ELEMS], dec[NUM_ELEMS];
orte_proc_state_t sps[NUM_ELEMS], dps[NUM_ELEMS];
orte_job_state_t sjs[NUM_ELEMS], djs[NUM_ELEMS];
orte_node_state_t sns[NUM_ELEMS], dns[NUM_ELEMS];
int i;
for (i=0; i < NUM_ELEMS; i++) {
sec[i] = i % 256;
sps[i] = (i+1)%256;
sjs[i] = (i+2)%256;
sns[i] = (i+3)%256;
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(stderr, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, sec, NUM_ELEMS, ORTE_EXIT_CODE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, sps, NUM_ELEMS, ORTE_PROC_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, sjs, NUM_ELEMS, ORTE_JOB_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, sns, NUM_ELEMS, ORTE_NODE_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
size_t count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dec, &count, ORTE_EXIT_CODE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(stderr, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dps, &count, ORTE_PROC_STATE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(stderr, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, djs, &count, ORTE_JOB_STATE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(stderr, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dns, &count, ORTE_NODE_STATE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(stderr, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(sec[j] != dec[j] ||
sps[j] != dps[j] ||
sjs[j] != djs[j] ||
sns[j] != dns[j]) {
fprintf(stderr, "test5: invalid results from unpack\n");
return(false);
}
}
}
/* cleanup */
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(stderr, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return(true);
}

Просмотреть файл

@ -1,169 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/soh/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_soh_base_open()) {
fprintf(stderr, "SOH opened\n");
} else {
fprintf(stderr, "SOH could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_soh_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
int rc;
orte_exit_code_t sec, *dec;
orte_proc_state_t sps, *dps;
orte_job_state_t sjs, *djs;
orte_node_state_t sns, *dns;
sec = 2;
sps = 125;
sjs = 117;
sns = 0x7e;
rc = orte_dss.copy((void**)&dec, &sec, ORTE_EXIT_CODE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dec, &sec, ORTE_EXIT_CODE)) {
fprintf(stderr, "orte_dss.compare failed with incorrect response (exit code)\n");
return(false);
}
rc = orte_dss.copy((void**)&dps, &sps, ORTE_PROC_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dps, &sps, ORTE_PROC_STATE)) {
fprintf(stderr, "orte_dss.compare failed with incorrect response (ORTE_PROC_STATE)\n");
return(false);
}
rc = orte_dss.copy((void**)&djs, &sjs, ORTE_JOB_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(djs, &sjs, ORTE_JOB_STATE)) {
fprintf(stderr, "orte_dss.compare failed with incorrect response (ORTE_JOB_STATE)\n");
return(false);
}
rc = orte_dss.copy((void**)&dns, &sns, ORTE_NODE_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dns, &sns, ORTE_NODE_STATE)) {
fprintf(stderr, "orte_dss.compare failed with incorrect response (ORTE_NODE_STATE)\n");
return(false);
}
return(true);
}

Просмотреть файл

@ -1,169 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/soh/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_soh_base_open()) {
fprintf(stderr, "SOH opened\n");
} else {
fprintf(stderr, "SOH could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_soh_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
int rc;
orte_exit_code_t sec, *dec;
orte_proc_state_t sps, *dps;
orte_job_state_t sjs, *djs;
orte_node_state_t sns, *dns;
sec = 2;
sps = 125;
sjs = 117;
sns = 0x7e;
rc = orte_dss.copy((void**)&dec, &sec, ORTE_EXIT_CODE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (*dec != sec) {
fprintf(stderr, "orte_dss.copy failed with incorrect value (exit code)\n");
return(false);
}
rc = orte_dss.copy((void**)&dps, &sps, ORTE_PROC_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (*dps != sps) {
fprintf(stderr, "orte_dss.copy failed with incorrect value (proc state)\n");
return(false);
}
rc = orte_dss.copy((void**)&djs, &sjs, ORTE_JOB_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (*djs != sjs) {
fprintf(stderr, "orte_dss.copy failed with incorrect value (job state)\n");
return(false);
}
rc = orte_dss.copy((void**)&dns, &sns, ORTE_NODE_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (*dns != sns) {
fprintf(stderr, "orte_dss.copy failed with incorrect value (node state)\n");
return(false);
}
return(true);
}

Просмотреть файл

@ -1,190 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/soh/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_soh_base_open()) {
fprintf(stderr, "SOH opened\n");
} else {
fprintf(stderr, "SOH could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_soh_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
int rc;
orte_exit_code_t sec;
orte_proc_state_t sps;
orte_job_state_t sjs;
orte_node_state_t sns;
char *output;
sec = 2;
sps = 125;
sjs = 117;
sns = 0x7e;
rc = orte_dss.print(&output, "dumb-prefix", &sec, ORTE_EXIT_CODE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with return code %d\n", rc);
return(false);
}
fprintf(stderr, "%s\n", output);
free(output);
rc = orte_dss.print(&output, NULL, &sec, ORTE_EXIT_CODE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with return code %d\n", rc);
return(false);
}
fprintf(stderr, "NULL prefix\n%s\n\n", output);
free(output);
rc = orte_dss.print(&output, "dumb-prefix", &sps, ORTE_PROC_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with return code %d\n", rc);
return(false);
}
fprintf(stderr, "%s\n", output);
free(output);
rc = orte_dss.print(&output, NULL, &sps, ORTE_PROC_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with return code %d\n", rc);
return(false);
}
fprintf(stderr, "NULL prefix\n%s\n\n", output);
free(output);
rc = orte_dss.print(&output, "dumb-prefix", &sjs, ORTE_JOB_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with return code %d\n", rc);
return(false);
}
fprintf(stderr, "%s\n", output);
free(output);
rc = orte_dss.print(&output, NULL, &sjs, ORTE_JOB_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with return code %d\n", rc);
return(false);
}
fprintf(stderr, "NULL prefix\n%s\n\n", output);
free(output);
rc = orte_dss.print(&output, "dumb-prefix", &sns, ORTE_NODE_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with return code %d\n", rc);
return(false);
}
fprintf(stderr, "%s\n", output);
free(output);
rc = orte_dss.print(&output, NULL, &sns, ORTE_NODE_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.print failed with return code %d\n", rc);
return(false);
}
fprintf(stderr, "NULL prefix\n%s\n\n", output);
free(output);
return(true);
}

Просмотреть файл

@ -1,199 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/soh/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_soh_base_open()) {
fprintf(stderr, "SOH opened\n");
} else {
fprintf(stderr, "SOH could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_soh_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
int rc;
orte_exit_code_t sec, *dec;
orte_proc_state_t sps, *dps;
orte_job_state_t sjs, *djs;
orte_node_state_t sns, *dns;
orte_data_value_t dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
sec = 2;
sps = 125;
sjs = 117;
sns = 0x7e;
rc = orte_dss.copy((void**)&dec, &sec, ORTE_EXIT_CODE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (*dec != sec) {
fprintf(stderr, "orte_dss.copy failed with incorrect value (exit code)\n");
return(false);
}
dval.type = ORTE_EXIT_CODE;
dval.data = dec;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(stderr, "data pointer did not get null'd\n");
return(false);
}
rc = orte_dss.copy((void**)&dps, &sps, ORTE_PROC_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (*dps != sps) {
fprintf(stderr, "orte_dss.copy failed with incorrect value (proc state)\n");
return(false);
}
dval.type = ORTE_PROC_STATE;
dval.data = dps;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(stderr, "data pointer did not get null'd\n");
return(false);
}
rc = orte_dss.copy((void**)&djs, &sjs, ORTE_JOB_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (*djs != sjs) {
fprintf(stderr, "orte_dss.copy failed with incorrect value (job state)\n");
return(false);
}
dval.type = ORTE_JOB_STATE;
dval.data = djs;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(stderr, "data pointer did not get null'd\n");
return(false);
}
rc = orte_dss.copy((void**)&dns, &sns, ORTE_NODE_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.copy failed with return code %d\n", rc);
return(false);
}
if (*dns != sns) {
fprintf(stderr, "orte_dss.copy failed with incorrect value (node state)\n");
return(false);
}
dval.type = ORTE_NODE_STATE;
dval.data = dns;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(stderr, "data pointer did not get null'd\n");
return(false);
}
return(true);
}

Просмотреть файл

@ -1,170 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/soh/base/base.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test_unstruct(void); /* size */
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OPAL_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the name service to register data types */
if (ORTE_SUCCESS == orte_soh_base_open()) {
fprintf(stderr, "SOH opened\n");
} else {
fprintf(stderr, "SOH could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
orte_soh_base_close();
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
int rc;
orte_exit_code_t sec;
orte_proc_state_t sps;
orte_job_state_t sjs;
orte_node_state_t sns;
size_t sz;
sec = 2;
sps = 125;
sjs = 117;
sns = 0x7e;
rc = orte_dss.size(&sz, &sec, ORTE_EXIT_CODE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
if (sz != sizeof(orte_exit_code_t)) {
fprintf(stderr, "orte_dss.size failed with incorrect value (exit code)\n");
return(false);
}
rc = orte_dss.size(&sz, &sps, ORTE_PROC_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
if (sz != sizeof(orte_proc_state_t)) {
fprintf(stderr, "orte_dss.size failed with incorrect value (ORTE_PROC_STATE)\n");
return(false);
}
rc = orte_dss.size(&sz, &sjs, ORTE_JOB_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
if (sz != sizeof(orte_job_state_t)) {
fprintf(stderr, "orte_dss.size failed with incorrect value (ORTE_JOB_STATE)\n");
return(false);
}
rc = orte_dss.size(&sz, &sns, ORTE_NODE_STATE);
if (ORTE_SUCCESS != rc) {
fprintf(stderr, "orte_dss.size failed with return code %d\n", rc);
return(false);
}
if (sz != sizeof(orte_node_state_t)) {
fprintf(stderr, "orte_dss.size failed with incorrect value (ORTE_NODE_STATE)\n");
return(false);
}
return(true);
}