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
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
206 orte_data_value_t udv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
208 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, type
)) {
209 fprintf(test_out
, "orte_dss.set returned error\n");
212 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, type
)) {
213 fprintf(test_out
, "orte_dss.get returned error\n");
217 fprintf(test_out
, "orte_dss.get/set failed for signed value\n");
221 if (ORTE_SUCCESS
!= orte_dss
.set(&udv
, &u2
, utype
)) {
222 fprintf(test_out
, "orte_dss.set returned error\n");
225 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&u1
, &udv
, utype
)) {
226 fprintf(test_out
, "orte_dss.get returned error\n");
230 fprintf(test_out
, "orte_dss.get/set failed for unsigned value\n");
240 static bool test2(void)
243 uint16_t *u1
, u2
=150;
244 orte_data_type_t type
=ORTE_INT16
, utype
=ORTE_UINT16
;
245 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
246 orte_data_value_t udv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
248 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, type
)) {
249 fprintf(test_out
, "orte_dss.set returned error\n");
252 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, type
)) {
253 fprintf(test_out
, "orte_dss.get returned error\n");
257 fprintf(test_out
, "orte_dss.get/set failed for signed value\n");
261 if (ORTE_SUCCESS
!= orte_dss
.set(&udv
, &u2
, utype
)) {
262 fprintf(test_out
, "orte_dss.set returned error\n");
265 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&u1
, &udv
, utype
)) {
266 fprintf(test_out
, "orte_dss.get returned error\n");
270 fprintf(test_out
, "orte_dss.get/set failed for unsigned value\n");
280 static bool test3(void)
283 uint32_t *u1
, u2
=150;
284 orte_data_type_t type
=ORTE_INT32
, utype
=ORTE_UINT32
;
285 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
286 orte_data_value_t udv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
288 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, type
)) {
289 fprintf(test_out
, "orte_dss.set returned error\n");
292 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, type
)) {
293 fprintf(test_out
, "orte_dss.get returned error\n");
297 fprintf(test_out
, "orte_dss.get/set failed for signed value\n");
301 if (ORTE_SUCCESS
!= orte_dss
.set(&udv
, &u2
, utype
)) {
302 fprintf(test_out
, "orte_dss.set returned error\n");
305 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&u1
, &udv
, utype
)) {
306 fprintf(test_out
, "orte_dss.get returned error\n");
310 fprintf(test_out
, "orte_dss.get/set failed for unsigned value\n");
320 static bool test4(void)
323 uint64_t *u1
, u2
=150;
324 orte_data_type_t type
=ORTE_INT64
, utype
=ORTE_UINT64
;
325 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
326 orte_data_value_t udv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
328 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, type
)) {
329 fprintf(test_out
, "orte_dss.set returned error\n");
332 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, type
)) {
333 fprintf(test_out
, "orte_dss.get returned error\n");
337 fprintf(test_out
, "orte_dss.get/set failed for signed value\n");
341 if (ORTE_SUCCESS
!= orte_dss
.set(&udv
, &u2
, utype
)) {
342 fprintf(test_out
, "orte_dss.set returned error\n");
345 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&u1
, &udv
, utype
)) {
346 fprintf(test_out
, "orte_dss.get returned error\n");
350 fprintf(test_out
, "orte_dss.get/set failed for unsigned value\n");
360 static bool test5(void)
364 orte_data_type_t type
=ORTE_INT
, utype
=ORTE_UINT
;
365 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
366 orte_data_value_t udv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
368 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, type
)) {
369 fprintf(test_out
, "orte_dss.set returned error\n");
372 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, type
)) {
373 fprintf(test_out
, "orte_dss.get returned error\n");
377 fprintf(test_out
, "orte_dss.get/set failed for signed value\n");
381 if (ORTE_SUCCESS
!= orte_dss
.set(&udv
, &u2
, utype
)) {
382 fprintf(test_out
, "orte_dss.set returned error\n");
385 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&u1
, &udv
, utype
)) {
386 fprintf(test_out
, "orte_dss.get returned error\n");
390 fprintf(test_out
, "orte_dss.get/set failed for unsigned value\n");
400 static bool test6(void)
402 char *string1
="This is a short string", *string2
;
403 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
405 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, string1
, ORTE_STRING
)) {
406 fprintf(test_out
, "orte_dss.set returned error\n");
409 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&string2
, &dv
, ORTE_STRING
)) {
410 fprintf(test_out
, "orte_dss.get returned error\n");
413 if (0 != strcmp(string1
, string2
)) {
414 fprintf(test_out
, "orte_dss.get/set failed for string value\n");
424 static bool test7(void)
427 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
429 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, ORTE_BOOL
)) {
430 fprintf(test_out
, "orte_dss.set returned error\n");
433 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, ORTE_BOOL
)) {
434 fprintf(test_out
, "orte_dss.get returned error\n");
438 fprintf(test_out
, "orte_dss.get/set failed for bool value\n");
449 static bool test8(void)
452 orte_data_type_t type
=ORTE_SIZE
;
453 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
455 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, type
)) {
456 fprintf(test_out
, "orte_dss.set returned error\n");
459 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, type
)) {
460 fprintf(test_out
, "orte_dss.get returned error\n");
464 fprintf(test_out
, "orte_dss.get/set failed for size value\n");
474 static bool test9(void)
477 orte_data_type_t type
=ORTE_PID
;
478 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
480 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, type
)) {
481 fprintf(test_out
, "orte_dss.set returned error\n");
484 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, type
)) {
485 fprintf(test_out
, "orte_dss.get returned error\n");
489 fprintf(test_out
, "orte_dss.get/set failed for pid value\n");
499 static bool test10(void)
501 orte_daemon_cmd_flag_t
*v1
, v2
=100;
502 orte_data_type_t type
=ORTE_DAEMON_CMD
;
503 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
505 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, type
)) {
506 fprintf(test_out
, "orte_dss.set returned error\n");
509 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, type
)) {
510 fprintf(test_out
, "orte_dss.get returned error\n");
514 fprintf(test_out
, "orte_dss.get/set failed for daemon cmd value\n");
524 static bool test11(void)
526 orte_data_type_t
*v1
, v2
=100;
527 orte_data_type_t type
=ORTE_DATA_TYPE
;
528 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
530 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, type
)) {
531 fprintf(test_out
, "orte_dss.set returned error\n");
534 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, type
)) {
535 fprintf(test_out
, "orte_dss.get returned error\n");
539 fprintf(test_out
, "orte_dss.get/set failed for data type value\n");
550 static bool test12(void)
553 orte_byte_object_t v2
, *v1
;
554 orte_data_value_t dv
= {{OBJ_CLASS(orte_data_value_t
),0},ORTE_UNDEF
, NULL
};
557 v2
.bytes
= (uint8_t*)malloc(v2
.size
);
558 for (i
=0; i
<v2
.size
; i
++) v2
.bytes
[i
] = i
;
560 if (ORTE_SUCCESS
!= orte_dss
.set(&dv
, &v2
, ORTE_BYTE_OBJECT
)) {
561 fprintf(test_out
, "orte_dss.set returned error\n");
564 if (ORTE_SUCCESS
!= orte_dss
.get((void**)&v1
, &dv
, ORTE_BYTE_OBJECT
)) {
565 fprintf(test_out
, "orte_dss.get returned error\n");
568 if (0 != orte_dss
.compare(v1
, &v2
, ORTE_BYTE_OBJECT
)) {
569 fprintf(test_out
, "orte_dss.get/set failed for byte object value\n");