1
1

Complete updating of tests to reflect new functionality.

This commit was SVN r2249.
Этот коммит содержится в:
Ralph Castain 2004-08-20 13:59:34 +00:00
родитель c67b2a9bdb
Коммит b64dc67d7a
3 изменённых файлов: 217 добавлений и 59 удалений

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

@ -215,7 +215,7 @@ ompi_list_t* gpr_replica_index(char *segment)
if (NULL == seg) { /* segment not found */ if (NULL == seg) { /* segment not found */
return answer; return answer;
} }
/* got segment - now find specified token-key pair in that dictionary */ /* got segment - now index that dictionary */
for (ptr = (mca_gpr_keytable_t*)ompi_list_get_first(&seg->keytable); for (ptr = (mca_gpr_keytable_t*)ompi_list_get_first(&seg->keytable);
ptr != (mca_gpr_keytable_t*)ompi_list_get_end(&seg->keytable); ptr != (mca_gpr_keytable_t*)ompi_list_get_end(&seg->keytable);
ptr = (mca_gpr_keytable_t*)ompi_list_get_next(ptr)) { ptr = (mca_gpr_keytable_t*)ompi_list_get_next(ptr)) {
@ -233,13 +233,13 @@ int gpr_replica_subscribe(ompi_process_name_t *caller, ompi_registry_mode_t mode
ompi_registry_notify_action_t action, ompi_registry_notify_action_t action,
char *segment, char **tokens) char *segment, char **tokens)
{ {
return 0; return OMPI_ERR_NOT_IMPLEMENTED;
} }
int gpr_replica_unsubscribe(ompi_process_name_t *caller, ompi_registry_mode_t mode, int gpr_replica_unsubscribe(ompi_process_name_t *caller, ompi_registry_mode_t mode,
char *segment, char **tokens) char *segment, char **tokens)
{ {
return 0; return OMPI_ERR_NOT_IMPLEMENTED;
} }
ompi_list_t* gpr_replica_get(ompi_registry_mode_t mode, ompi_list_t* gpr_replica_get(ompi_registry_mode_t mode,

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

@ -150,38 +150,61 @@ int exec_client(int argc, char** argv)
int run_test() int run_test()
{ {
mca_gpr_replica_key_t test_key, test_key2;
ompi_list_t *test_list, *internal_tests; ompi_list_t *test_list, *internal_tests;
ompi_registry_index_value_t *ptr; ompi_registry_index_value_t *ptr;
ompi_registry_internal_test_results_t *ptri; ompi_registry_internal_test_results_t *ptri;
ompi_registry_object_t *test_buffer; ompi_registry_object_t test_buffer;
uint8_t *test_buf; uint8_t *test_buf;
ompi_registry_object_size_t input_size; ompi_registry_object_size_t input_size;
ompi_registry_mode_t mode; ompi_registry_mode_t mode;
ompi_list_t *answer;
ompi_registry_value_t *ans;
bool multi, hidden; bool multi, hidden;
int i, j; int i, j;
bool success; bool success;
char *tmp; char name[30], *name2[30], *name3[30];
char name[30], *name2[30]; int put_test; /* result from system call */
int result, put_test; /* result from system call */
/* check index */ test_init("test_gpr_replica");
test_list = ompi_registry.index(NULL);
if (0 == ompi_list_get_size(test_list)) { /* should have been something in dictionary */ test_out = fopen( "test_gpr_replica_out", "w+" );
fprintf(test_out, "GPR replica: index function failed\n"); if( test_out == NULL ) {
test_failure("test_gpr_replica index_global_dictionary failed\n"); test_failure("test_gpr_replica couldn't open test file failed");
test_finalize(); test_finalize();
exit(1); exit(1);
}
ompi_process_info.seed = true;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else { } else {
fprintf(test_out, "GPR index returned list\n"); fprintf(test_out, "MCA could not start - please report error to bugs@open-mpi.org\n");
for (ptr = (ompi_registry_index_value_t*)ompi_list_get_first(test_list); exit (1);
ptr != (ompi_registry_index_value_t*)ompi_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)ompi_list_get_next(ptr)) {
fprintf(test_out, "\t%s\n", ptr->token);
}
test_success();
} }
/* 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 */ /* check internals */
internal_tests = ompi_registry.test_internals(1); internal_tests = ompi_registry.test_internals(1);
@ -201,21 +224,45 @@ int run_test()
test_success(); test_success();
} }
/* check index */
test_list = ompi_registry.index(NULL);
if (0 == ompi_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*)ompi_list_get_first(test_list);
ptr != (ompi_registry_index_value_t*)ompi_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)ompi_list_get_next(ptr)) {
fprintf(test_out, "\t%s\n", ptr->token);
}
test_success();
}
/* test the put function */ /* test the put function */
success = true; success = true;
input_size = 10000; input_size = 10000;
test_buffer = (ompi_registry_object_t*)malloc(input_size); test_buffer = (ompi_registry_object_t)malloc(input_size);
test_buf = (uint8_t*)test_buffer; test_buf = (uint8_t*)test_buffer;
for (i=0; i<input_size; i++) { for (i=0; i<input_size; i++) {
*test_buf = i % 256; *test_buf = i % 256;
test_buf++; 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++) { for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i); sprintf(name, "test-def-seg%d", i);
for (j=0; j<10 && success; j++) {
asprintf(&name2[j], "test-key%d", j);
}
name2[j] = NULL;
if (OMPI_SUCCESS != ompi_registry.put(OMPI_REGISTRY_NONE, name, if (OMPI_SUCCESS != ompi_registry.put(OMPI_REGISTRY_NONE, name,
name2, test_buffer, input_size)) { name2, test_buffer, input_size)) {
fprintf(test_out, "put test failed for segment %s\n", name); fprintf(test_out, "put test failed for segment %s\n", name);
@ -236,12 +283,9 @@ int run_test()
} }
/* test the put overwrite function */ /* test the put overwrite function */
success = true;
for (i=0; i<5 && success; i++) { for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i); sprintf(name, "test-def-seg%d", i);
for (j=0; j<10 && success; j++) {
asprintf(&name2[j], "test-key%d", j);
}
name2[j] = NULL;
if (10 % i) { if (10 % i) {
mode = OMPI_REGISTRY_OVERWRITE; mode = OMPI_REGISTRY_OVERWRITE;
} else { } else {
@ -267,6 +311,83 @@ int run_test()
exit(1); 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*)ompi_list_get_first(answer);
ans != (ompi_registry_value_t*)ompi_list_get_end(answer);
ans = (ompi_registry_value_t*)ompi_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 < ompi_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 == ompi_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*)ompi_list_get_first(test_list);
ptr != (ompi_registry_index_value_t*)ompi_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)ompi_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" */ /* check the universe segment - should have a key value of "1" */
fclose( test_out ); fclose( test_out );
@ -279,5 +400,6 @@ int run_test()
} }
*/ */
test_finalize(); test_finalize();
return(0); return(0);
} }

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

@ -31,7 +31,6 @@ static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std";
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
mca_gpr_replica_key_t test_key, test_key2;
ompi_list_t *test_list, *internal_tests; ompi_list_t *test_list, *internal_tests;
ompi_registry_index_value_t *ptr; ompi_registry_index_value_t *ptr;
ompi_registry_internal_test_results_t *ptri; ompi_registry_internal_test_results_t *ptri;
@ -42,11 +41,10 @@ int main(int argc, char **argv)
ompi_list_t *answer; ompi_list_t *answer;
ompi_registry_value_t *ans; ompi_registry_value_t *ans;
bool multi, hidden; bool multi, hidden;
int i, j, response; int i, j;
bool success; bool success;
char *tmp;
char name[30], *name2[30], *name3[30]; char name[30], *name2[30], *name3[30];
int result, put_test; /* result from system call */ int put_test; /* result from system call */
test_init("test_gpr_replica"); test_init("test_gpr_replica");
@ -67,7 +65,6 @@ int main(int argc, char **argv)
exit (1); exit (1);
} }
fprintf(stderr, "opening gpr base\n");
/* open the GPR */ /* open the GPR */
if (OMPI_SUCCESS == mca_gpr_base_open()) { if (OMPI_SUCCESS == mca_gpr_base_open()) {
fprintf(test_out, "GPR opened\n"); fprintf(test_out, "GPR opened\n");
@ -79,7 +76,6 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
fprintf(stderr, "selecting gpr module\n");
/* startup the GPR replica */ /* startup the GPR replica */
if (OMPI_SUCCESS != mca_gpr_base_select(&multi, &hidden)) { if (OMPI_SUCCESS != mca_gpr_base_select(&multi, &hidden)) {
fprintf(test_out, "GPR replica could not start\n"); fprintf(test_out, "GPR replica could not start\n");
@ -91,25 +87,6 @@ int main(int argc, char **argv)
test_success(); test_success();
} }
fprintf(stderr, "testing get index\n");
/* check index */
test_list = ompi_registry.index(NULL);
if (0 == ompi_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*)ompi_list_get_first(test_list);
ptr != (ompi_registry_index_value_t*)ompi_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)ompi_list_get_next(ptr)) {
fprintf(test_out, "\t%s\n", ptr->token);
}
test_success();
}
fprintf(stderr, "testing internals\n");
/* check internals */ /* check internals */
internal_tests = ompi_registry.test_internals(1); internal_tests = ompi_registry.test_internals(1);
if (0 == ompi_list_get_size(internal_tests)) { /* should have been something in list */ if (0 == ompi_list_get_size(internal_tests)) { /* should have been something in list */
@ -128,8 +105,24 @@ int main(int argc, char **argv)
test_success(); test_success();
} }
/* check index */
test_list = ompi_registry.index(NULL);
if (0 == ompi_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*)ompi_list_get_first(test_list);
ptr != (ompi_registry_index_value_t*)ompi_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)ompi_list_get_next(ptr)) {
fprintf(test_out, "\t%s\n", ptr->token);
}
test_success();
}
fprintf(stderr, "testing put\n");
/* test the put function */ /* test the put function */
success = true; success = true;
input_size = 10000; input_size = 10000;
@ -151,7 +144,6 @@ int main(int argc, char **argv)
for (i=0; i<5 && success; i++) { for (i=0; i<5 && success; i++) {
sprintf(name, "test-def-seg%d", i); sprintf(name, "test-def-seg%d", i);
fprintf(stderr, "testing seg %d\n", i);
if (OMPI_SUCCESS != ompi_registry.put(OMPI_REGISTRY_NONE, name, if (OMPI_SUCCESS != ompi_registry.put(OMPI_REGISTRY_NONE, name,
name2, test_buffer, input_size)) { name2, test_buffer, input_size)) {
fprintf(test_out, "put test failed for segment %s\n", name); fprintf(test_out, "put test failed for segment %s\n", name);
@ -200,7 +192,6 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
fprintf(stderr, "testing get\n");
/* test the get function */ /* test the get function */
success = true; success = true;
for (i=0; i<5 && success; i++) { for (i=0; i<5 && success; i++) {
@ -233,6 +224,51 @@ int main(int argc, char **argv)
exit(1); 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 == ompi_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*)ompi_list_get_first(test_list);
ptr != (ompi_registry_index_value_t*)ompi_list_get_end(test_list);
ptr = (ompi_registry_index_value_t*)ompi_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" */ /* check the universe segment - should have a key value of "1" */
fclose( test_out ); fclose( test_out );