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 */
55 static bool test13(void); /* verify pid_t */
60 int main (int argc
, char* argv
[])
66 /* register handler for errnum -> string converstion */
67 opal_error_register("ORTE", ORTE_ERR_BASE
, ORTE_ERR_MAX
, orte_err2str
);
71 /* Ensure the process info structure is instantiated and initialized */
72 if (ORTE_SUCCESS
!= (ret
= orte_proc_info())) {
76 orte_process_info
.seed
= true;
77 orte_process_info
.my_name
= (orte_process_name_t
*)malloc(sizeof(orte_process_name_t
));
78 orte_process_info
.my_name
->cellid
= 0;
79 orte_process_info
.my_name
->jobid
= 0;
80 orte_process_info
.my_name
->vpid
= 0;
84 if (ORTE_SUCCESS
== orte_dss_open()) {
85 fprintf(test_out
, "DSS started\n");
87 fprintf(test_out
, "DSS could not start\n");
93 fprintf(test_out
, "executing test1\n");
95 fprintf(test_out
, "Test1 succeeded\n");
98 fprintf(test_out
, "Test1 failed\n");
101 fprintf(test_out
, "executing test2\n");
103 fprintf(test_out
, "Test2 succeeded\n");
106 fprintf(test_out
, "Test2 failed\n");
109 fprintf(test_out
, "executing test3\n");
111 fprintf(test_out
, "Test3 succeeded\n");
114 fprintf(test_out
, "Test3 failed\n");
117 fprintf(test_out
, "executing test4\n");
119 fprintf(test_out
, "Test4 succeeded\n");
122 fprintf(test_out
, "Test4 failed\n");
125 fprintf(test_out
, "executing test5\n");
127 fprintf(test_out
, "Test5 succeeded\n");
130 fprintf(test_out
, "Test5 failed\n");
133 fprintf(test_out
, "executing test6\n");
135 fprintf(test_out
, "Test6 succeeded\n");
138 fprintf(test_out
, "Test6 failed\n");
141 fprintf(test_out
, "executing test7\n");
143 fprintf(test_out
, "Test7 succeeded\n");
146 fprintf(test_out
, "Test7 failed\n");
149 fprintf(test_out
, "executing test8\n");
151 fprintf(test_out
, "Test8 succeeded\n");
154 fprintf(test_out
, "Test8 failed\n");
157 fprintf(test_out
, "executing test9\n");
159 fprintf(test_out
, "Test9 succeeded\n");
162 fprintf(test_out
, "orte_dss test9 failed\n");
165 fprintf(test_out
, "executing test10\n");
167 fprintf(test_out
, "Test10 succeeded\n");
170 fprintf(test_out
, "orte_dss test10 failed\n");
173 fprintf(test_out
, "executing test11\n");
175 fprintf(test_out
, "Test11 succeeded\n");
178 fprintf(test_out
, "orte_dss test11 failed\n");
181 fprintf(test_out
, "executing test12\n");
183 fprintf(test_out
, "Test12 succeeded\n");
186 fprintf(test_out
, "orte_dss test12 failed\n");
189 fprintf(test_out
, "executing test13\n");
191 fprintf(test_out
, "Test13 succeeded\n");
194 fprintf(test_out
, "orte_dss test13 failed\n");
209 static bool test1(void)
213 orte_data_type_t type
=ORTE_INT8
, utype
=ORTE_UINT8
;
216 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
217 fprintf(test_out
, "orte_dss.print returned error\n");
220 if (NULL
== output
) {
221 fprintf(test_out
, "orte_dss.print failed for signed value\n");
224 fprintf(test_out
, "orte_dss.print output for signed value: %s\n", output
);
227 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &u2
, utype
)) {
228 fprintf(test_out
, "orte_dss.print returned error\n");
231 if (NULL
== output
) {
232 fprintf(test_out
, "orte_dss.print failed for unsigned value\n");
235 fprintf(test_out
, "orte_dss.print output for unsigned value: %s\n", output
);
244 static bool test2(void)
248 orte_data_type_t type
=ORTE_INT16
, utype
=ORTE_UINT16
;
251 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
252 fprintf(test_out
, "orte_dss.print returned error\n");
255 if (NULL
== output
) {
256 fprintf(test_out
, "orte_dss.print failed for signed value\n");
259 fprintf(test_out
, "orte_dss.print output for signed value: %s\n", output
);
262 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &u2
, utype
)) {
263 fprintf(test_out
, "orte_dss.print returned error\n");
266 if (NULL
== output
) {
267 fprintf(test_out
, "orte_dss.print failed for unsigned value\n");
270 fprintf(test_out
, "orte_dss.print output for unsigned value: %s\n", output
);
279 static bool test3(void)
283 orte_data_type_t type
=ORTE_INT32
, utype
=ORTE_UINT32
;
286 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
287 fprintf(test_out
, "orte_dss.print returned error\n");
290 if (NULL
== output
) {
291 fprintf(test_out
, "orte_dss.print failed for signed value\n");
294 fprintf(test_out
, "orte_dss.print output for signed value: %s\n", output
);
297 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &u2
, utype
)) {
298 fprintf(test_out
, "orte_dss.print returned error\n");
301 if (NULL
== output
) {
302 fprintf(test_out
, "orte_dss.print failed for unsigned value\n");
305 fprintf(test_out
, "orte_dss.print output for unsigned value: %s\n", output
);
314 static bool test4(void)
318 orte_data_type_t type
=ORTE_INT64
, utype
=ORTE_UINT64
;
321 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
322 fprintf(test_out
, "orte_dss.print returned error\n");
325 if (NULL
== output
) {
326 fprintf(test_out
, "orte_dss.print failed for signed value\n");
329 fprintf(test_out
, "orte_dss.print output for signed value: %s\n", output
);
332 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &u2
, utype
)) {
333 fprintf(test_out
, "orte_dss.print returned error\n");
336 if (NULL
== output
) {
337 fprintf(test_out
, "orte_dss.print failed for unsigned value\n");
340 fprintf(test_out
, "orte_dss.print output for unsigned value: %s\n", output
);
349 static bool test5(void)
353 orte_data_type_t type
=ORTE_INT
, utype
=ORTE_UINT
;
356 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
357 fprintf(test_out
, "orte_dss.print returned error\n");
360 if (NULL
== output
) {
361 fprintf(test_out
, "orte_dss.print failed for signed value\n");
364 fprintf(test_out
, "orte_dss.print output for signed value: %s\n", output
);
367 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &u2
, utype
)) {
368 fprintf(test_out
, "orte_dss.print returned error\n");
371 if (NULL
== output
) {
372 fprintf(test_out
, "orte_dss.print failed for unsigned value\n");
375 fprintf(test_out
, "orte_dss.print output for unsigned value: %s\n", output
);
384 static bool test6(void)
386 char *string1
="This is a short string";
389 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, string1
, ORTE_STRING
)) {
390 fprintf(test_out
, "orte_dss.print returned error\n");
393 if (NULL
== output
) {
394 fprintf(test_out
, "orte_dss.print failed\n");
397 fprintf(test_out
, "orte_dss.print output for string: %s\n", output
);
406 static bool test7(void)
411 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, ORTE_BOOL
)) {
412 fprintf(test_out
, "orte_dss.print returned error\n");
415 if (NULL
== output
) {
416 fprintf(test_out
, "orte_dss.print failed\n");
419 fprintf(test_out
, "orte_dss.print output for bool: %s\n", output
);
429 static bool test8(void)
432 orte_data_type_t type
=ORTE_SIZE
;
435 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
436 fprintf(test_out
, "orte_dss.print returned error\n");
439 if (NULL
== output
) {
440 fprintf(test_out
, "orte_dss.print failed\n");
443 fprintf(test_out
, "orte_dss.print output for size: %s\n", output
);
452 static bool test9(void)
455 orte_data_type_t type
=ORTE_PID
;
458 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
459 fprintf(test_out
, "orte_dss.print returned error\n");
462 if (NULL
== output
) {
463 fprintf(test_out
, "orte_dss.print failed\n");
466 fprintf(test_out
, "orte_dss.print output for pid: %s\n", output
);
475 static bool test10(void)
477 orte_daemon_cmd_flag_t v2
=100;
478 orte_data_type_t type
=ORTE_DAEMON_CMD
;
481 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
482 fprintf(test_out
, "orte_dss.print returned error\n");
485 if (NULL
== output
) {
486 fprintf(test_out
, "orte_dss.print failed\n");
489 fprintf(test_out
, "orte_dss.print output for daemon cmd: %s\n", output
);
498 static bool test11(void)
500 orte_data_type_t v2
=100;
501 orte_data_type_t type
=ORTE_DATA_TYPE
;
504 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
505 fprintf(test_out
, "orte_dss.print returned error\n");
508 if (NULL
== output
) {
509 fprintf(test_out
, "orte_dss.print failed\n");
512 fprintf(test_out
, "orte_dss.print output for data type: %s\n", output
);
522 static bool test12(void)
525 orte_byte_object_t v2
;
526 orte_data_type_t type
=ORTE_BYTE_OBJECT
;
530 v2
.bytes
= (uint8_t*)malloc(v2
.size
);
531 for (i
=0; i
<v2
.size
; i
++) v2
.bytes
[i
] = i
;
533 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
534 fprintf(test_out
, "orte_dss.print returned error\n");
537 if (NULL
== output
) {
538 fprintf(test_out
, "orte_dss.print failed\n");
541 fprintf(test_out
, "orte_dss.print output for byte object: %s\n", output
);
548 /* ORTE_DATA_VALUE */
549 static bool test13(void)
552 orte_data_value_t v2
;
553 orte_data_type_t type
=ORTE_DATA_VALUE
;
559 if (ORTE_SUCCESS
!= orte_dss
.print(&output
, NULL
, &v2
, type
)) {
560 fprintf(test_out
, "orte_dss.print returned error\n");
563 if (NULL
== output
) {
564 fprintf(test_out
, "orte_dss.print failed\n");
567 fprintf(test_out
, "orte_dss.print output for data value: %s\n", output
);