1
1

Begin cleanup of the name service unit tests. Fix an error in create_cellid.

This commit was SVN r4993.
Этот коммит содержится в:
Ralph Castain 2005-03-22 19:56:45 +00:00
родитель 7935e05309
Коммит 875da82a6f
3 изменённых файлов: 151 добавлений и 121 удалений

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

@ -36,7 +36,7 @@ int orte_ns_replica_create_cellid(orte_cellid_t *cellid)
{
OMPI_THREAD_LOCK(&orte_ns_replica_mutex);
if (ORTE_CELLID_MAX < orte_ns_replica_next_cellid) {
if (ORTE_CELLID_MAX > orte_ns_replica_next_cellid) {
*cellid = orte_ns_replica_next_cellid;
orte_ns_replica_next_cellid++;
OMPI_THREAD_UNLOCK(&orte_ns_replica_mutex);

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

@ -152,6 +152,7 @@ orte_rml_tag_t orte_ns_replica_next_rml_tag;
ompi_list_t orte_ns_replica_taglist;
int orte_ns_replica_debug;
ompi_mutex_t orte_ns_replica_mutex;
int orte_ns_replica_isolate;
/*
* don't really need this function - could just put NULL in the above structure
@ -161,9 +162,12 @@ int orte_ns_replica_open(void)
{
int id;
id = mca_base_param_register_int("ns", "replica", "debug", NULL, 0);
id = mca_base_param_register_int("ns", "replica", "debug", NULL, (int)false);
mca_base_param_lookup_int(id, &orte_ns_replica_debug);
id = mca_base_param_register_int("ns", "replica", "isolate", NULL, (int)false);
mca_base_param_lookup_int(id, &orte_ns_replica_isolate);
return ORTE_SUCCESS;
}
@ -228,6 +232,10 @@ mca_ns_base_module_t* orte_ns_replica_init(int *priority)
int orte_ns_replica_module_init(void)
{
if (orte_ns_replica_isolate) {
return ORTE_SUCCESS;
}
/* issue non-blocking receive for call_back function */
return orte_rml.recv_buffer_nb(ORTE_RML_NAME_ANY, ORTE_RML_TAG_NS, 0, orte_ns_replica_recv, NULL);
}
@ -258,6 +266,10 @@ int orte_ns_replica_finalize(void)
}
/* All done */
if (orte_ns_replica_isolate) {
return ORTE_SUCCESS;
}
orte_rml.recv_cancel(ORTE_RML_NAME_ANY, ORTE_RML_TAG_NS);
return ORTE_SUCCESS;
}

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

@ -16,7 +16,7 @@
#include "support.h"
#include "include/orte_constants.h"
#include "util/sys_info.h"
#include "include/orte_schema.h"
#include "util/proc_info.h"
#include "mca/mca.h"
#include "mca/base/base.h"
@ -29,20 +29,12 @@ static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std";
int main(int argc, char **argv)
{
printf("Test test_ns_replica disabled. Does not compile.\n");
return 77;
#if 0
orte_process_name_t *test_name;
orte_process_name_t *procs;
int num_procs;
orte_cellid_t cell;
orte_jobid_t job;
orte_vpid_t vpid;
bool multi, hidden;
int i, j;
int i, j, rc;
char *tmp;
int result; /* result from system call */
test_init("test_ns_replica");
@ -53,12 +45,15 @@ int main(int argc, char **argv)
exit(1);
}
/* ensure orte_process_info struct initialized */
orte_proc_info();
/* 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");
@ -79,7 +74,7 @@ int main(int argc, char **argv)
}
/* startup the name server */
if (OMPI_SUCCESS != orte_ns_base_select(&multi, &hidden)) {
if (OMPI_SUCCESS != orte_ns_base_select()) {
fprintf(test_out, "NS could not start\n");
test_failure("test_ns_replica mca_ns_base_select failed");
test_finalize();
@ -90,129 +85,152 @@ int main(int argc, char **argv)
}
/* create a name */
test_name = orte_ns.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 orte_ns create_process_name failed");
test_finalize();
exit(1);
if (ORTE_SUCCESS != (rc = orte_ns.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: %0X %0X %0X\n",
test_name->cellid, test_name->jobid, test_name->vpid);
test_success();
fprintf(test_out, "got process name: %0X %0X %0X\n", ORTE_NAME_ARGS(test_name));
test_success();
}
/* convert a string to a name */
tmp = strdup("1234.5678.9AEF");
test_name = orte_ns.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 orte_ns convert_string_to_process_name failed");
test_finalize();
exit(1);
if (ORTE_SUCCESS != (rc = orte_ns.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: %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);
fprintf(test_out, "got process name: %0X %0X %0X\n",
ORTE_NAME_ARGS(test_name));
test_success();
}
/* create a cellid */
cell = orte_ns.create_cellid();
if (0 == cell) { /* got error */
test_failure("test_ns_replica orte_ns test create_cellid");
fprintf(test_out, "create cellid: error\n");
test_finalize();
exit(1);
if (ORTE_SUCCESS != (rc = orte_ns.create_cellid(&cell))) { /* 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: %d\n", cell);
test_success();
fprintf(test_out, "cellid created: %d\n", cell);
test_success();
}
for (i=0; i<10; i++) { /* loop through */
/* create jobid */
job = orte_ns.create_jobid();
if (0 == job) { /* got error */
fprintf(test_out, "create jobid: error\n");
test_failure("test_ns_replica orte_ns 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 = orte_ns.reserve_range(job, 250);
if (0 == vpid) { /* got error */
fprintf(test_out, "get range: error\n");
test_failure("test_ns_replica orte_ns reserve_range failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "range reserved: %d\n", vpid);
test_success();
}
/* create a name */
test_name = orte_ns.create_process_name((mca_ns_base_cellid_t)i,
job, vpid);
/* get and print its string values */
tmp = orte_ns.get_proc_name_string(test_name);
fprintf(test_out, "(%d) strings: name - %s\n", i, tmp);
tmp = orte_ns.get_vpid_string(test_name);
fprintf(test_out, "\tvpid: %s\n", tmp);
tmp = orte_ns.get_jobid_string(test_name);
fprintf(test_out, "\tjobid: %s\n", tmp);
tmp = orte_ns.get_cellid_string(test_name);
fprintf(test_out, "\tcellid: %s\n", tmp);
/* get and print its numeric values */
vpid = orte_ns.get_vpid(test_name);
job = orte_ns.get_jobid(test_name);
cell = orte_ns.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);
}
/* create jobid */
if (ORTE_SUCCESS != (rc = orte_ns.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: %d\n", job);
test_success();
}
for (j=0; j<5; j++) { /* loop through several vpid ranges */
/* get range of vpids */
if (ORTE_SUCCESS != (rc = orte_ns.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: %d\n", vpid);
test_success();
}
/* create a name */
if (ORTE_SUCCESS != (rc = orte_ns.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 = orte_ns.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 = orte_ns.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 = orte_ns.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 = orte_ns.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 = orte_ns.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 = orte_ns.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 = orte_ns.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 %0X(%ld) job %0X(%ld) vpid %0x(%ld)\n\n",
i, cell, (long int)cell, job, (long int)job, vpid, (long int)vpid);
}
}
/* check that we can get a name from the environment */
if (NULL != orte_process_info.my_name) { /* clear the name if set */
free(orte_process_info.my_name);
orte_process_info.my_name = NULL;
}
if (ORTE_SUCCESS != orte_ns.set_my_name()) {
fprintf(test_out, "name discovery failed\n");
} else {
fprintf(test_out, "name discovery succeeded: name set to [%d,%d,%d]\n",
ORTE_NAME_ARGS(*orte_process_info.my_name));
}
/* check get peers */
orte_process_info.vpid_start = 0;
orte_process_info.num_procs = 1000;
if (ORTE_SUCCESS != orte_ns.get_peers(&procs, &num_procs)) {
fprintf(test_out, "get peers failed\n");
} else {
fprintf(test_out, "get peers succeeded\n");
}
fclose( test_out );
result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_ns_replica orte_ns get_proc_name_string, etc failed");
}
/* finalize and see if memory cleared */
orte_ns_base_close();
orte_proc_info_finalize();
mca_base_close();
test_finalize();
return(0);
#endif
}