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
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
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 = 2;
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 *v1, v2=100;
170 uint8_t *u1, u2=150;
171 opal_data_type_t type=OPAL_INT8, utype=OPAL_UINT8;
172
173 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
174 fprintf(test_out, "opal_dss.copy returned error\n");
175 return(false);
176 }
177 if (*v1 != v2) {
178 fprintf(test_out, "opal_dss.copy failed for signed value\n");
179 return(false);
180 }
181
182 if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) {
183 fprintf(test_out, "opal_dss.copy returned error\n");
184 return(false);
185 }
186 if (*u1 != u2) {
187 fprintf(test_out, "opal_dss.copy failed for unsigned value\n");
188 return(false);
189 }
190
191 return (true);
192 }
193
194
195
196
197 static bool test2(void)
198 {
199 int16_t *v1, v2=100;
200 uint16_t *u1, u2=150;
201 opal_data_type_t type=OPAL_INT16, utype=OPAL_UINT16;
202
203 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
204 fprintf(test_out, "opal_dss.copy returned error\n");
205 return(false);
206 }
207 if (*v1 != v2) {
208 fprintf(test_out, "opal_dss.copy failed for signed value\n");
209 return(false);
210 }
211
212 if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) {
213 fprintf(test_out, "opal_dss.copy returned error\n");
214 return(false);
215 }
216 if (*u1 != u2) {
217 fprintf(test_out, "opal_dss.copy failed for unsigned value\n");
218 return(false);
219 }
220
221 return (true);
222 }
223
224
225
226
227 static bool test3(void)
228 {
229 int32_t *v1, v2=100;
230 uint32_t *u1, u2=150;
231 opal_data_type_t type=OPAL_INT32, utype=OPAL_UINT32;
232
233 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
234 fprintf(test_out, "opal_dss.copy returned error\n");
235 return(false);
236 }
237 if (*v1 != v2) {
238 fprintf(test_out, "opal_dss.copy failed for signed value\n");
239 return(false);
240 }
241
242 if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) {
243 fprintf(test_out, "opal_dss.copy returned error\n");
244 return(false);
245 }
246 if (*u1 != u2) {
247 fprintf(test_out, "opal_dss.copy failed for unsigned value\n");
248 return(false);
249 }
250
251 return (true);
252 }
253
254
255
256
257 static bool test4(void)
258 {
259 int64_t *v1, v2=100;
260 uint64_t *u1, u2=150;
261 opal_data_type_t type=OPAL_INT64, utype=OPAL_UINT64;
262
263 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
264 fprintf(test_out, "opal_dss.copy returned error\n");
265 return(false);
266 }
267 if (*v1 != v2) {
268 fprintf(test_out, "opal_dss.copy failed for signed value\n");
269 return(false);
270 }
271
272 if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) {
273 fprintf(test_out, "opal_dss.copy returned error\n");
274 return(false);
275 }
276 if (*u1 != u2) {
277 fprintf(test_out, "opal_dss.copy failed for unsigned value\n");
278 return(false);
279 }
280
281 return (true);
282 }
283
284
285
286
287 static bool test5(void)
288 {
289 int *v1, v2=100;
290 uint *u1, u2=150;
291 opal_data_type_t type=OPAL_INT, utype=OPAL_UINT;
292
293 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
294 fprintf(test_out, "opal_dss.copy returned error\n");
295 return(false);
296 }
297 if (*v1 != v2) {
298 fprintf(test_out, "opal_dss.copy failed for signed value\n");
299 return(false);
300 }
301
302 if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) {
303 fprintf(test_out, "opal_dss.copy returned error\n");
304 return(false);
305 }
306 if (*u1 != u2) {
307 fprintf(test_out, "opal_dss.copy failed for unsigned value\n");
308 return(false);
309 }
310
311 return (true);
312 }
313
314
315
316
317 static bool test6(void)
318 {
319 char *string1="This is a short string";
320 char *string2;
321
322 if (OPAL_EQUAL != opal_dss.copy((void**)&string2, string1, OPAL_STRING)) {
323 fprintf(test_out, "opal_dss.copy returned error code\n");
324 return(false);
325 }
326
327 if (0 != strcmp(string1, string2)) {
328 fprintf(test_out, "opal_dss.copy failed\n");
329 return(false);
330 }
331
332 return (true);
333 }
334
335
336
337
338 static bool test7(void)
339 {
340 bool *v1, v2=true;
341
342 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, OPAL_BOOL)) {
343 fprintf(test_out, "opal_dss.copy returned error\n");
344 return(false);
345 }
346 if (*v1 != v2) {
347 fprintf(test_out, "opal_dss.copy failed\n");
348 return(false);
349 }
350
351 return (true);
352 }
353
354
355
356
357
358 static bool test8(void)
359 {
360 size_t *v1, v2=100;
361 opal_data_type_t type=OPAL_SIZE;
362
363 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
364 fprintf(test_out, "opal_dss.copy returned error\n");
365 return(false);
366 }
367 if (*v1 != v2) {
368 fprintf(test_out, "opal_dss.copy failed\n");
369 return(false);
370 }
371
372 return (true);
373 }
374
375
376
377
378 static bool test9(void)
379 {
380 pid_t *v1, v2=100;
381 opal_data_type_t type=OPAL_PID;
382
383 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
384 fprintf(test_out, "opal_dss.copy returned error\n");
385 return(false);
386 }
387 if (*v1 != v2) {
388 fprintf(test_out, "opal_dss.copy failed\n");
389 return(false);
390 }
391
392 return (true);
393 }
394
395
396
397
398 static bool test11(void)
399 {
400 opal_data_type_t *v1, v2=100;
401 opal_data_type_t type=OPAL_DATA_TYPE;
402
403 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
404 fprintf(test_out, "opal_dss.copy returned error\n");
405 return(false);
406 }
407 if (*v1 != v2) {
408 fprintf(test_out, "opal_dss.copy failed\n");
409 return(false);
410 }
411
412 return (true);
413 }
414
415
416
417
418
419 static bool test12(void)
420 {
421 size_t i;
422 opal_byte_object_t *v1, v2;
423 opal_data_type_t type=OPAL_BYTE_OBJECT;
424
425 v2.size = 20;
426 v2.bytes = (uint8_t*)malloc(v2.size);
427 for (i=0; i<v2.size; i++) v2.bytes[i]=i;
428
429 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
430 fprintf(test_out, "opal_dss.copy returned error\n");
431 return(false);
432 }
433 if (v1->size != v2.size) {
434 fprintf(test_out, "opal_dss.copy failed\n");
435 return(false);
436 }
437 for (i=0; i < v2.size; i++) {
438 if (v1->bytes[i] != v2.bytes[i]) {
439 fprintf(test_out, "opal_dss.copy failed\n");
440 return(false);
441 }
442 }
443
444 return (true);
445 }
446
447
448
449 static bool test13(void)
450 {
451 int dat2=200;
452 opal_dss_value_t *v1, v2;
453 opal_data_type_t type=OPAL_DATA_VALUE;
454
455 v2.type = OPAL_INT;
456 v2.data = &dat2;
457
458 if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) {
459 fprintf(test_out, "opal_dss.copy returned error\n");
460 return(false);
461 }
462 if (OPAL_EQUAL != opal_dss.compare(v1, &v2, type)) {
463 fprintf(test_out, "opal_dss.copy failed\n");
464 return(false);
465 }
466 return (true);
467 }
468