1
1

Convert the rest of the GPR tests to use loading DSO's and function

pointers instead of direct function invocations.

This commit was SVN r5180.
Этот коммит содержится в:
Jeff Squyres 2005-04-05 18:18:27 +00:00
родитель 3380498e79
Коммит b5459e9da6
5 изменённых файлов: 129 добавлений и 111 удалений

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

@ -31,12 +31,6 @@ check_PROGRAMS = \
TESTS = \ TESTS = \
$(check_PROGRAMS) $(check_PROGRAMS)
if OMPI_BUILD_gpr_replica_DSO
replica = $(top_builddir)/src/mca/gpr/replica/mca_gpr_replica.la
else
replica = $(top_builddir)/src/mca/gpr/replica/libmca_gpr_replica.la
endif
gpr_internal_fns_SOURCES = gpr_internal_fns.c gpr_internal_fns_SOURCES = gpr_internal_fns.c
gpr_internal_fns_LDADD = \ gpr_internal_fns_LDADD = \
$(top_builddir)/src/libmpi.la \ $(top_builddir)/src/libmpi.la \
@ -58,20 +52,17 @@ gpr_overwrite_DEPENDENCIES = $(gpr_overwrite_LDADD)
gpr_put_get_SOURCES = gpr_put_get.c gpr_put_get_SOURCES = gpr_put_get.c
gpr_put_get_LDADD = \ gpr_put_get_LDADD = \
$(top_builddir)/src/libmpi.la \ $(top_builddir)/src/libmpi.la \
$(replica) \
$(top_builddir)/test/support/libsupport.a $(top_builddir)/test/support/libsupport.a
gpr_put_get_DEPENDENCIES = $(gpr_put_get_LDADD) gpr_put_get_DEPENDENCIES = $(gpr_put_get_LDADD)
gpr_threads_SOURCES = gpr_threads.c gpr_threads_SOURCES = gpr_threads.c
gpr_threads_LDADD = \ gpr_threads_LDADD = \
$(top_builddir)/src/libmpi.la \ $(top_builddir)/src/libmpi.la \
$(replica) \
$(top_builddir)/test/support/libsupport.a $(top_builddir)/test/support/libsupport.a
gpr_threads_DEPENDENCIES = $(gpr_threads_LDADD) gpr_threads_DEPENDENCIES = $(gpr_threads_LDADD)
gpr_triggers_SOURCES = gpr_triggers.c gpr_triggers_SOURCES = gpr_triggers.c
gpr_triggers_LDADD = \ gpr_triggers_LDADD = \
$(top_builddir)/src/libmpi.la \ $(top_builddir)/src/libmpi.la \
$(replica) \
$(top_builddir)/test/support/libsupport.a $(top_builddir)/test/support/libsupport.a
gpr_triggers_DEPENDENCIES = $(gpr_triggers_LDADD) gpr_triggers_DEPENDENCIES = $(gpr_triggers_LDADD)

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

@ -31,6 +31,7 @@
#include "include/orte_schema.h" #include "include/orte_schema.h"
#include "support.h" #include "support.h"
#include "components.h"
#include "class/orte_pointer_array.h" #include "class/orte_pointer_array.h"
#include "dps/dps.h" #include "dps/dps.h"
@ -52,6 +53,11 @@ int main(int argc, char **argv)
int32_t i, cnt; int32_t i, cnt;
char *names[15], *keys[5]; char *names[15], *keys[5];
orte_gpr_value_t **values, *val; orte_gpr_value_t **values, *val;
test_component_handle_t handle;
mca_gpr_base_component_t *gpr_component = NULL;
orte_gpr_base_module_t *gpr_module = NULL;
bool allow, have;
int priority;
test_init("test_gpr_replica"); test_init("test_gpr_replica");
@ -70,12 +76,13 @@ int main(int argc, char **argv)
if (!ompi_output_init()) { if (!ompi_output_init()) {
return OMPI_ERROR; return OMPI_ERROR;
} }
/* /*
* If threads are supported - assume that we are using threads - and reset otherwise. * If threads are supported - assume that we are using threads -
* and reset otherwise.
*/ */
ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT); ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */ /* For malloc debugging */
ompi_malloc_init(); ompi_malloc_init();
@ -88,7 +95,6 @@ int main(int argc, char **argv)
if (ORTE_SUCCESS != (rc = orte_proc_info())) { if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc; return rc;
} }
orte_process_info.seed = true; 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 = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
@ -104,20 +110,20 @@ int main(int argc, char **argv)
exit (1); exit (1);
} }
if (ORTE_SUCCESS == orte_gpr_base_open()) { /* Open the gpr replica component and initialize a module */
fprintf(test_out, "GPR started\n"); if (OMPI_SUCCESS !=
} else { test_component_open("gpr", "replica", &handle,
fprintf(test_out, "GPR could not start\n"); (mca_base_component_t**) &gpr_component) ||
exit (1); NULL == gpr_component) {
fprintf(test_out, "Could not open replica\n");
exit(1);
} }
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (ORTE_SUCCESS == orte_gpr_base_select()) { if (NULL == gpr_module) {
fprintf(test_out, "GPR replica selected\n"); fprintf(test_out, "replica component did not return a module\n");
} else { exit(1);
fprintf(test_out, "GPR replica could not be selected\n");
exit (1);
} }
if (ORTE_SUCCESS == orte_dps_open()) { if (ORTE_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n"); fprintf(test_out, "DPS started\n");
} else { } else {
@ -142,7 +148,7 @@ int main(int argc, char **argv)
(val->keyvals[i])->type = ORTE_UINT32; (val->keyvals[i])->type = ORTE_UINT32;
(val->keyvals[i])->value.ui32 = (uint32_t)i; (val->keyvals[i])->value.ui32 = (uint32_t)i;
} }
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &val))) {
fprintf(test_out, "gpr_test: put 1 value/multiple keyval failed with error code %s\n", fprintf(test_out, "gpr_test: put 1 value/multiple keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put 1 value/multiple keyval failed"); test_failure("gpr_test: put 1 value/multiple keyval failed");
@ -152,7 +158,7 @@ int main(int argc, char **argv)
fprintf(test_out, "gpr_test: put 1 value/multiple keyval passed\n"); fprintf(test_out, "gpr_test: put 1 value/multiple keyval passed\n");
} }
OBJ_RELEASE(val); OBJ_RELEASE(val);
fprintf(stderr, "do a get\n"); fprintf(stderr, "do a get\n");
names[0] = strdup("dummy0"); names[0] = strdup("dummy0");
names[1] = NULL; names[1] = NULL;
@ -161,7 +167,7 @@ int main(int argc, char **argv)
keys[2] = strdup("stupid-test-5"); keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8"); keys[3] = strdup("stupid-test-8");
keys[4] = NULL; keys[4] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR, if (ORTE_SUCCESS != (rc = gpr_module->get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment", "test-put-segment",
names, keys, names, keys,
&cnt, &values))) { &cnt, &values))) {
@ -199,7 +205,7 @@ int main(int argc, char **argv)
(val->keyvals[0])->value.strptr = strdup("try-string-value"); (val->keyvals[0])->value.strptr = strdup("try-string-value");
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
fprintf(stderr, "\tputting copy %d\n", i); fprintf(stderr, "\tputting copy %d\n", i);
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &val))) {
fprintf(test_out, "gpr_test: put multiple copies of one keyval in a container failed with error code %s\n", fprintf(test_out, "gpr_test: put multiple copies of one keyval in a container failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put multiple copies of one keyval in a container failed"); test_failure("gpr_test: put multiple copies of one keyval in a container failed");
@ -211,10 +217,9 @@ int main(int argc, char **argv)
fprintf(stderr, "generate a trigger event\n"); fprintf(stderr, "generate a trigger event\n");
fprintf(stderr, "now finalize and see if all memory cleared\n"); fprintf(stderr, "now finalize and see if all memory cleared\n");
test_component_close(&handle);
orte_dps_close(); orte_dps_close();
orte_gpr_base_close();
orte_sys_info_finalize(); orte_sys_info_finalize();
orte_proc_info_finalize(); orte_proc_info_finalize();
mca_base_close(); mca_base_close();

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

@ -23,6 +23,7 @@
#include <string.h> #include <string.h>
#include "support.h" #include "support.h"
#include "components.h"
#include "util/proc_info.h" #include "util/proc_info.h"
#include "util/sys_info.h" #include "util/sys_info.h"
@ -40,6 +41,9 @@
/* output files needed by the test */ /* output files needed by the test */
static FILE *test_out=NULL; static FILE *test_out=NULL;
/* GPR module used by this test */
static orte_gpr_base_module_t *gpr_module = NULL;
/** /**
* Struct for holding information * Struct for holding information
*/ */
@ -122,6 +126,10 @@ int main(int argc, char **argv)
ompi_list_t nodes; ompi_list_t nodes;
test_node_t *node; test_node_t *node;
int i, rc; int i, rc;
test_component_handle_t handle;
mca_gpr_base_component_t *gpr_component = NULL;
bool allow, have;
int priority;
/* test_out = fopen( "test_gpr_replica_out", "w+" ); */ /* test_out = fopen( "test_gpr_replica_out", "w+" ); */
test_out = stderr; test_out = stderr;
@ -138,12 +146,13 @@ int main(int argc, char **argv)
if (!ompi_output_init()) { if (!ompi_output_init()) {
return OMPI_ERROR; return OMPI_ERROR;
} }
/* /*
* If threads are supported - assume that we are using threads - and reset otherwise. * If threads are supported - assume that we are using threads -
* and reset otherwise.
*/ */
ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT); ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */ /* For malloc debugging */
ompi_malloc_init(); ompi_malloc_init();
@ -157,7 +166,6 @@ int main(int argc, char **argv)
return rc; return rc;
} }
orte_process_info.seed = true; 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 = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0; orte_process_info.my_name->cellid = 0;
@ -172,18 +180,18 @@ int main(int argc, char **argv)
exit (1); exit (1);
} }
if (ORTE_SUCCESS == orte_gpr_base_open()) { /* Open the gpr replica component and initialize a module */
fprintf(test_out, "GPR started\n"); if (OMPI_SUCCESS !=
} else { test_component_open("gpr", "replica", &handle,
fprintf(test_out, "GPR could not start\n"); (mca_base_component_t**) &gpr_component) ||
exit (1); NULL == gpr_component) {
fprintf(test_out, "Could not open replica\n");
exit(1);
} }
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (ORTE_SUCCESS == orte_gpr_base_select()) { if (NULL == gpr_module) {
fprintf(test_out, "GPR replica selected\n"); fprintf(test_out, "replica component did not return a module\n");
} else { exit(1);
fprintf(test_out, "GPR replica could not be selected\n");
exit (1);
} }
if (ORTE_SUCCESS == orte_dps_open()) { if (ORTE_SUCCESS == orte_dps_open()) {
@ -217,7 +225,7 @@ int main(int argc, char **argv)
fprintf(test_out, "initial put of values successful\n"); fprintf(test_out, "initial put of values successful\n");
} }
orte_gpr.dump_all(0); gpr_module->dump_all(0);
fprintf(test_out, "changing values for overwrite test\n"); fprintf(test_out, "changing values for overwrite test\n");
/* change the arch, state, and slots_inuse values */ /* change the arch, state, and slots_inuse values */
@ -240,15 +248,15 @@ int main(int argc, char **argv)
fprintf(test_out, "second put of values successful\n"); fprintf(test_out, "second put of values successful\n");
} }
orte_gpr.dump_all(0); gpr_module->dump_all(0);
fprintf(stderr, "now finalize and see if all memory cleared\n"); fprintf(stderr, "now finalize and see if all memory cleared\n");
while (NULL != (node = (test_node_t*)ompi_list_remove_first(&nodes))) { while (NULL != (node = (test_node_t*)ompi_list_remove_first(&nodes))) {
OBJ_RELEASE(node); OBJ_RELEASE(node);
} }
OBJ_DESTRUCT(&nodes); OBJ_DESTRUCT(&nodes);
test_component_close(&handle);
orte_dps_close(); orte_dps_close();
orte_gpr_base_close();
orte_sys_info_finalize(); orte_sys_info_finalize();
orte_proc_info_finalize(); orte_proc_info_finalize();
mca_base_close(); mca_base_close();
@ -371,7 +379,7 @@ int test_overwrite(ompi_list_t* nodes)
} }
/* try the insert */ /* try the insert */
rc = orte_gpr.put(num_values, values); rc = gpr_module->put(num_values, values);
for (j=0; j < num_values; j++) { for (j=0; j < num_values; j++) {
OBJ_RELEASE(values[j]); OBJ_RELEASE(values[j]);

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

@ -34,6 +34,7 @@
#include "include/orte_schema.h" #include "include/orte_schema.h"
#include "support.h" #include "support.h"
#include "components.h"
#include "class/orte_pointer_array.h" #include "class/orte_pointer_array.h"
#include "dps/dps.h" #include "dps/dps.h"
@ -59,6 +60,11 @@ int main(int argc, char **argv)
char *names[15], *keys[5]; char *names[15], *keys[5];
orte_gpr_keyval_t **kvals; orte_gpr_keyval_t **kvals;
orte_gpr_value_t **values, *val; orte_gpr_value_t **values, *val;
test_component_handle_t handle;
mca_gpr_base_component_t *gpr_component = NULL;
orte_gpr_base_module_t *gpr_module = NULL;
bool allow, have;
int priority;
test_init("test_gpr_replica"); test_init("test_gpr_replica");
@ -80,12 +86,13 @@ int main(int argc, char **argv)
if (!ompi_output_init()) { if (!ompi_output_init()) {
return OMPI_ERROR; return OMPI_ERROR;
} }
/* /*
* If threads are supported - assume that we are using threads - and reset otherwise. * If threads are supported - assume that we are using threads -
* and reset otherwise.
*/ */
ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT); ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */ /* For malloc debugging */
ompi_malloc_init(); ompi_malloc_init();
@ -98,7 +105,6 @@ int main(int argc, char **argv)
if (ORTE_SUCCESS != (rc = orte_proc_info())) { if (ORTE_SUCCESS != (rc = orte_proc_info())) {
return rc; return rc;
} }
orte_process_info.seed = true; 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 = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
@ -114,18 +120,18 @@ int main(int argc, char **argv)
exit (1); exit (1);
} }
if (ORTE_SUCCESS == orte_gpr_base_open()) { /* Open the gpr replica component and initialize a module */
fprintf(test_out, "GPR started\n"); if (OMPI_SUCCESS !=
} else { test_component_open("gpr", "replica", &handle,
fprintf(test_out, "GPR could not start\n"); (mca_base_component_t**) &gpr_component) ||
exit (1); NULL == gpr_component) {
fprintf(test_out, "Could not open replica\n");
exit(1);
} }
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (ORTE_SUCCESS == orte_gpr_base_select()) { if (NULL == gpr_module) {
fprintf(test_out, "GPR replica selected\n"); fprintf(test_out, "replica component did not return a module\n");
} else { exit(1);
fprintf(test_out, "GPR replica could not be selected\n");
exit (1);
} }
if (ORTE_SUCCESS == orte_dps_open()) { if (ORTE_SUCCESS == orte_dps_open()) {
@ -150,7 +156,7 @@ int main(int argc, char **argv)
(val->keyvals[0])->key = strdup("stupid-value-next-one"); (val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->type = ORTE_INT32; (val->keyvals[0])->type = ORTE_INT32;
(val->keyvals[0])->value.i32 = 654321; (val->keyvals[0])->value.i32 = 654321;
if (ORTE_SUCCESS != (rc = orte_gpr_replica_put(1, &val))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &val))) {
fprintf(test_out, "gpr_test: put of 1 value/1 keyval failed with error code %s\n", fprintf(test_out, "gpr_test: put of 1 value/1 keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put of 1 value/1 keyval failed"); test_failure("gpr_test: put of 1 value/1 keyval failed");
@ -178,7 +184,7 @@ int main(int argc, char **argv)
(val->keyvals[i])->type = ORTE_UINT32; (val->keyvals[i])->type = ORTE_UINT32;
(val->keyvals[i])->value.ui32 = (uint32_t)i; (val->keyvals[i])->value.ui32 = (uint32_t)i;
} }
if (ORTE_SUCCESS != (rc = orte_gpr_replica_put(1, &val))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &val))) {
fprintf(test_out, "gpr_test: put 1 value/multiple keyval failed with error code %s\n", fprintf(test_out, "gpr_test: put 1 value/multiple keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put 1 value/multiple keyval failed"); test_failure("gpr_test: put 1 value/multiple keyval failed");
@ -206,7 +212,7 @@ int main(int argc, char **argv)
(val->keyvals[i])->type = ORTE_UINT32; (val->keyvals[i])->type = ORTE_UINT32;
(val->keyvals[i])->value.ui32 = (uint32_t)i; (val->keyvals[i])->value.ui32 = (uint32_t)i;
} }
if (ORTE_SUCCESS != (rc = orte_gpr_replica_put(1, &val))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &val))) {
fprintf(test_out, "gpr_test: put 1 value/multiple keyval in second container failed with error code %s\n", fprintf(test_out, "gpr_test: put 1 value/multiple keyval in second container failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put 1 value/multiple keyval in second container failed"); test_failure("gpr_test: put 1 value/multiple keyval in second container failed");
@ -218,7 +224,7 @@ int main(int argc, char **argv)
OBJ_RELEASE(val); OBJ_RELEASE(val);
fprintf(stderr, "dump\n"); fprintf(stderr, "dump\n");
if (ORTE_SUCCESS != (rc = orte_gpr.dump_all(0))) { if (ORTE_SUCCESS != (rc = gpr_module->dump_all(0))) {
fprintf(test_out, "gpr_test: dump failed with error code %s\n", fprintf(test_out, "gpr_test: dump failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: dump failed"); test_failure("gpr_test: dump failed");
@ -233,7 +239,7 @@ int main(int argc, char **argv)
names[1] = NULL; names[1] = NULL;
keys[0] = strdup("stupid-test-1"); keys[0] = strdup("stupid-test-1");
keys[1] = NULL; keys[1] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR, if (ORTE_SUCCESS != (rc = gpr_module->get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment", "test-put-segment",
names, keys, names, keys,
&cnt, &values))) { &cnt, &values))) {
@ -269,7 +275,7 @@ int main(int argc, char **argv)
keys[2] = strdup("stupid-test-5"); keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8"); keys[3] = strdup("stupid-test-8");
keys[4] = NULL; keys[4] = NULL;
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR, if (ORTE_SUCCESS != (rc = gpr_module->get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment", "test-put-segment",
names, keys, names, keys,
&cnt, &values))) { &cnt, &values))) {
@ -317,7 +323,7 @@ int main(int argc, char **argv)
(val->keyvals[0])->value.strptr = strdup("try-string-value"); (val->keyvals[0])->value.strptr = strdup("try-string-value");
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
fprintf(stderr, "\tputting copy %d\n", i); fprintf(stderr, "\tputting copy %d\n", i);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_put(1, &val))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &val))) {
fprintf(test_out, "gpr_test: put multiple copies of one keyval in a container failed with error code %s\n", fprintf(test_out, "gpr_test: put multiple copies of one keyval in a container failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put multiple copies of one keyval in a container failed"); test_failure("gpr_test: put multiple copies of one keyval in a container failed");
@ -327,7 +333,7 @@ int main(int argc, char **argv)
} }
OBJ_RELEASE(val); OBJ_RELEASE(val);
orte_gpr.dump_all(0); gpr_module->dump_all(0);
fprintf(stderr, "put with no tokens puts in every container\n"); fprintf(stderr, "put with no tokens puts in every container\n");
val = OBJ_NEW(orte_gpr_value_t); val = OBJ_NEW(orte_gpr_value_t);
@ -341,7 +347,7 @@ int main(int argc, char **argv)
(val->keyvals[0])->key = strdup("stupid-value-next-one"); (val->keyvals[0])->key = strdup("stupid-value-next-one");
(val->keyvals[0])->type = ORTE_STRING; (val->keyvals[0])->type = ORTE_STRING;
(val->keyvals[0])->value.strptr = strdup("try-string-value"); (val->keyvals[0])->value.strptr = strdup("try-string-value");
if (ORTE_SUCCESS != (rc = orte_gpr_replica_put(1, &val))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &val))) {
fprintf(test_out, "gpr_test: put with no tokens failed - returned %s\n", fprintf(test_out, "gpr_test: put with no tokens failed - returned %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put with no tokens failed"); test_failure("gpr_test: put with no tokens failed");
@ -351,12 +357,11 @@ int main(int argc, char **argv)
} }
OBJ_RELEASE(val); OBJ_RELEASE(val);
orte_gpr.dump_all(0); gpr_module->dump_all(0);
fprintf(stderr, "now finalize and see if all memory cleared\n"); fprintf(stderr, "now finalize and see if all memory cleared\n");
test_component_close(&handle);
orte_dps_close(); orte_dps_close();
orte_gpr_base_close();
orte_sys_info_finalize(); orte_sys_info_finalize();
orte_proc_info_finalize(); orte_proc_info_finalize();
mca_base_close(); mca_base_close();

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

@ -33,6 +33,7 @@
#include "include/orte_constants.h" #include "include/orte_constants.h"
#include "support.h" #include "support.h"
#include "components.h"
#include "class/orte_pointer_array.h" #include "class/orte_pointer_array.h"
#include "dps/dps.h" #include "dps/dps.h"
@ -53,6 +54,9 @@
/* output files needed by the test */ /* output files needed by the test */
static FILE *test_out=NULL; static FILE *test_out=NULL;
/* GPR module under test */
static orte_gpr_base_module_t *gpr_module = NULL;
static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std"; static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std";
static void test_cbfunc1(orte_gpr_notify_data_t *data, void *user_tag); static void test_cbfunc1(orte_gpr_notify_data_t *data, void *user_tag);
@ -69,6 +73,10 @@ static int test2(void);
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int rc=0; int rc=0;
test_component_handle_t handle;
mca_gpr_base_component_t *gpr_component = NULL;
bool allow, have;
int priority;
test_init("test_gpr_replica_trigs"); test_init("test_gpr_replica_trigs");
@ -90,12 +98,13 @@ int main(int argc, char **argv)
if (!ompi_output_init()) { if (!ompi_output_init()) {
exit(1); exit(1);
} }
/* /*
* If threads are supported - assume that we are using threads - and reset otherwise. * If threads are supported - assume that we are using threads -
* and reset otherwise.
*/ */
ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT); ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */ /* For malloc debugging */
ompi_malloc_init(); ompi_malloc_init();
@ -119,18 +128,18 @@ int main(int argc, char **argv)
exit (1); exit (1);
} }
if (ORTE_SUCCESS == orte_gpr_base_open()) { /* Open the gpr replica component and initialize a module */
fprintf(test_out, "GPR started\n"); if (OMPI_SUCCESS !=
} else { test_component_open("gpr", "replica", &handle,
fprintf(test_out, "GPR could not start\n"); (mca_base_component_t**) &gpr_component) ||
exit (1); NULL == gpr_component) {
fprintf(test_out, "Could not open replica\n");
exit(1);
} }
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (ORTE_SUCCESS == orte_gpr_base_select()) { if (NULL == gpr_module) {
fprintf(test_out, "GPR replica selected\n"); fprintf(test_out, "replica component did not return a module\n");
} else { exit(1);
fprintf(test_out, "GPR replica could not be selected\n");
exit (1);
} }
if (ORTE_SUCCESS == orte_dps_open()) { if (ORTE_SUCCESS == orte_dps_open()) {
@ -241,7 +250,7 @@ static int test1(void)
fprintf(test_out, "putting counters on registry\n"); fprintf(test_out, "putting counters on registry\n");
/* put the counters on the registry */ /* put the counters on the registry */
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &values))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value); OBJ_DESTRUCT(&value);
return rc; return rc;
@ -278,7 +287,7 @@ static int test1(void)
} }
values = &value; values = &value;
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &values))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value); OBJ_DESTRUCT(&value);
return rc; return rc;
@ -312,7 +321,7 @@ static int test1(void)
(value.keyvals[2])->value.i32 = 2348; (value.keyvals[2])->value.i32 = 2348;
values = &value; values = &value;
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &values))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value); OBJ_DESTRUCT(&value);
return rc; return rc;
@ -407,20 +416,20 @@ static int test1(void)
trigs = &trig; trigs = &trig;
/* enter things as three different subscriptions */ /* enter things as three different subscriptions */
rc = orte_gpr.subscribe( rc = gpr_module->subscribe(
ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_MONITOR_ONLY, ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_MONITOR_ONLY,
2, subscriptions, 2, subscriptions,
1, &trigs, 1, &trigs,
sub); sub);
rc = orte_gpr.subscribe( rc = gpr_module->subscribe(
ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_MONITOR_ONLY, ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_MONITOR_ONLY,
2, &(subscriptions[2]), 2, &(subscriptions[2]),
1, &trigs, 1, &trigs,
sub); sub);
rc = orte_gpr.subscribe( rc = gpr_module->subscribe(
ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_MONITOR_ONLY, ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_MONITOR_ONLY,
1, &(subscriptions[4]), 1, &(subscriptions[4]),
1, &trigs, 1, &trigs,
@ -435,7 +444,7 @@ static int test1(void)
} }
} }
orte_gpr.dump_triggers(0); gpr_module->dump_triggers(0);
return ORTE_SUCCESS; return ORTE_SUCCESS;
fprintf(test_out, "incrementing until trigger\n"); fprintf(test_out, "incrementing until trigger\n");
@ -469,14 +478,14 @@ static int test1(void)
for (i=0; i < 10; i++) { for (i=0; i < 10; i++) {
fprintf(test_out, "\tincrement %s\n", keys[1]); fprintf(test_out, "\tincrement %s\n", keys[1]);
if (ORTE_SUCCESS != (rc = orte_gpr.increment_value(&value))) { if (ORTE_SUCCESS != (rc = gpr_module->increment_value(&value))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value); OBJ_DESTRUCT(&value);
return rc; return rc;
} }
} }
orte_gpr.dump_all(0); gpr_module->dump_all(0);
OBJ_DESTRUCT(&value); OBJ_DESTRUCT(&value);
return ORTE_SUCCESS; return ORTE_SUCCESS;
@ -525,7 +534,7 @@ int test2(void)
fprintf(test_out, "putting level test counter on registry\n"); fprintf(test_out, "putting level test counter on registry\n");
/* put the counters on the registry */ /* put the counters on the registry */
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) { if (ORTE_SUCCESS != (rc = gpr_module->put(1, &values))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value); OBJ_DESTRUCT(&value);
return rc; return rc;
@ -579,13 +588,13 @@ int test2(void)
trigs = &trig; trigs = &trig;
/* enter subscription */ /* enter subscription */
rc = orte_gpr.subscribe( rc = gpr_module->subscribe(
ORTE_GPR_TRIG_AT_LEVEL | ORTE_GPR_TRIG_MONITOR_ONLY, ORTE_GPR_TRIG_AT_LEVEL | ORTE_GPR_TRIG_MONITOR_ONLY,
1, &subscription, 1, &subscription,
1, &trigs, 1, &trigs,
&sub); &sub);
orte_gpr.dump_triggers(0); gpr_module->dump_triggers(0);
/* cleanup */ /* cleanup */
OBJ_RELEASE(subscription); OBJ_RELEASE(subscription);
@ -622,14 +631,14 @@ int test2(void)
for (i=0; i < 10; i++) { for (i=0; i < 10; i++) {
fprintf(test_out, "\tincrement level-counter\n"); fprintf(test_out, "\tincrement level-counter\n");
if (ORTE_SUCCESS != (rc = orte_gpr.increment_value(&value))) { if (ORTE_SUCCESS != (rc = gpr_module->increment_value(&value))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value); OBJ_DESTRUCT(&value);
return rc; return rc;
} }
} }
orte_gpr.dump_all(0); gpr_module->dump_all(0);
OBJ_DESTRUCT(&value); OBJ_DESTRUCT(&value);
return ORTE_SUCCESS; return ORTE_SUCCESS;
@ -640,40 +649,40 @@ void test_cbfunc1(orte_gpr_notify_data_t *data, void *tag)
{ {
fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 1\n"); fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 1\n");
orte_gpr.dump_notify_data(data, 0); gpr_module->dump_notify_data(data, 0);
} }
void test_cbfunc2(orte_gpr_notify_data_t *data, void *tag) void test_cbfunc2(orte_gpr_notify_data_t *data, void *tag)
{ {
fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 2\n"); fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 2\n");
orte_gpr.dump_notify_data(data, 0); gpr_module->dump_notify_data(data, 0);
} }
void test_cbfunc3(orte_gpr_notify_data_t *data, void *tag) void test_cbfunc3(orte_gpr_notify_data_t *data, void *tag)
{ {
fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 3\n"); fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 3\n");
orte_gpr.dump_notify_data(data, 0); gpr_module->dump_notify_data(data, 0);
} }
void test_cbfunc4(orte_gpr_notify_data_t *data, void *tag) void test_cbfunc4(orte_gpr_notify_data_t *data, void *tag)
{ {
fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 4\n"); fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 4\n");
orte_gpr.dump_notify_data(data, 0); gpr_module->dump_notify_data(data, 0);
} }
void test_cbfunc5(orte_gpr_notify_data_t *data, void *tag) void test_cbfunc5(orte_gpr_notify_data_t *data, void *tag)
{ {
fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 5\n"); fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 5\n");
orte_gpr.dump_notify_data(data, 0); gpr_module->dump_notify_data(data, 0);
} }
void test_cbfunc6(orte_gpr_notify_data_t *data, void *tag) void test_cbfunc6(orte_gpr_notify_data_t *data, void *tag)
{ {
fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 6\n"); fprintf(test_out, "\n\n\nTRIGGER FIRED AND RECEIVED AT CALLBACK 6\n");
orte_gpr.dump_notify_data(data, 0); gpr_module->dump_notify_data(data, 0);
} }