1
1

Remove duplicate tests. The current version of the dss tests are in orte/test/unit/dss

Remove defunct testing matrix

This commit was SVN r15535.
Этот коммит содержится в:
Tim Prins 2007-07-20 13:37:44 +00:00
родитель 1751b289ed
Коммит 7445a11f61
11 изменённых файлов: 0 добавлений и 5419 удалений

Двоичные данные
test/Unit-Test-Status.pdf

Двоичный файл не отображается.

Двоичные данные
test/Unit-Test-Status.xls

Двоичный файл не отображается.

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

@ -1,78 +0,0 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. 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$
#
check_PROGRAMS = \
dss_buffer \
dss_copy \
dss_set_get \
dss_inc_dec \
dss_cmp \
dss_release \
dss_size \
dss_print
TESTS = \
$(check_PROGRAMS)
dss_buffer_SOURCES = dss_buffer.c
dss_buffer_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
dss_buffer_DEPENDENCIES = $(dss_buffer_LDADD)
dss_copy_SOURCES = dss_copy.c
dss_copy_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
dss_copy_DEPENDENCIES = $(dss_copy_LDADD)
dss_set_get_SOURCES = dss_set_get.c
dss_set_get_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
dss_set_get_DEPENDENCIES = $(dss_set_get_LDADD)
dss_inc_dec_SOURCES = dss_inc_dec.c
dss_inc_dec_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
dss_inc_dec_DEPENDENCIES = $(dss_inc_dec_LDADD)
dss_cmp_SOURCES = dss_cmp.c
dss_cmp_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
dss_cmp_DEPENDENCIES = $(dss_cmp_LDADD)
dss_release_SOURCES = dss_release.c
dss_release_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
dss_release_DEPENDENCIES = $(dss_release_LDADD)
dss_size_SOURCES = dss_size.c
dss_size_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
dss_size_DEPENDENCIES = $(dss_size_LDADD)
dss_print_SOURCES = dss_print.c
dss_print_LDADD = \
$(top_builddir)/orte/libopen-rte.la \
$(top_builddir)/opal/libopen-pal.la
dss_print_DEPENDENCIES = $(dss_print_LDADD)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,688 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. 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 "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
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;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t v1, v2=100;
uint8_t u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t v1, v2=100;
uint16_t u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t v1, v2=100;
uint32_t u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t v1, v2=100;
uint64_t u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int v1, v2=100;
uint u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
char *string2="This is a longer string";
if (ORTE_EQUAL != orte_dss.compare(string1, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
if (ORTE_VALUE2_GREATER != orte_dss.compare(string1, string2, ORTE_STRING)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
if (ORTE_VALUE1_GREATER != orte_dss.compare(string2, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool v1, v2=true;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = true;
v2 = false;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = false;
v2 = true;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t v1, v2=100;
orte_data_type_t type=ORTE_PID;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t v1, v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
v1.size = 20;
v1.bytes = (uint8_t*)malloc(v1.size);
for (i=0; i<v1.size; i++) v1.bytes[i] = i;
v2.size = v1.size;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = v1.bytes[i];
v2.bytes[(v2.size)/2] += 1;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v1, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v2, &v1, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat1=100, dat2=200;
orte_data_value_t v1, v2;
orte_data_type_t type=ORTE_DATA_VALUE;
v1.type = ORTE_INT;
v1.data = &dat1;
v2.type = ORTE_INT;
v2.data = &dat2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v1, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v2, &v1, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}

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

@ -1,530 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. 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 "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
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;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t *v1, v2=100;
uint8_t *u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t *v1, v2=100;
uint16_t *u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t *v1, v2=100;
uint32_t *u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t *v1, v2=100;
uint64_t *u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int *v1, v2=100;
uint *u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
char *string2;
if (ORTE_EQUAL != orte_dss.copy((void**)&string2, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.copy returned error code\n");
return(false);
}
if (0 != strcmp(string1, string2)) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool *v1, v2=true;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t *v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t *v1, v2=100;
orte_data_type_t type=ORTE_PID;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t *v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t *v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t *v1, v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i]=i;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (v1->size != v2.size) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
for (i=0; i < v2.size; i++) {
if (v1->bytes[i] != v2.bytes[i]) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
}
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat2=200;
orte_data_value_t *v1, v2;
orte_data_type_t type=ORTE_DATA_VALUE;
v2.type = ORTE_INT;
v2.data = &dat2;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}

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

@ -1,689 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. 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 "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
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;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t v1, v2=100;
uint8_t u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t v1, v2=100;
uint16_t u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t v1, v2=100;
uint32_t u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t v1, v2=100;
uint64_t u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int v1, v2=100;
uint u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
orte_data_value_t dv;
dv.type = ORTE_STRING;
dv.data = string1;
if (ORTE_ERR_OPERATION_UNSUPPORTED != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment failed to return correct error\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool v2=true;
orte_data_value_t dv;
dv.type = ORTE_BOOL;
dv.data = &v2;
if (ORTE_ERR_OPERATION_UNSUPPORTED != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment failed to return correct error\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for size value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for size value\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t v1, v2=100;
orte_data_type_t type=ORTE_PID;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for pid value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for pid value\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for daemon cmd value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for daemon cmd value\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for data type value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for data type value\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t v2;
orte_data_value_t dv;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = i;
dv.type = ORTE_BYTE_OBJECT;
dv.data = &v2;
if (ORTE_ERR_OPERATION_UNSUPPORTED != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment failed to return correct error\n");
return(false);
}
return (true);
}

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

@ -1,572 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. 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 "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
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;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t v2=-100;
uint8_t u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t v2=-100;
uint16_t u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t v2=-100;
uint32_t u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t v2=-100;
uint64_t u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int v2=-100;
uint u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for string: %s\n", output);
free(output);
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool v2=true;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for bool: %s\n", output);
free(output);
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t v2=100;
orte_data_type_t type=ORTE_SIZE;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for size: %s\n", output);
free(output);
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t v2=100;
orte_data_type_t type=ORTE_PID;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for pid: %s\n", output);
free(output);
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for daemon cmd: %s\n", output);
free(output);
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for data type: %s\n", output);
free(output);
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
char *output;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = i;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for byte object: %s\n", output);
free(output);
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat2=200;
orte_data_value_t v2;
orte_data_type_t type=ORTE_DATA_VALUE;
char *output;
v2.type = ORTE_INT;
v2.data = &dat2;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for data value: %s\n", output);
free(output);
return (true);
}

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

@ -1,582 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. 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 "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
orte_data_value_t dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
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;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t *v1, v2=100;
uint8_t *u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_INT8;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_UINT8;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t *v1, v2=100;
uint16_t *u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_INT16;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_UINT16;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t *v1, v2=100;
uint32_t *u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_INT32;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_UINT32;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t *v1, v2=100;
uint64_t *u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_UINT64;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int *v1, v2=100;
uint *u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = utype;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
char *string2;
if (ORTE_EQUAL != orte_dss.copy((void**)&string2, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.copy returned error code\n");
return(false);
}
dval.type = ORTE_STRING;
dval.data = string2;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for string value\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool *v1, v2=true;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_BOOL;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for bool value\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t *v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for size value\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t *v1, v2=100;
orte_data_type_t type=ORTE_PID;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for pid value\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t *v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for daemon_cmd value\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t *v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for data_type value\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t *v1, v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i]= i;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for byte_object value\n");
return(false);
}
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat2=200;
orte_data_value_t *v1, v2;
orte_data_type_t type=ORTE_DATA_VALUE;
v2.type = ORTE_INT;
v2.data = &dat2;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for data_value value\n");
return(false);
}
return (true);
}

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

@ -1,574 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. 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 "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
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;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t *v1, v2=100;
uint8_t *u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t *v1, v2=100;
uint16_t *u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t *v1, v2=100;
uint32_t *u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t *v1, v2=100;
uint64_t *u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int *v1, v2=100;
uint *u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string", *string2;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&string2, &dv, ORTE_STRING)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (0 != strcmp(string1, string2)) {
fprintf(test_out, "orte_dss.get/set failed for string value\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool *v1, v2=true;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for bool value\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t *v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for size value\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t *v1, v2=100;
orte_data_type_t type=ORTE_PID;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for pid value\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t *v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for daemon cmd value\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t *v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for data type value\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t v2, *v1;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = i;
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, ORTE_BYTE_OBJECT)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, ORTE_BYTE_OBJECT)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (0 != orte_dss.compare(v1, &v2, ORTE_BYTE_OBJECT)) {
fprintf(test_out, "orte_dss.get/set failed for byte object value\n");
return(false);
}
return (true);
}

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

@ -1,702 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. 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 "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
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;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t v1;
uint8_t u1;
size_t s;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t v1;
uint16_t u1;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t v1;
uint32_t u1;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t v1;
uint64_t u1;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int v1;
uint u1;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != strlen(string1)+1) {
fprintf(test_out, "orte_dss.size failed for string\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, ORTE_STRING)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(string1)) {
fprintf(test_out, "orte_dss.size failed for string with NULL\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool v1;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for bool");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for bool with NULL\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t v1;
orte_data_type_t type=ORTE_SIZE;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for size with NULL\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t v1;
orte_data_type_t type=ORTE_PID;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for pid\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for pid with NULL\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t v1;
orte_data_type_t type=ORTE_DAEMON_CMD;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for daemon cmd\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for daemon cmd with NULL\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t v1;
orte_data_type_t type=ORTE_DATA_TYPE;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for data type\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for data type with NULL\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i, ts;
orte_byte_object_t v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
size_t s;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = i;
ts = sizeof(v2) + 20*sizeof(uint8_t);
if (ORTE_SUCCESS != orte_dss.size(&s, &v2, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != ts) {
fprintf(test_out, "orte_dss.size failed for byte object\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v2)) {
fprintf(test_out, "orte_dss.size failed for byte object with NULL\n");
return(false);
}
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat2=200;
orte_data_value_t v2;
orte_data_type_t type=ORTE_DATA_VALUE;
size_t s, ts;
v2.type = ORTE_INT;
v2.data = &dat2;
ts = sizeof(v2) + sizeof(int);
if (ORTE_SUCCESS != orte_dss.size(&s, &v2, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != ts) {
fprintf(test_out, "orte_dss.size failed for data value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v2)) {
fprintf(test_out, "orte_dss.size failed for data value with NULL\n");
return(false);
}
return (true);
}