2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
14 * Additional copyrights may follow
19 #include "orte_config.h"
20 #include "orte/orte_constants.h"
21 #include "orte/orte_types.h"
27 #ifdef HAVE_SYS_PARAM_H
28 #include <sys/param.h>
30 #ifdef HAVE_NETINET_IN_H
31 #include <netinet/in.h>
34 #include "opal/runtime/opal.h"
35 #include "orte/util/proc_info.h"
36 #include "orte/mca/errmgr/errmgr.h"
38 #include "orte/dss/dss.h"
43 static bool test1(void); /* verify different buffer inits */
44 static bool test2(void); /* verify int16 */
45 static bool test3(void); /* verify int */
46 static bool test4(void); /* verify int32 */
47 static bool test5(void); /* verify int64 */
48 static bool test6(void); /* verify string */
49 static bool test7(void); /* verify BOOL */
50 static bool test8(void); /* verify OBJECT */
51 static bool test9(void); /* verify composite (multiple types and element counts) */
52 static bool test10(void); /* verify KEYVAL */
53 static bool test11(void); /* verify size_t */
54 static bool test12(void); /* verify pid_t */
59 int main (int argc
, char* argv
[])
65 /* register handler for errnum -> string converstion */
66 opal_error_register("ORTE", ORTE_ERR_BASE
, ORTE_ERR_MAX
, orte_err2str
);
70 /* Ensure the process info structure is instantiated and initialized */
71 if (ORTE_SUCCESS
!= (ret
= orte_proc_info())) {
75 orte_process_info
.seed
= true;
76 orte_process_info
.my_name
= (orte_process_name_t
*)malloc(sizeof(orte_process_name_t
));
77 orte_process_info
.my_name
->cellid
= 0;
78 orte_process_info
.my_name
->jobid
= 0;
79 orte_process_info
.my_name
->vpid
= 0;
83 if (ORTE_SUCCESS
== orte_dss_open()) {
84 fprintf(test_out
, "DSS started\n");
86 fprintf(test_out
, "DSS could not start\n");
92 fprintf(test_out
, "executing test1\n");
94 fprintf(test_out
, "Test1 succeeded\n");
97 fprintf(test_out
, "Test1 failed\n");
100 fprintf(test_out
, "executing test2\n");
102 fprintf(test_out
, "Test2 succeeded\n");
105 fprintf(test_out
, "Test2 failed\n");
108 fprintf(test_out
, "executing test3\n");
110 fprintf(test_out
, "Test3 succeeded\n");
113 fprintf(test_out
, "Test3 failed\n");
116 fprintf(test_out
, "executing test4\n");
118 fprintf(test_out
, "Test4 succeeded\n");
121 fprintf(test_out
, "Test4 failed\n");
124 fprintf(test_out
, "executing test5\n");
126 fprintf(test_out
, "Test5 succeeded\n");
129 fprintf(test_out
, "Test5 failed\n");
132 fprintf(test_out
, "executing test6\n");
134 fprintf(test_out
, "Test6 succeeded\n");
137 fprintf(test_out
, "Test6 failed\n");
140 fprintf(test_out
, "executing test7\n");
142 fprintf(test_out
, "Test7 succeeded\n");
145 fprintf(test_out
, "Test7 failed\n");
148 fprintf(test_out
, "executing test8\n");
150 fprintf(test_out
, "Test8 succeeded\n");
153 fprintf(test_out
, "Test8 failed\n");
156 fprintf(test_out
, "executing test9\n");
158 fprintf(test_out
, "Test9 succeeded\n");
161 fprintf(test_out
, "orte_dss test9 failed\n");
164 fprintf(test_out
, "executing test10\n");
166 fprintf(test_out
, "Test10 succeeded\n");
169 fprintf(test_out
, "orte_dss test10 failed\n");
172 fprintf(test_out
, "executing test11\n");
174 fprintf(test_out
, "Test11 succeeded\n");
177 fprintf(test_out
, "orte_dss test11 failed\n");
180 fprintf(test_out
, "executing test12\n");
182 fprintf(test_out
, "Test12 succeeded\n");
185 fprintf(test_out
, "orte_dss test12 failed\n");
200 static bool test1(void)
204 orte_data_type_t type
=ORTE_INT8
, utype
=ORTE_UINT8
;
205 orte_data_value_t dv
;
211 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
212 fprintf(test_out
, "orte_dss.increment returned error\n");
216 fprintf(test_out
, "orte_dss.increment failed for signed value\n");
220 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
221 fprintf(test_out
, "orte_dss.decrement returned error\n");
225 fprintf(test_out
, "orte_dss.decrement failed for signed value\n");
234 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
235 fprintf(test_out
, "orte_dss.increment returned error\n");
239 fprintf(test_out
, "orte_dss.increment failed for unsigned value\n");
243 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
244 fprintf(test_out
, "orte_dss.decrement returned error\n");
248 fprintf(test_out
, "orte_dss.decrement failed for unsigned value\n");
259 static bool test2(void)
263 orte_data_type_t type
=ORTE_INT16
, utype
=ORTE_UINT16
;
264 orte_data_value_t dv
;
270 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
271 fprintf(test_out
, "orte_dss.increment returned error\n");
275 fprintf(test_out
, "orte_dss.increment failed for signed value\n");
279 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
280 fprintf(test_out
, "orte_dss.decrement returned error\n");
284 fprintf(test_out
, "orte_dss.decrement failed for signed value\n");
293 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
294 fprintf(test_out
, "orte_dss.increment returned error\n");
298 fprintf(test_out
, "orte_dss.increment failed for unsigned value\n");
302 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
303 fprintf(test_out
, "orte_dss.decrement returned error\n");
307 fprintf(test_out
, "orte_dss.decrement failed for unsigned value\n");
318 static bool test3(void)
322 orte_data_type_t type
=ORTE_INT32
, utype
=ORTE_UINT32
;
323 orte_data_value_t dv
;
329 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
330 fprintf(test_out
, "orte_dss.increment returned error\n");
334 fprintf(test_out
, "orte_dss.increment failed for signed value\n");
338 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
339 fprintf(test_out
, "orte_dss.decrement returned error\n");
343 fprintf(test_out
, "orte_dss.decrement failed for signed value\n");
352 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
353 fprintf(test_out
, "orte_dss.increment returned error\n");
357 fprintf(test_out
, "orte_dss.increment failed for unsigned value\n");
361 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
362 fprintf(test_out
, "orte_dss.decrement returned error\n");
366 fprintf(test_out
, "orte_dss.decrement failed for unsigned value\n");
377 static bool test4(void)
381 orte_data_type_t type
=ORTE_INT64
, utype
=ORTE_UINT64
;
382 orte_data_value_t dv
;
388 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
389 fprintf(test_out
, "orte_dss.increment returned error\n");
393 fprintf(test_out
, "orte_dss.increment failed for signed value\n");
397 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
398 fprintf(test_out
, "orte_dss.decrement returned error\n");
402 fprintf(test_out
, "orte_dss.decrement failed for signed value\n");
411 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
412 fprintf(test_out
, "orte_dss.increment returned error\n");
416 fprintf(test_out
, "orte_dss.increment failed for unsigned value\n");
420 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
421 fprintf(test_out
, "orte_dss.decrement returned error\n");
425 fprintf(test_out
, "orte_dss.decrement failed for unsigned value\n");
436 static bool test5(void)
440 orte_data_type_t type
=ORTE_INT
, utype
=ORTE_UINT
;
441 orte_data_value_t dv
;
447 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
448 fprintf(test_out
, "orte_dss.increment returned error\n");
452 fprintf(test_out
, "orte_dss.increment failed for signed value\n");
456 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
457 fprintf(test_out
, "orte_dss.decrement returned error\n");
461 fprintf(test_out
, "orte_dss.decrement failed for signed value\n");
470 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
471 fprintf(test_out
, "orte_dss.increment returned error\n");
475 fprintf(test_out
, "orte_dss.increment failed for unsigned value\n");
479 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
480 fprintf(test_out
, "orte_dss.decrement returned error\n");
484 fprintf(test_out
, "orte_dss.decrement failed for unsigned value\n");
494 static bool test6(void)
496 char *string1
="This is a short string";
497 orte_data_value_t dv
;
499 dv
.type
= ORTE_STRING
;
502 if (ORTE_ERR_OPERATION_UNSUPPORTED
!= orte_dss
.increment(&dv
)) {
503 fprintf(test_out
, "orte_dss.increment failed to return correct error\n");
513 static bool test7(void)
516 orte_data_value_t dv
;
521 if (ORTE_ERR_OPERATION_UNSUPPORTED
!= orte_dss
.increment(&dv
)) {
522 fprintf(test_out
, "orte_dss.increment failed to return correct error\n");
533 static bool test8(void)
536 orte_data_type_t type
=ORTE_SIZE
;
537 orte_data_value_t dv
;
543 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
544 fprintf(test_out
, "orte_dss.increment returned error\n");
548 fprintf(test_out
, "orte_dss.increment failed for size value\n");
552 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
553 fprintf(test_out
, "orte_dss.decrement returned error\n");
557 fprintf(test_out
, "orte_dss.decrement failed for size value\n");
567 static bool test9(void)
570 orte_data_type_t type
=ORTE_PID
;
571 orte_data_value_t dv
;
577 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
578 fprintf(test_out
, "orte_dss.increment returned error\n");
582 fprintf(test_out
, "orte_dss.increment failed for pid value\n");
586 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
587 fprintf(test_out
, "orte_dss.decrement returned error\n");
591 fprintf(test_out
, "orte_dss.decrement failed for pid value\n");
601 static bool test10(void)
603 orte_daemon_cmd_flag_t v1
, v2
=100;
604 orte_data_type_t type
=ORTE_DAEMON_CMD
;
605 orte_data_value_t dv
;
611 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
612 fprintf(test_out
, "orte_dss.increment returned error\n");
616 fprintf(test_out
, "orte_dss.increment failed for daemon cmd value\n");
620 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
621 fprintf(test_out
, "orte_dss.decrement returned error\n");
625 fprintf(test_out
, "orte_dss.decrement failed for daemon cmd value\n");
635 static bool test11(void)
637 orte_data_type_t v1
, v2
=100;
638 orte_data_type_t type
=ORTE_DATA_TYPE
;
639 orte_data_value_t dv
;
645 if (ORTE_SUCCESS
!= orte_dss
.increment(&dv
)) {
646 fprintf(test_out
, "orte_dss.increment returned error\n");
650 fprintf(test_out
, "orte_dss.increment failed for data type value\n");
654 if (ORTE_SUCCESS
!= orte_dss
.decrement(&dv
)) {
655 fprintf(test_out
, "orte_dss.decrement returned error\n");
659 fprintf(test_out
, "orte_dss.decrement failed for data type value\n");
670 static bool test12(void)
673 orte_byte_object_t v2
;
674 orte_data_value_t dv
;
677 v2
.bytes
= (uint8_t*)malloc(v2
.size
);
678 for (i
=0; i
<v2
.size
; i
++) v2
.bytes
[i
] = i
;
680 dv
.type
= ORTE_BYTE_OBJECT
;
683 if (ORTE_ERR_OPERATION_UNSUPPORTED
!= orte_dss
.increment(&dv
)) {
684 fprintf(test_out
, "orte_dss.increment failed to return correct error\n");