Skip to content

Commit d544e0e

Browse files
committed
Merge pull request #1347 from ggouaillardet/topic/dss_tests
test/dss: update tests to make them usable again, and run them
2 parents 2a728f3 + 1e26f9c commit d544e0e

File tree

13 files changed

+253
-1892
lines changed

13 files changed

+253
-1892
lines changed

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Copyright (c) 2013 Mellanox Technologies, Inc.
2121
# All rights reserved.
2222
# Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
23-
# Copyright (c) 2014-2015 Research Organization for Information Science
23+
# Copyright (c) 2014-2016 Research Organization for Information Science
2424
# and Technology (RIST). All rights reserved.
2525
# $COPYRIGHT$
2626
#
@@ -1372,6 +1372,7 @@ AC_CONFIG_FILES([
13721372
test/event/Makefile
13731373
test/asm/Makefile
13741374
test/datatype/Makefile
1375+
test/dss/Makefile
13751376
test/class/Makefile
13761377
test/support/Makefile
13771378
test/threads/Makefile

opal/dss/dss_compare.c

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* All rights reserved.
1212
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
1313
* Copyright (c) 2014 Intel, Inc. All rights reserved.
14-
* Copyright (c) 2014 Research Organization for Information Science
14+
* Copyright (c) 2014-2016 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
1616
* $COPYRIGHT$
1717
*
@@ -305,7 +305,64 @@ int opal_dss_compare_node_stat(opal_node_stats_t *value1, opal_node_stats_t *val
305305
/* OPAL_VALUE */
306306
int opal_dss_compare_value(opal_value_t *value1, opal_value_t *value2, opal_data_type_t type)
307307
{
308-
return OPAL_EQUAL; /* eventually compare field to field */
308+
if (NULL == value1 && NULL == value2) {
309+
return OPAL_EQUAL;
310+
}
311+
if (NULL == value2) {
312+
return OPAL_VALUE1_GREATER;
313+
}
314+
if (NULL == value1) {
315+
return OPAL_VALUE2_GREATER;
316+
}
317+
if (value1->type != value2->type) {
318+
opal_output(0, "COMPARE-OPAL-VALUE: INCONSISTENT TYPE %d vs %d", (int)value1->type, (int)value2->type);
319+
return OPAL_EQUAL;
320+
}
321+
switch (value1->type) {
322+
case OPAL_BYTE:
323+
return opal_dss_compare_byte((char *)&value1->data.byte, (char *)&value2->data.byte, type);
324+
case OPAL_STRING:
325+
return opal_dss_compare_string(value1->data.string, value2->data.string, type);
326+
case OPAL_PID:
327+
return opal_dss_compare_pid(&value1->data.pid, &value2->data.pid, type);
328+
case OPAL_INT:
329+
return opal_dss_compare_int(&value1->data.integer, &value2->data.integer, type);
330+
case OPAL_INT8:
331+
return opal_dss_compare_int8(&value1->data.int8, &value2->data.int8, type);
332+
case OPAL_INT16:
333+
return opal_dss_compare_int16(&value1->data.int16, &value2->data.int16, type);
334+
case OPAL_INT32:
335+
return opal_dss_compare_int32(&value1->data.int32, &value2->data.int32, type);
336+
case OPAL_INT64:
337+
return opal_dss_compare_int64(&value1->data.int64, &value2->data.int64, type);
338+
case OPAL_UINT:
339+
return opal_dss_compare_uint(&value1->data.uint, &value2->data.uint, type);
340+
case OPAL_UINT8:
341+
return opal_dss_compare_uint8(&value1->data.uint8, &value2->data.uint8, type);
342+
case OPAL_UINT16:
343+
return opal_dss_compare_uint16(&value1->data.uint16, &value2->data.uint16, type);
344+
case OPAL_UINT32:
345+
return opal_dss_compare_uint32(&value1->data.uint32, &value2->data.uint32, type);
346+
case OPAL_UINT64:
347+
return opal_dss_compare_uint64(&value1->data.uint64, &value2->data.uint64, type);
348+
case OPAL_BYTE_OBJECT:
349+
return opal_dss_compare_byte_object(&value1->data.bo, &value2->data.bo, type);
350+
case OPAL_SIZE:
351+
return opal_dss_compare_size(&value1->data.size, &value2->data.size, type);
352+
case OPAL_FLOAT:
353+
return opal_dss_compare_float(&value1->data.fval, &value2->data.fval, type);
354+
case OPAL_DOUBLE:
355+
return opal_dss_compare_double(&value1->data.dval, &value2->data.dval, type);
356+
case OPAL_BOOL:
357+
return opal_dss_compare_bool(&value1->data.flag, &value2->data.flag, type);
358+
case OPAL_TIMEVAL:
359+
return opal_dss_compare_timeval(&value1->data.tv, &value2->data.tv, type);
360+
case OPAL_NAME:
361+
return opal_dss_compare_name(&value1->data.name, &value2->data.name, type);
362+
default:
363+
opal_output(0, "COMPARE-OPAL-VALUE: UNSUPPORTED TYPE %d", (int)value1->type);
364+
return OPAL_EQUAL;
365+
}
309366
}
310367

311368
/* OPAL_BUFFER */

test/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# All rights reserved.
1212
# Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
1313
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
14-
# Copyright (c) 2015 Research Organization for Information Science
14+
# Copyright (c) 2015-2016 Research Organization for Information Science
1515
# and Technology (RIST). All rights reserved.
1616
# $COPYRIGHT$
1717
#
@@ -21,7 +21,7 @@
2121
#
2222

2323
# support needs to be first for dependencies
24-
SUBDIRS = support asm class threads datatype util
24+
SUBDIRS = support asm class threads datatype util dss
2525
if PROJECT_OMPI
2626
SUBDIRS += monitoring
2727
endif

test/dss/Makefile

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/dss/Makefile.am

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2016 Research Organization for Information Science
2+
# and Technology (RIST). All rights reserved.
3+
# $COPYRIGHT$
4+
#
5+
# Additional copyrights may follow
6+
#
7+
# $HEADER$
8+
#
9+
10+
TESTS = dss_buffer dss_cmp dss_payload dss_print
11+
12+
check_PROGRAMS = $(TESTS) $(MPI_CHECKS)
13+
14+
LDFLAGS = $(OPAL_PKG_CONFIG_LDFLAGS)
15+
LDADD = $(top_builddir)/opal/lib@[email protected]

test/dss/dss_buffer.c

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12+
* Copyright (c) 2016 Research Organization for Information Science
13+
* and Technology (RIST). All rights reserved.
1214
* $COPYRIGHT$
1315
*
1416
* Additional copyrights may follow
@@ -47,11 +49,13 @@ static bool test10(void); /* verify KEYVAL */
4749
static bool test11(void); /* verify int32_t */
4850
static bool test12(void); /* verify pid_t */
4951

50-
FILE *test_out;
52+
static FILE *test_out;
5153

5254

5355
int main (int argc, char* argv[])
5456
{
57+
int ret = 0;
58+
5559
opal_init(&argc, &argv);
5660

5761
test_out = stderr;
@@ -61,104 +65,104 @@ int main (int argc, char* argv[])
6165
fprintf(test_out, "executing test1\n");
6266
if (test1()) {
6367
fprintf(test_out, "Test1 succeeded\n");
64-
}
65-
else {
68+
} else {
6669
fprintf(test_out, "Test1 failed\n");
70+
ret = 1;
6771
}
6872

6973
fprintf(test_out, "executing test2\n");
7074
if (test2()) {
7175
fprintf(test_out, "Test2 succeeded\n");
72-
}
73-
else {
76+
} else {
7477
fprintf(test_out, "Test2 failed\n");
78+
ret = 2;
7579
}
7680

7781
fprintf(test_out, "executing test3\n");
7882
if (test3()) {
7983
fprintf(test_out, "Test3 succeeded\n");
80-
}
81-
else {
84+
} else {
8285
fprintf(test_out, "Test3 failed\n");
86+
ret = 3;
8387
}
8488

8589
fprintf(test_out, "executing test4\n");
8690
if (test4()) {
8791
fprintf(test_out, "Test4 succeeded\n");
88-
}
89-
else {
92+
} else {
9093
fprintf(test_out, "Test4 failed\n");
94+
ret = 4;
9195
}
9296

9397
fprintf(test_out, "executing test5\n");
9498
if (test5()) {
9599
fprintf(test_out, "Test5 succeeded\n");
96-
}
97-
else {
100+
} else {
98101
fprintf(test_out, "Test5 failed\n");
102+
ret = 5;
99103
}
100104

101105
fprintf(test_out, "executing test6\n");
102106
if (test6()) {
103107
fprintf(test_out, "Test6 succeeded\n");
104-
}
105-
else {
108+
} else {
106109
fprintf(test_out, "Test6 failed\n");
110+
ret = 6;
107111
}
108112

109113
fprintf(test_out, "executing test7\n");
110114
if (test7()) {
111115
fprintf(test_out, "Test7 succeeded\n");
112-
}
113-
else {
116+
} else {
114117
fprintf(test_out, "Test7 failed\n");
118+
ret = 7;
115119
}
116120

117121
fprintf(test_out, "executing test8\n");
118122
if (test8()) {
119123
fprintf(test_out, "Test8 succeeded\n");
120-
}
121-
else {
124+
} else {
122125
fprintf(test_out, "Test8 failed\n");
126+
ret = 8;
123127
}
124128

125129
fprintf(test_out, "executing test9\n");
126130
if (test9()) {
127131
fprintf(test_out, "Test9 succeeded\n");
128-
}
129-
else {
132+
} else {
130133
fprintf(test_out, "opal_dss test9 failed\n");
134+
ret = 9;
131135
}
132136

133137
fprintf(test_out, "executing test10\n");
134138
if (test10()) {
135139
fprintf(test_out, "Test10 succeeded\n");
136-
}
137-
else {
140+
} else {
138141
fprintf(test_out, "opal_dss test10 failed\n");
142+
ret = 10;
139143
}
140144

141145
fprintf(test_out, "executing test11\n");
142146
if (test11()) {
143147
fprintf(test_out, "Test11 succeeded\n");
144-
}
145-
else {
148+
} else {
146149
fprintf(test_out, "opal_dss test11 failed\n");
150+
ret = 11;
147151
}
148152

149153
fprintf(test_out, "executing test12\n");
150154
if (test12()) {
151155
fprintf(test_out, "Test12 succeeded\n");
152-
}
153-
else {
156+
} else {
154157
fprintf(test_out, "opal_dss test12 failed\n");
158+
ret = 12;
155159
}
156160

157161
fclose(test_out);
158162

159163
opal_finalize();
160164

161-
return(0);
165+
return ret;
162166
}
163167

164168
static bool test1(void) /* verify different buffer inits */
@@ -199,7 +203,7 @@ static bool test2(void)
199203
return false;
200204
}
201205

202-
opal_dss.set_buffer_type(bufA, OPAL_DSS_BUFFER_NON_DESC);
206+
bufA->type = OPAL_DSS_BUFFER_NON_DESC;
203207

204208
for (i=0;i<NUM_ITERS;i++) {
205209
rc = opal_dss.pack(bufA, src, NUM_ELEMS, OPAL_INT16);
@@ -791,18 +795,18 @@ static bool test10(void)
791795
int rc;
792796
int i;
793797
int16_t i16[NUM_ELEMS];
794-
opal_dss_value_t *src[NUM_ELEMS];
795-
opal_dss_value_t *dst[NUM_ELEMS];
798+
opal_value_t *src[NUM_ELEMS];
799+
opal_value_t *dst[NUM_ELEMS];
796800

797801
/* setup source array of data values */
798802
for(i=0; i<NUM_ELEMS; i++) {
799803
i16[i] = (int16_t)i;
800-
src[i] = OBJ_NEW(opal_dss_value_t);
804+
src[i] = OBJ_NEW(opal_value_t);
801805
src[i]->type = ((i % 2) == 0) ? OPAL_INT16 : OPAL_STRING;
802806
if (OPAL_INT16 == src[i]->type)
803-
src[i]->data = &i16[i];
807+
src[i]->data.uint16 = i16[i];
804808
else
805-
src[i]->data = strdup("truly-a-dumb-test");
809+
src[i]->data.string = strdup("truly-a-dumb-test");
806810
}
807811

808812
bufA = OBJ_NEW(opal_buffer_t);
@@ -812,7 +816,7 @@ static bool test10(void)
812816
}
813817

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

827-
rc = opal_dss.unpack(bufA, dst, &count, OPAL_DATA_VALUE);
831+
rc = opal_dss.unpack(bufA, dst, &count, OPAL_VALUE);
828832
if (OPAL_SUCCESS != rc || count != NUM_ELEMS) {
829833
fprintf(test_out,
830834
"opal_dss.unpack (DATA_VALUE) failed on iteration %d with error code %d\n",

0 commit comments

Comments
 (0)