1
1

Begin to add unit tests for the API layer on ras and rmaps.

Fix a compiler warning on dump.

This commit was SVN r5138.
Этот коммит содержится в:
Ralph Castain 2005-04-01 20:17:49 +00:00
родитель d900d8f137
Коммит 9cbb698ada
7 изменённых файлов: 396 добавлений и 4 удалений

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

@ -1655,7 +1655,9 @@ AC_CONFIG_FILES([
test/mca/gpr/Makefile test/mca/gpr/Makefile
test/mca/ns/Makefile test/mca/ns/Makefile
test/mca/oob/Makefile test/mca/oob/Makefile
test/mca/ras/Makefile
test/mca/rds/Makefile test/mca/rds/Makefile
test/mca/rmaps/Makefile
test/runtime/Makefile test/runtime/Makefile
test/support/Makefile test/support/Makefile
test/threads/Makefile test/threads/Makefile

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

@ -52,7 +52,7 @@ int orte_gpr_replica_dump_all_fn(orte_buffer_t *buffer)
char tmp_out[80], *tmp; char tmp_out[80], *tmp;
int rc; int rc;
tmp = &tmp_out; tmp = tmp_out;
sprintf(tmp_out, "\n\n\nDUMP OF GENERAL PURPOSE REGISTRY"); sprintf(tmp_out, "\n\n\nDUMP OF GENERAL PURPOSE REGISTRY");
orte_gpr_replica_dump_load_string(buffer, &tmp); orte_gpr_replica_dump_load_string(buffer, &tmp);
@ -222,7 +222,7 @@ int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer)
char tmp_out[100], *tmp; char tmp_out[100], *tmp;
int j, k; int j, k;
tmp = &tmp_out; tmp = tmp_out;
sprintf(tmp_out, "\nDUMP OF GPR TRIGGERS\n"); sprintf(tmp_out, "\nDUMP OF GPR TRIGGERS\n");
orte_gpr_replica_dump_load_string(buffer, &tmp); orte_gpr_replica_dump_load_string(buffer, &tmp);
@ -456,7 +456,7 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
{ {
char tmp[132], *tmp2; char tmp[132], *tmp2;
tmp2 = &tmp; tmp2 = tmp;
switch(iptr->type) { switch(iptr->type) {
case ORTE_BYTE: case ORTE_BYTE:

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

@ -16,4 +16,4 @@
include $(top_srcdir)/config/Makefile.options include $(top_srcdir)/config/Makefile.options
SUBDIRS = gpr ns oob rds SUBDIRS = gpr ns oob ras rds rmaps

31
test/mca/ras/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,31 @@
# -*- makefile -*-
#
# 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$
#
include $(top_srcdir)/config/Makefile.options
AM_CPPFLAGS = -I$(top_srcdir)/test/support -DOMPI_ENABLE_DEBUG_OVERRIDE=1
check_PROGRAMS = \
test_ras
TESTS = \
$(check_PROGRAMS)
test_ras_SOURCES = test_ras.c
test_ras_LDADD = \
$(top_builddir)/test/support/libsupport.a \
$(top_builddir)/src/libmpi.la
test_ras_DEPENDENCIES = $(test_ras_LDADD)

164
test/mca/ras/test_ras.c Обычный файл
Просмотреть файл

@ -0,0 +1,164 @@
/*
* unit test for RDS resource file parser
--------------------------------------------------------------------------
Authors: Ralph H. Castain <rhc@lanl.gov>
--------------------------------------------------------------------------
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "include/orte_constants.h"
#include "dps/dps.h"
#include "runtime/runtime.h"
#include "util/proc_info.h"
#include "util/sys_info.h"
#include "mca/gpr/base/base.h"
#include "mca/rds/base/base.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std";
int
main(int argc, char **argv)
{
int rc;
test_init("test_rds_fn");
if (getenv("TEST_WRITE_TO_FILE") != NULL) {
test_out = fopen( "test_rds_fn", "w+" );
} else {
test_out = stderr;
}
if( test_out == NULL ) {
test_failure("rds_fn couldn't open test file failed");
test_finalize();
exit(1);
}
/* ENSURE THE GPR REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* Open up the output streams */
if (!ompi_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads - and reset otherwise.
*/
ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
ompi_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);
}
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(test_out, "GPR started\n");
} else {
fprintf(test_out, "GPR could not start\n");
exit (1);
}
if (ORTE_SUCCESS == orte_gpr_base_select()) {
fprintf(test_out, "GPR replica selected\n");
} else {
fprintf(test_out, "GPR replica could not be selected\n");
exit (1);
}
if (ORTE_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else {
fprintf(test_out, "DPS could not start\n");
exit (1);
}
/* setup the RDS */
if (ORTE_SUCCESS == orte_rds_base_open()) {
fprintf(test_out, "RDS started\n");
} else {
fprintf(test_out, "RDS could not start\n");
exit (1);
}
if (ORTE_SUCCESS == orte_rds_base_select()) {
fprintf(test_out, "RDS selected\n");
} else {
fprintf(test_out, "RDS could not be selected\n");
exit (1);
}
/* run the query */
if (ORTE_SUCCESS != (rc = orte_rds_base_query())) {
fprintf(test_out, "RDS query failed with code %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_rds_fn rds_query failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "RDS query succeeded\n");
test_success();
}
fprintf(stderr, "now finalize and see if all memory cleared\n");
orte_rds_base_close();
orte_dps_close();
orte_gpr_base_close();
orte_sys_info_finalize();
orte_proc_info_finalize();
mca_base_close();
ompi_malloc_finalize();
ompi_output_finalize();
ompi_class_finalize();
fclose( test_out );
/* result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_rds failed");
}
*/
test_finalize();
exit (0);
}

31
test/mca/rmaps/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,31 @@
# -*- makefile -*-
#
# 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$
#
include $(top_srcdir)/config/Makefile.options
AM_CPPFLAGS = -I$(top_srcdir)/test/support -DOMPI_ENABLE_DEBUG_OVERRIDE=1
check_PROGRAMS = \
test_rmaps
TESTS = \
$(check_PROGRAMS)
test_rmaps_SOURCES = test_rmaps.c
test_rmaps_LDADD = \
$(top_builddir)/test/support/libsupport.a \
$(top_builddir)/src/libmpi.la
test_rmaps_DEPENDENCIES = $(test_rmaps_LDADD)

164
test/mca/rmaps/test_rmaps.c Обычный файл
Просмотреть файл

@ -0,0 +1,164 @@
/*
* unit test for RDS resource file parser
--------------------------------------------------------------------------
Authors: Ralph H. Castain <rhc@lanl.gov>
--------------------------------------------------------------------------
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "support.h"
#include "include/orte_constants.h"
#include "dps/dps.h"
#include "runtime/runtime.h"
#include "util/proc_info.h"
#include "util/sys_info.h"
#include "mca/gpr/base/base.h"
#include "mca/rds/base/base.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std";
int
main(int argc, char **argv)
{
int rc;
test_init("test_rds_fn");
if (getenv("TEST_WRITE_TO_FILE") != NULL) {
test_out = fopen( "test_rds_fn", "w+" );
} else {
test_out = stderr;
}
if( test_out == NULL ) {
test_failure("rds_fn couldn't open test file failed");
test_finalize();
exit(1);
}
/* ENSURE THE GPR REPLICA IS ISOLATED */
setenv("OMPI_MCA_gpr_replica_isolate", "1", 1);
/* Open up the output streams */
if (!ompi_output_init()) {
return OMPI_ERROR;
}
/*
* If threads are supported - assume that we are using threads - and reset otherwise.
*/
ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT);
/* For malloc debugging */
ompi_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);
}
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(test_out, "GPR started\n");
} else {
fprintf(test_out, "GPR could not start\n");
exit (1);
}
if (ORTE_SUCCESS == orte_gpr_base_select()) {
fprintf(test_out, "GPR replica selected\n");
} else {
fprintf(test_out, "GPR replica could not be selected\n");
exit (1);
}
if (ORTE_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else {
fprintf(test_out, "DPS could not start\n");
exit (1);
}
/* setup the RDS */
if (ORTE_SUCCESS == orte_rds_base_open()) {
fprintf(test_out, "RDS started\n");
} else {
fprintf(test_out, "RDS could not start\n");
exit (1);
}
if (ORTE_SUCCESS == orte_rds_base_select()) {
fprintf(test_out, "RDS selected\n");
} else {
fprintf(test_out, "RDS could not be selected\n");
exit (1);
}
/* run the query */
if (ORTE_SUCCESS != (rc = orte_rds_base_query())) {
fprintf(test_out, "RDS query failed with code %s\n",
ORTE_ERROR_NAME(rc));
test_failure("test_rds_fn rds_query failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "RDS query succeeded\n");
test_success();
}
fprintf(stderr, "now finalize and see if all memory cleared\n");
orte_rds_base_close();
orte_dps_close();
orte_gpr_base_close();
orte_sys_info_finalize();
orte_proc_info_finalize();
mca_base_close();
ompi_malloc_finalize();
ompi_output_finalize();
ompi_class_finalize();
fclose( test_out );
/* result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_rds failed");
}
*/
test_finalize();
exit (0);
}