Add unit test for quick put function - not fully ready yet
This commit was SVN r6693.
Этот коммит содержится в:
родитель
9447050dcf
Коммит
63cef99bcd
@ -24,6 +24,8 @@ check_PROGRAMS = \
|
||||
gpr_mem_leaks \
|
||||
gpr_overwrite \
|
||||
gpr_put_get \
|
||||
gpr_quick_put \
|
||||
gpr_quick_triggers \
|
||||
gpr_threads \
|
||||
gpr_triggers
|
||||
|
||||
@ -31,36 +33,56 @@ TESTS =
|
||||
|
||||
gpr_internal_fns_SOURCES = gpr_internal_fns.c
|
||||
gpr_internal_fns_LDADD = \
|
||||
$(top_builddir)/src/libmpi.la \
|
||||
$(top_builddir)/orte/liborte.la \
|
||||
$(top_builddir)/opal/libopal.la \
|
||||
$(top_builddir)/test/support/libsupport.a
|
||||
gpr_internal_fns_DEPENDENCIES = $(gpr_internal_fns_LDADD)
|
||||
|
||||
gpr_mem_leaks_SOURCES = gpr_mem_leaks.c
|
||||
gpr_mem_leaks_LDADD = \
|
||||
$(top_builddir)/src/libmpi.la \
|
||||
$(top_builddir)/orte/liborte.la \
|
||||
$(top_builddir)/opal/libopal.la \
|
||||
$(top_builddir)/test/support/libsupport.a
|
||||
gpr_mem_leaks_DEPENDENCIES = $(gpr_mem_leaks_LDADD)
|
||||
|
||||
gpr_overwrite_SOURCES = gpr_overwrite.c
|
||||
gpr_overwrite_LDADD = \
|
||||
$(top_builddir)/src/libmpi.la \
|
||||
$(top_builddir)/orte/liborte.la \
|
||||
$(top_builddir)/opal/libopal.la \
|
||||
$(top_builddir)/test/support/libsupport.a
|
||||
gpr_overwrite_DEPENDENCIES = $(gpr_overwrite_LDADD)
|
||||
|
||||
gpr_put_get_SOURCES = gpr_put_get.c
|
||||
gpr_put_get_LDADD = \
|
||||
$(top_builddir)/src/libmpi.la \
|
||||
$(top_builddir)/orte/liborte.la \
|
||||
$(top_builddir)/opal/libopal.la \
|
||||
$(top_builddir)/test/support/libsupport.a
|
||||
gpr_put_get_DEPENDENCIES = $(gpr_put_get_LDADD)
|
||||
|
||||
gpr_threads_SOURCES = gpr_threads.c
|
||||
gpr_threads_LDADD = \
|
||||
$(top_builddir)/src/libmpi.la \
|
||||
$(top_builddir)/orte/liborte.la \
|
||||
$(top_builddir)/opal/libopal.la \
|
||||
$(top_builddir)/test/support/libsupport.a
|
||||
gpr_threads_DEPENDENCIES = $(gpr_threads_LDADD)
|
||||
|
||||
gpr_triggers_SOURCES = gpr_triggers.c
|
||||
gpr_triggers_LDADD = \
|
||||
$(top_builddir)/src/libmpi.la \
|
||||
$(top_builddir)/orte/liborte.la \
|
||||
$(top_builddir)/opal/libopal.la \
|
||||
$(top_builddir)/test/support/libsupport.a
|
||||
gpr_triggers_DEPENDENCIES = $(gpr_triggers_LDADD)
|
||||
|
||||
gpr_quick_put_SOURCES = gpr_quick_put.c
|
||||
gpr_quick_put_LDADD = \
|
||||
$(top_builddir)/orte/liborte.la \
|
||||
$(top_builddir)/opal/libopal.la \
|
||||
$(top_builddir)/test/support/libsupport.a
|
||||
gpr_quick_put_DEPENDENCIES = $(gpr_quick_put_LDADD)
|
||||
|
||||
gpr_quick_triggers= gpr_quick_triggers.c
|
||||
gpr_quick_triggers_LDADD = \
|
||||
$(top_builddir)/orte/liborte.la \
|
||||
$(top_builddir)/opal/libopal.la \
|
||||
$(top_builddir)/test/support/libsupport.a
|
||||
gpr_quick_triggers_DEPENDENCIES = $(gpr_quick_triggers_LDADD)
|
||||
|
@ -100,7 +100,7 @@ int main(int argc, char **argv)
|
||||
opal_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
|
||||
|
||||
/* For malloc debugging */
|
||||
ompi_malloc_init();
|
||||
opal_malloc_init();
|
||||
|
||||
/* Ensure the system_info structure is instantiated and initialized */
|
||||
if (ORTE_SUCCESS != (rc = orte_sys_info())) {
|
||||
@ -515,9 +515,9 @@ int main(int argc, char **argv)
|
||||
orte_sys_info_finalize();
|
||||
orte_proc_info_finalize();
|
||||
mca_base_close();
|
||||
ompi_malloc_finalize();
|
||||
opal_malloc_finalize();
|
||||
opal_output_finalize();
|
||||
ompi_class_finalize();
|
||||
opal_class_finalize();
|
||||
|
||||
fclose( test_out );
|
||||
/* result = system( cmd_str );
|
||||
|
235
test/mca/gpr/gpr_quick_put.c
Обычный файл
235
test/mca/gpr/gpr_quick_put.c
Обычный файл
@ -0,0 +1,235 @@
|
||||
/*
|
||||
* 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>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "include/orte_constants.h"
|
||||
#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"
|
||||
|
||||
#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"
|
||||
#include "opal/util/malloc.h"
|
||||
#include "opal/util/output.h"
|
||||
|
||||
#include "mca/gpr/base/base.h"
|
||||
#include "mca/gpr/replica/api_layer/gpr_replica_api.h"
|
||||
#include "mca/gpr/replica/functional_layer/gpr_replica_fn.h"
|
||||
#include "mca/gpr/replica/communications/gpr_replica_comm.h"
|
||||
#include "mca/gpr/replica/transition_layer/gpr_replica_tl.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;
|
||||
char *tokens[5], *keys[5];
|
||||
orte_data_type_t types[5];
|
||||
orte_gpr_value_union_t value, values[5];
|
||||
|
||||
if (getenv("TEST_WRITE_TO_FILE") != NULL) {
|
||||
test_out = fopen( "test_gpr_replica_out", "w+" );
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
tokens[0] = strdup("test-token-1");
|
||||
tokens[1] = strdup("test-token-2");
|
||||
tokens[2] = NULL;
|
||||
value.i32 = 123456;
|
||||
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", ORTE_INT32, value))) {
|
||||
fprintf(test_out, "gpr_test: put of 1 value/1 keyval failed with error code %s\n",
|
||||
ORTE_ERROR_NAME(rc));
|
||||
return rc;
|
||||
} else {
|
||||
fprintf(test_out, "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);
|
||||
types[i] = ORTE_INT16;
|
||||
values[i].i16 = i * 1000;
|
||||
}
|
||||
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, 5,
|
||||
keys, types, values))) {
|
||||
fprintf(test_out, "gpr_test: put 1 value/multiple keyval failed with error code %s\n",
|
||||
ORTE_ERROR_NAME(rc));
|
||||
return rc;
|
||||
} else {
|
||||
fprintf(test_out, "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_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");
|
||||
}
|
||||
*/
|
||||
unlink("test_gpr_replica_out");
|
||||
|
||||
return(0);
|
||||
}
|
Загрузка…
x
Ссылка в новой задаче
Block a user