2005-03-22 03:31:17 +03:00
|
|
|
/*
|
|
|
|
* 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.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2005-03-22 03:31:17 +03:00
|
|
|
* $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 "include/orte_constants.h"
|
2005-05-01 04:58:06 +04:00
|
|
|
#include "mca/schema/schema.h"
|
|
|
|
#include "mca/schema/base/base.h"
|
|
|
|
#include "mca/ns/base/base.h"
|
|
|
|
#include "mca/soh/base/base.h"
|
|
|
|
#include "mca/rmgr/base/base.h"
|
2005-03-22 03:31:17 +03:00
|
|
|
|
|
|
|
#include "support.h"
|
|
|
|
|
|
|
|
#include "class/orte_pointer_array.h"
|
|
|
|
#include "dps/dps.h"
|
|
|
|
#include "runtime/runtime.h"
|
|
|
|
#include "util/proc_info.h"
|
|
|
|
#include "util/sys_info.h"
|
2005-07-04 05:36:20 +04:00
|
|
|
#include "opal/util/malloc.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-03-22 03:31:17 +03:00
|
|
|
|
|
|
|
#include "mca/gpr/base/base.h"
|
|
|
|
#include "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;
|
2005-05-01 04:58:06 +04:00
|
|
|
size_t i, cnt;
|
2005-03-22 03:31:17 +03:00
|
|
|
char *names[15], *keys[5];
|
|
|
|
orte_gpr_value_t **values, *val;
|
2005-06-24 20:59:37 +04:00
|
|
|
|
2005-03-22 03:31:17 +03:00
|
|
|
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 */
|
2005-04-05 02:55:26 +04:00
|
|
|
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
|
2005-03-22 03:31:17 +03:00
|
|
|
|
|
|
|
/* Open up the output streams */
|
2005-07-04 03:31:27 +04:00
|
|
|
if (!opal_output_init()) {
|
2005-03-22 03:31:17 +03:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2005-04-05 22:18:27 +04:00
|
|
|
|
2005-03-22 03:31:17 +03:00
|
|
|
/*
|
2005-04-05 22:18:27 +04:00
|
|
|
* If threads are supported - assume that we are using threads -
|
|
|
|
* and reset otherwise.
|
2005-03-22 03:31:17 +03:00
|
|
|
*/
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
|
2005-04-05 22:18:27 +04:00
|
|
|
|
2005-03-22 03:31:17 +03:00
|
|
|
/* For malloc debugging */
|
2005-08-07 17:09:34 +04:00
|
|
|
opal_malloc_init();
|
2005-03-22 03:31:17 +03:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
2005-05-01 04:58:06 +04:00
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
2005-06-24 20:59:37 +04:00
|
|
|
/* 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);
|
2005-03-22 03:31:17 +03:00
|
|
|
}
|
2005-04-05 22:18:27 +04:00
|
|
|
|
2005-06-24 20:59:37 +04:00
|
|
|
/* do a select on the registry components */
|
|
|
|
if (OMPI_SUCCESS == orte_gpr_base_select()) {
|
|
|
|
fprintf(test_out, "GPR selected\n");
|
2005-03-22 03:31:17 +03:00
|
|
|
} else {
|
2005-06-24 20:59:37 +04:00
|
|
|
fprintf(test_out, "GPR could not select\n");
|
2005-03-22 03:31:17 +03:00
|
|
|
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++) {
|
2005-05-11 03:28:31 +04:00
|
|
|
asprintf(&(val->tokens[i]), "dummy%lu", (unsigned long) i);
|
2005-03-22 03:31:17 +03:00
|
|
|
}
|
|
|
|
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);
|
2005-05-11 03:28:31 +04:00
|
|
|
asprintf(&((val->keyvals[i])->key), "stupid-test-%lu",
|
|
|
|
(unsigned long) i);
|
2005-03-22 03:31:17 +03:00
|
|
|
(val->keyvals[i])->type = ORTE_UINT32;
|
|
|
|
(val->keyvals[i])->value.ui32 = (uint32_t)i;
|
|
|
|
}
|
2005-06-24 20:59:37 +04:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
|
2005-03-22 03:31:17 +03:00
|
|
|
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);
|
2005-04-05 22:18:27 +04:00
|
|
|
|
2005-03-22 03:31:17 +03:00
|
|
|
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;
|
2005-06-24 20:59:37 +04:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
|
2005-03-22 03:31:17 +03:00
|
|
|
"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++) {
|
2005-05-11 03:28:31 +04:00
|
|
|
asprintf(&(val->tokens[i]), "multi-dum-dum-%lu", (unsigned long) i);
|
2005-03-22 03:31:17 +03:00
|
|
|
}
|
|
|
|
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++) {
|
2005-05-11 03:28:31 +04:00
|
|
|
fprintf(stderr, "\tputting copy %lu\n", (unsigned long) i);
|
2005-06-24 20:59:37 +04:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
|
2005-03-22 03:31:17 +03:00
|
|
|
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");
|
2005-06-24 20:59:37 +04:00
|
|
|
orte_gpr_base_close();
|
2005-03-22 03:31:17 +03:00
|
|
|
orte_dps_close();
|
|
|
|
orte_sys_info_finalize();
|
|
|
|
orte_proc_info_finalize();
|
|
|
|
mca_base_close();
|
2005-08-07 17:09:34 +04:00
|
|
|
opal_malloc_finalize();
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_finalize();
|
2005-08-07 17:09:34 +04:00
|
|
|
opal_class_finalize();
|
2005-04-01 01:32:12 +04:00
|
|
|
|
2005-03-22 03:31:17 +03:00
|
|
|
fclose( test_out );
|
|
|
|
/* result = system( cmd_str );
|
|
|
|
if( result == 0 ) {
|
|
|
|
test_success();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
test_failure( "test_gpr_replica failed");
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
test_finalize();
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|