Skip to content

Commit

Permalink
Merge pull request #1347 from ggouaillardet/topic/dss_tests
Browse files Browse the repository at this point in the history
test/dss: update tests to make them usable again, and run them
  • Loading branch information
jsquyres committed Feb 17, 2016
2 parents 2a728f3 + 1e26f9c commit d544e0e
Show file tree
Hide file tree
Showing 13 changed files with 253 additions and 1,892 deletions.
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Copyright (c) 2013 Mellanox Technologies, Inc.
# All rights reserved.
# Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
# Copyright (c) 2014-2015 Research Organization for Information Science
# Copyright (c) 2014-2016 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# $COPYRIGHT$
#
Expand Down Expand Up @@ -1372,6 +1372,7 @@ AC_CONFIG_FILES([
test/event/Makefile
test/asm/Makefile
test/datatype/Makefile
test/dss/Makefile
test/class/Makefile
test/support/Makefile
test/threads/Makefile
Expand Down
61 changes: 59 additions & 2 deletions opal/dss/dss_compare.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* Copyright (c) 2014-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -305,7 +305,64 @@ int opal_dss_compare_node_stat(opal_node_stats_t *value1, opal_node_stats_t *val
/* OPAL_VALUE */
int opal_dss_compare_value(opal_value_t *value1, opal_value_t *value2, opal_data_type_t type)
{
return OPAL_EQUAL; /* eventually compare field to field */
if (NULL == value1 && NULL == value2) {
return OPAL_EQUAL;
}
if (NULL == value2) {
return OPAL_VALUE1_GREATER;
}
if (NULL == value1) {
return OPAL_VALUE2_GREATER;
}
if (value1->type != value2->type) {
opal_output(0, "COMPARE-OPAL-VALUE: INCONSISTENT TYPE %d vs %d", (int)value1->type, (int)value2->type);
return OPAL_EQUAL;
}
switch (value1->type) {
case OPAL_BYTE:
return opal_dss_compare_byte((char *)&value1->data.byte, (char *)&value2->data.byte, type);
case OPAL_STRING:
return opal_dss_compare_string(value1->data.string, value2->data.string, type);
case OPAL_PID:
return opal_dss_compare_pid(&value1->data.pid, &value2->data.pid, type);
case OPAL_INT:
return opal_dss_compare_int(&value1->data.integer, &value2->data.integer, type);
case OPAL_INT8:
return opal_dss_compare_int8(&value1->data.int8, &value2->data.int8, type);
case OPAL_INT16:
return opal_dss_compare_int16(&value1->data.int16, &value2->data.int16, type);
case OPAL_INT32:
return opal_dss_compare_int32(&value1->data.int32, &value2->data.int32, type);
case OPAL_INT64:
return opal_dss_compare_int64(&value1->data.int64, &value2->data.int64, type);
case OPAL_UINT:
return opal_dss_compare_uint(&value1->data.uint, &value2->data.uint, type);
case OPAL_UINT8:
return opal_dss_compare_uint8(&value1->data.uint8, &value2->data.uint8, type);
case OPAL_UINT16:
return opal_dss_compare_uint16(&value1->data.uint16, &value2->data.uint16, type);
case OPAL_UINT32:
return opal_dss_compare_uint32(&value1->data.uint32, &value2->data.uint32, type);
case OPAL_UINT64:
return opal_dss_compare_uint64(&value1->data.uint64, &value2->data.uint64, type);
case OPAL_BYTE_OBJECT:
return opal_dss_compare_byte_object(&value1->data.bo, &value2->data.bo, type);
case OPAL_SIZE:
return opal_dss_compare_size(&value1->data.size, &value2->data.size, type);
case OPAL_FLOAT:
return opal_dss_compare_float(&value1->data.fval, &value2->data.fval, type);
case OPAL_DOUBLE:
return opal_dss_compare_double(&value1->data.dval, &value2->data.dval, type);
case OPAL_BOOL:
return opal_dss_compare_bool(&value1->data.flag, &value2->data.flag, type);
case OPAL_TIMEVAL:
return opal_dss_compare_timeval(&value1->data.tv, &value2->data.tv, type);
case OPAL_NAME:
return opal_dss_compare_name(&value1->data.name, &value2->data.name, type);
default:
opal_output(0, "COMPARE-OPAL-VALUE: UNSUPPORTED TYPE %d", (int)value1->type);
return OPAL_EQUAL;
}
}

/* OPAL_BUFFER */
Expand Down
4 changes: 2 additions & 2 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# All rights reserved.
# Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2015 Research Organization for Information Science
# Copyright (c) 2015-2016 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# $COPYRIGHT$
#
Expand All @@ -21,7 +21,7 @@
#

# support needs to be first for dependencies
SUBDIRS = support asm class threads datatype util
SUBDIRS = support asm class threads datatype util dss
if PROJECT_OMPI
SUBDIRS += monitoring
endif
Expand Down
9 changes: 0 additions & 9 deletions test/dss/Makefile

This file was deleted.

15 changes: 15 additions & 0 deletions test/dss/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2016 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

TESTS = dss_buffer dss_cmp dss_payload dss_print

check_PROGRAMS = $(TESTS) $(MPI_CHECKS)

LDFLAGS = $(OPAL_PKG_CONFIG_LDFLAGS)
LDADD = $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la
72 changes: 38 additions & 34 deletions test/dss/dss_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -47,11 +49,13 @@ static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify int32_t */
static bool test12(void); /* verify pid_t */

FILE *test_out;
static FILE *test_out;


int main (int argc, char* argv[])
{
int ret = 0;

opal_init(&argc, &argv);

test_out = stderr;
Expand All @@ -61,104 +65,104 @@ int main (int argc, char* argv[])
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
} else {
fprintf(test_out, "Test1 failed\n");
ret = 1;
}

fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
} else {
fprintf(test_out, "Test2 failed\n");
ret = 2;
}

fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
} else {
fprintf(test_out, "Test3 failed\n");
ret = 3;
}

fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
} else {
fprintf(test_out, "Test4 failed\n");
ret = 4;
}

fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
} else {
fprintf(test_out, "Test5 failed\n");
ret = 5;
}

fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
} else {
fprintf(test_out, "Test6 failed\n");
ret = 6;
}

fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
} else {
fprintf(test_out, "Test7 failed\n");
ret = 7;
}

fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
} else {
fprintf(test_out, "Test8 failed\n");
ret = 8;
}

fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
} else {
fprintf(test_out, "opal_dss test9 failed\n");
ret = 9;
}

fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
} else {
fprintf(test_out, "opal_dss test10 failed\n");
ret = 10;
}

fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
} else {
fprintf(test_out, "opal_dss test11 failed\n");
ret = 11;
}

fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
} else {
fprintf(test_out, "opal_dss test12 failed\n");
ret = 12;
}

fclose(test_out);

opal_finalize();

return(0);
return ret;
}

static bool test1(void) /* verify different buffer inits */
Expand Down Expand Up @@ -199,7 +203,7 @@ static bool test2(void)
return false;
}

opal_dss.set_buffer_type(bufA, OPAL_DSS_BUFFER_NON_DESC);
bufA->type = OPAL_DSS_BUFFER_NON_DESC;

for (i=0;i<NUM_ITERS;i++) {
rc = opal_dss.pack(bufA, src, NUM_ELEMS, OPAL_INT16);
Expand Down Expand Up @@ -791,18 +795,18 @@ static bool test10(void)
int rc;
int i;
int16_t i16[NUM_ELEMS];
opal_dss_value_t *src[NUM_ELEMS];
opal_dss_value_t *dst[NUM_ELEMS];
opal_value_t *src[NUM_ELEMS];
opal_value_t *dst[NUM_ELEMS];

/* setup source array of data values */
for(i=0; i<NUM_ELEMS; i++) {
i16[i] = (int16_t)i;
src[i] = OBJ_NEW(opal_dss_value_t);
src[i] = OBJ_NEW(opal_value_t);
src[i]->type = ((i % 2) == 0) ? OPAL_INT16 : OPAL_STRING;
if (OPAL_INT16 == src[i]->type)
src[i]->data = &i16[i];
src[i]->data.uint16 = i16[i];
else
src[i]->data = strdup("truly-a-dumb-test");
src[i]->data.string = strdup("truly-a-dumb-test");
}

bufA = OBJ_NEW(opal_buffer_t);
Expand All @@ -812,7 +816,7 @@ static bool test10(void)
}

for (i=0;i<NUM_ITERS;i++) {
rc = opal_dss.pack(bufA, src, NUM_ELEMS, OPAL_DATA_VALUE);
rc = opal_dss.pack(bufA, src, NUM_ELEMS, OPAL_VALUE);
if (OPAL_SUCCESS != rc) {
fprintf(test_out, "opal_dss.pack failed with error code %d\n", rc);
return(false);
Expand All @@ -824,7 +828,7 @@ static bool test10(void)
int32_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));

rc = opal_dss.unpack(bufA, dst, &count, OPAL_DATA_VALUE);
rc = opal_dss.unpack(bufA, dst, &count, OPAL_VALUE);
if (OPAL_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out,
"opal_dss.unpack (DATA_VALUE) failed on iteration %d with error code %d\n",
Expand Down
Loading

0 comments on commit d544e0e

Please sign in to comment.