This source file includes following definitions.
- main
- test1
- test2
- test3
- test4
- test5
- test6
- test7
- test8
- test9
- test11
- test12
- test13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include "opal_config.h"
22 #include "opal/constants.h"
23
24 #include <stdio.h>
25 #include <string.h>
26 #include <stdlib.h>
27
28 #include "opal/runtime/opal.h"
29
30 #include "opal/dss/dss.h"
31
32 #define NUM_ITERS 3
33 #define NUM_ELEMS 10
34
35 static bool test1(void);
36 static bool test2(void);
37 static bool test3(void);
38 static bool test4(void);
39 static bool test5(void);
40 static bool test6(void);
41 static bool test7(void);
42 static bool test8(void);
43 static bool test9(void);
44 static bool test11(void);
45 static bool test12(void);
46 static bool test13(void);
47
48 static FILE *test_out;
49
50
51 int main (int argc, char* argv[])
52 {
53 int ret = 0;
54
55 opal_init(&argc, &argv);
56
57 test_out = stderr;
58
59
60
61 fprintf(test_out, "executing test1\n");
62 if (test1()) {
63 fprintf(test_out, "Test1 succeeded\n");
64 } else {
65 fprintf(test_out, "Test1 failed\n");
66 ret = 1;
67 }
68
69 fprintf(test_out, "executing test2\n");
70 if (test2()) {
71 fprintf(test_out, "Test2 succeeded\n");
72 } else {
73 fprintf(test_out, "Test2 failed\n");
74 ret = 1;
75 }
76
77 fprintf(test_out, "executing test3\n");
78 if (test3()) {
79 fprintf(test_out, "Test3 succeeded\n");
80 } else {
81 fprintf(test_out, "Test3 failed\n");
82 ret = 3;
83 }
84
85 fprintf(test_out, "executing test4\n");
86 if (test4()) {
87 fprintf(test_out, "Test4 succeeded\n");
88 } else {
89 fprintf(test_out, "Test4 failed\n");
90 ret = 4;
91 }
92
93 fprintf(test_out, "executing test5\n");
94 if (test5()) {
95 fprintf(test_out, "Test5 succeeded\n");
96 } else {
97 fprintf(test_out, "Test5 failed\n");
98 ret = 5;
99 }
100
101 fprintf(test_out, "executing test6\n");
102 if (test6()) {
103 fprintf(test_out, "Test6 succeeded\n");
104 } else {
105 fprintf(test_out, "Test6 failed\n");
106 ret = 6;
107 }
108
109 fprintf(test_out, "executing test7\n");
110 if (test7()) {
111 fprintf(test_out, "Test7 succeeded\n");
112 } else {
113 fprintf(test_out, "Test7 failed\n");
114 ret = 7;
115 }
116
117 fprintf(test_out, "executing test8\n");
118 if (test8()) {
119 fprintf(test_out, "Test8 succeeded\n");
120 } else {
121 fprintf(test_out, "Test8 failed\n");
122 ret = 8;
123 }
124
125 fprintf(test_out, "executing test9\n");
126 if (test9()) {
127 fprintf(test_out, "Test9 succeeded\n");
128 } else {
129 fprintf(test_out, "opal_dss test9 failed\n");
130 ret = 9;
131 }
132
133 fprintf(test_out, "executing test11\n");
134 if (test11()) {
135 fprintf(test_out, "Test11 succeeded\n");
136 } else {
137 fprintf(test_out, "opal_dss test11 failed\n");
138 ret = 11;
139 }
140
141 fprintf(test_out, "executing test12\n");
142 if (test12()) {
143 fprintf(test_out, "Test12 succeeded\n");
144 } else {
145 fprintf(test_out, "opal_dss test12 failed\n");
146 ret = 12;
147 }
148
149 fprintf(test_out, "executing test13\n");
150 if (test13()) {
151 fprintf(test_out, "Test13 succeeded\n");
152 } else {
153 fprintf(test_out, "opal_dss test13 failed\n");
154 ret = 13;
155 }
156
157 fclose(test_out);
158
159 opal_finalize();
160
161 return ret;
162 }
163
164
165
166
167 static bool test1(void)
168 {
169 int8_t v2=-100;
170 uint8_t u2=150;
171 opal_data_type_t type=OPAL_INT8, utype=OPAL_UINT8;
172 char *output;
173
174 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
175 fprintf(test_out, "opal_dss.print returned error\n");
176 return(false);
177 }
178 if (NULL == output) {
179 fprintf(test_out, "opal_dss.print failed for signed value\n");
180 return(false);
181 }
182 fprintf(test_out, "opal_dss.print output for signed value: %s\n", output);
183 free(output);
184
185 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) {
186 fprintf(test_out, "opal_dss.print returned error\n");
187 return(false);
188 }
189 if (NULL == output) {
190 fprintf(test_out, "opal_dss.print failed for unsigned value\n");
191 return(false);
192 }
193 fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output);
194 free(output);
195
196 return (true);
197 }
198
199
200
201
202 static bool test2(void)
203 {
204 int16_t v2=-100;
205 uint16_t u2=150;
206 opal_data_type_t type=OPAL_INT16, utype=OPAL_UINT16;
207 char *output;
208
209 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
210 fprintf(test_out, "opal_dss.print returned error\n");
211 return(false);
212 }
213 if (NULL == output) {
214 fprintf(test_out, "opal_dss.print failed for signed value\n");
215 return(false);
216 }
217 fprintf(test_out, "opal_dss.print output for signed value: %s\n", output);
218 free(output);
219
220 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) {
221 fprintf(test_out, "opal_dss.print returned error\n");
222 return(false);
223 }
224 if (NULL == output) {
225 fprintf(test_out, "opal_dss.print failed for unsigned value\n");
226 return(false);
227 }
228 fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output);
229 free(output);
230
231 return (true);
232 }
233
234
235
236
237 static bool test3(void)
238 {
239 int32_t v2=-100;
240 uint32_t u2=150;
241 opal_data_type_t type=OPAL_INT32, utype=OPAL_UINT32;
242 char *output;
243
244 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
245 fprintf(test_out, "opal_dss.print returned error\n");
246 return(false);
247 }
248 if (NULL == output) {
249 fprintf(test_out, "opal_dss.print failed for signed value\n");
250 return(false);
251 }
252 fprintf(test_out, "opal_dss.print output for signed value: %s\n", output);
253 free(output);
254
255 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) {
256 fprintf(test_out, "opal_dss.print returned error\n");
257 return(false);
258 }
259 if (NULL == output) {
260 fprintf(test_out, "opal_dss.print failed for unsigned value\n");
261 return(false);
262 }
263 fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output);
264 free(output);
265
266 return (true);
267 }
268
269
270
271
272 static bool test4(void)
273 {
274 int64_t v2=-100;
275 uint64_t u2=150;
276 opal_data_type_t type=OPAL_INT64, utype=OPAL_UINT64;
277 char *output;
278
279 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
280 fprintf(test_out, "opal_dss.print returned error\n");
281 return(false);
282 }
283 if (NULL == output) {
284 fprintf(test_out, "opal_dss.print failed for signed value\n");
285 return(false);
286 }
287 fprintf(test_out, "opal_dss.print output for signed value: %s\n", output);
288 free(output);
289
290 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) {
291 fprintf(test_out, "opal_dss.print returned error\n");
292 return(false);
293 }
294 if (NULL == output) {
295 fprintf(test_out, "opal_dss.print failed for unsigned value\n");
296 return(false);
297 }
298 fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output);
299 free(output);
300
301 return (true);
302 }
303
304
305
306
307 static bool test5(void)
308 {
309 int v2=-100;
310 uint u2=150;
311 opal_data_type_t type=OPAL_INT, utype=OPAL_UINT;
312 char *output;
313
314 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
315 fprintf(test_out, "opal_dss.print returned error\n");
316 return(false);
317 }
318 if (NULL == output) {
319 fprintf(test_out, "opal_dss.print failed for signed value\n");
320 return(false);
321 }
322 fprintf(test_out, "opal_dss.print output for signed value: %s\n", output);
323 free(output);
324
325 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) {
326 fprintf(test_out, "opal_dss.print returned error\n");
327 return(false);
328 }
329 if (NULL == output) {
330 fprintf(test_out, "opal_dss.print failed for unsigned value\n");
331 return(false);
332 }
333 fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output);
334 free(output);
335
336 return (true);
337 }
338
339
340
341
342 static bool test6(void)
343 {
344 char *string1="This is a short string";
345 char *output;
346
347 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, string1, OPAL_STRING)) {
348 fprintf(test_out, "opal_dss.print returned error\n");
349 return(false);
350 }
351 if (NULL == output) {
352 fprintf(test_out, "opal_dss.print failed\n");
353 return(false);
354 }
355 fprintf(test_out, "opal_dss.print output for string: %s\n", output);
356 free(output);
357
358 return (true);
359 }
360
361
362
363
364 static bool test7(void)
365 {
366 bool v2=true;
367 char *output;
368
369 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, OPAL_BOOL)) {
370 fprintf(test_out, "opal_dss.print returned error\n");
371 return(false);
372 }
373 if (NULL == output) {
374 fprintf(test_out, "opal_dss.print failed\n");
375 return(false);
376 }
377 fprintf(test_out, "opal_dss.print output for bool: %s\n", output);
378 free(output);
379
380 return (true);
381 }
382
383
384
385
386
387 static bool test8(void)
388 {
389 size_t v2=100;
390 opal_data_type_t type=OPAL_SIZE;
391 char *output;
392
393 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
394 fprintf(test_out, "opal_dss.print returned error\n");
395 return(false);
396 }
397 if (NULL == output) {
398 fprintf(test_out, "opal_dss.print failed\n");
399 return(false);
400 }
401 fprintf(test_out, "opal_dss.print output for size: %s\n", output);
402 free(output);
403
404 return (true);
405 }
406
407
408
409
410 static bool test9(void)
411 {
412 pid_t v2=100;
413 opal_data_type_t type=OPAL_PID;
414 char *output;
415
416 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
417 fprintf(test_out, "opal_dss.print returned error\n");
418 return(false);
419 }
420 if (NULL == output) {
421 fprintf(test_out, "opal_dss.print failed\n");
422 return(false);
423 }
424 fprintf(test_out, "opal_dss.print output for pid: %s\n", output);
425 free(output);
426
427 return (true);
428 }
429
430
431
432
433 static bool test11(void)
434 {
435 opal_data_type_t v2=100;
436 opal_data_type_t type=OPAL_DATA_TYPE;
437 char *output;
438
439 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
440 fprintf(test_out, "opal_dss.print returned error\n");
441 return(false);
442 }
443 if (NULL == output) {
444 fprintf(test_out, "opal_dss.print failed\n");
445 return(false);
446 }
447 fprintf(test_out, "opal_dss.print output for data type: %s\n", output);
448 free(output);
449
450 return (true);
451 }
452
453
454
455
456
457 static bool test12(void)
458 {
459 int i;
460 opal_byte_object_t v2;
461 opal_data_type_t type=OPAL_BYTE_OBJECT;
462 char *output;
463
464 v2.size = 20;
465 v2.bytes = (uint8_t*)malloc(v2.size);
466 for (i=0; i<v2.size; i++) v2.bytes[i] = i;
467
468 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
469 fprintf(test_out, "opal_dss.print returned error\n");
470 return(false);
471 }
472 if (NULL == output) {
473 fprintf(test_out, "opal_dss.print failed\n");
474 return(false);
475 }
476 fprintf(test_out, "opal_dss.print output for byte object: %s\n", output);
477 free(output);
478
479 return (true);
480 }
481
482
483
484 static bool test13(void)
485 {
486 int dat2=200;
487 opal_value_t v2;
488 opal_data_type_t type=OPAL_VALUE;
489 char *output;
490
491 v2.type = OPAL_INT;
492 v2.data.integer = dat2;
493 v2.key = "key";
494
495 if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) {
496 fprintf(test_out, "opal_dss.print returned error\n");
497 return(false);
498 }
499 if (NULL == output) {
500 fprintf(test_out, "opal_dss.print failed\n");
501 return(false);
502 }
503 fprintf(test_out, "opal_dss.print output for data value: %s\n", output);
504 free(output);
505
506 return (true);
507 }
508