This source file includes following definitions.
- ipv4_test
- ranking_test
- loop_test
- test_ipv6
- main
1
2
3
4
5
6
7
8
9
10
11
12 #include "opal_config.h"
13
14 #include "reachable_shared.h"
15
16
17
18 enum connection_quality {
19 CQ_NO_CONNECTION = 0,
20 CQ_PRIVATE_DIFFERENT_NETWORK = 50,
21 CQ_PRIVATE_SAME_NETWORK = 80,
22 CQ_PUBLIC_DIFFERENT_NETWORK = 90,
23 CQ_PUBLIC_SAME_NETWORK = 100
24 };
25
26
27
28
29
30
31
32
33
34
35 int ipv4_test()
36 {
37 opal_if_t *int1;
38 opal_if_t *int2;
39 int expected_result;
40 int result;
41 int test_no = 0;
42 int failed_no = 0;
43
44
45
46
47
48
49 test_no++;
50 expected_result = CQ_PUBLIC_SAME_NETWORK;
51 int1 = create_if(AF_INET, "127.0.0.1", 24, 0);
52 int2 = create_if(AF_INET, "127.0.0.2", 0, 0);
53 result = run_single_test(int1, int2);
54 if (result != expected_result) {
55 ++failed_no;
56 opal_output(0, "Failed test #%d", test_no);
57 }
58 OBJ_RELEASE(int1);
59 OBJ_RELEASE(int2);
60
61
62
63
64
65 test_no++;
66 expected_result = CQ_PUBLIC_SAME_NETWORK;
67 int1 = create_if(AF_INET, "31.14.15.92", 24, 0);
68 int2 = create_if(AF_INET, "31.14.15.27", 0, 0);
69 result = run_single_test(int1, int2);
70
71 if (result != expected_result) {
72 ++failed_no;
73 opal_output(0, "Failed test #%d", test_no);
74 }
75 OBJ_RELEASE(int1);
76 OBJ_RELEASE(int2);
77
78
79
80
81
82 test_no++;
83 expected_result = CQ_PUBLIC_SAME_NETWORK;
84 int1 = create_if(AF_INET, "65.35.89.79", 16, 0);
85 int2 = create_if(AF_INET, "65.35.27.27", 0, 0);
86 result = run_single_test(int1, int2);
87
88 if (result != expected_result) {
89 ++failed_no;
90 opal_output(0, "Failed test #%d", test_no);
91 }
92 OBJ_RELEASE(int1);
93 OBJ_RELEASE(int2);
94
95
96
97
98
99 test_no++;
100 expected_result = CQ_PUBLIC_SAME_NETWORK;
101 int1 = create_if(AF_INET, "3.23.84.62", 8, 0);
102 int2 = create_if(AF_INET, "3.27.27.27", 0, 0);
103 result = run_single_test(int1, int2);
104
105 if (result != expected_result) {
106 ++failed_no;
107 opal_output(0, "Failed test #%d", test_no);
108 }
109 OBJ_RELEASE(int1);
110 OBJ_RELEASE(int2);
111
112
113
114
115
116 test_no++;
117 expected_result = CQ_PUBLIC_SAME_NETWORK;
118 int1 = create_if(AF_INET, "64.33.83.27", 0, 0);
119 int2 = create_if(AF_INET, "27.27.27.27", 0, 0);
120 result = run_single_test(int1, int2);
121
122 if (result != expected_result) {
123 ++failed_no;
124 opal_output(0, "Failed test #%d", test_no);
125 }
126 OBJ_RELEASE(int1);
127 OBJ_RELEASE(int2);
128
129
130
131
132
133 test_no++;
134 expected_result = CQ_PUBLIC_DIFFERENT_NETWORK;
135 int1 = create_if(AF_INET, "95.2.88.41", 24, 0);
136 int2 = create_if(AF_INET, "95.2.27.27", 0, 0);
137 result = run_single_test(int1, int2);
138
139 if (result != expected_result) {
140 ++failed_no;
141 opal_output(0, "Failed test #%d", test_no);
142 }
143 OBJ_RELEASE(int1);
144 OBJ_RELEASE(int2);
145
146
147
148
149
150 test_no++;
151 expected_result = CQ_PUBLIC_DIFFERENT_NETWORK;
152 int1 = create_if(AF_INET, "97.16.93.99", 16, 0);
153 int2 = create_if(AF_INET, "97.27.27.27", 0, 0);
154 result = run_single_test(int1, int2);
155
156 if (result != expected_result) {
157 ++failed_no;
158 opal_output(0, "Failed test #%d", test_no);
159 }
160 OBJ_RELEASE(int1);
161 OBJ_RELEASE(int2);
162
163
164
165
166
167 test_no++;
168 expected_result = CQ_PUBLIC_DIFFERENT_NETWORK;
169 int1 = create_if(AF_INET, "37.51.5.82", 8, 0);
170 int2 = create_if(AF_INET, "27.27.27.27", 0, 0);
171 result = run_single_test(int1, int2);
172
173 if (result != expected_result) {
174 ++failed_no;
175 opal_output(0, "Failed test #%d", test_no);
176 }
177 OBJ_RELEASE(int1);
178 OBJ_RELEASE(int2);
179
180
181
182
183
184 test_no++;
185 expected_result = CQ_PRIVATE_SAME_NETWORK;
186 int1 = create_if(AF_INET, "192.168.0.1", 24, 0);
187 int2 = create_if(AF_INET, "192.168.0.27", 0, 0);
188 result = run_single_test(int1, int2);
189
190 if (result != expected_result) {
191 ++failed_no;
192 opal_output(0, "Failed test #%d", test_no);
193 }
194 OBJ_RELEASE(int1);
195 OBJ_RELEASE(int2);
196
197
198
199
200
201 test_no++;
202 expected_result = CQ_PRIVATE_SAME_NETWORK;
203 int1 = create_if(AF_INET, "192.168.0.1", 16, 0);
204 int2 = create_if(AF_INET, "192.168.27.27", 0, 0);
205 result = run_single_test(int1, int2);
206
207 if (result != expected_result) {
208 ++failed_no;
209 opal_output(0, "Failed this test #%d", test_no);
210 }
211 OBJ_RELEASE(int1);
212 OBJ_RELEASE(int2);
213
214
215
216
217
218 test_no++;
219 expected_result = CQ_PRIVATE_SAME_NETWORK;
220 int1 = create_if(AF_INET, "172.16.0.1", 8, 0);
221 int2 = create_if(AF_INET, "172.27.27.27", 0, 0);
222 result = run_single_test(int1, int2);
223
224 if (result != expected_result) {
225 ++failed_no;
226 opal_output(0, "Failed this test #%d", test_no);
227 }
228 OBJ_RELEASE(int1);
229 OBJ_RELEASE(int2);
230
231
232
233
234
235 test_no++;
236 expected_result = CQ_PRIVATE_SAME_NETWORK;
237 int1 = create_if(AF_INET, "192.168.0.1", 0, 0);
238 int2 = create_if(AF_INET, "10.27.27.27", 0, 0);
239 result = run_single_test(int1, int2);
240
241 if (result != expected_result) {
242 ++failed_no;
243 opal_output(0, "Failed test #%d", test_no);
244 }
245 OBJ_RELEASE(int1);
246 OBJ_RELEASE(int2);
247
248
249
250
251
252 test_no++;
253 expected_result = CQ_PRIVATE_DIFFERENT_NETWORK;
254 int1 = create_if(AF_INET, "192.168.0.1", 24, 0);
255 int2 = create_if(AF_INET, "192.168.27.27", 0, 0);
256 result = run_single_test(int1, int2);
257
258 if (result != expected_result) {
259 ++failed_no;
260 opal_output(0, "Failed test #%d", test_no);
261 }
262 OBJ_RELEASE(int1);
263 OBJ_RELEASE(int2);
264
265
266
267
268
269 test_no++;
270 expected_result = CQ_PRIVATE_DIFFERENT_NETWORK;
271 int1 = create_if(AF_INET, "192.168.0.1", 16, 0);
272 int2 = create_if(AF_INET, "10.1.0.1", 16, 0);
273 result = run_single_test(int1, int2);
274
275 if (result != expected_result) {
276 ++failed_no;
277 opal_output(0, "Failed test #%d", test_no);
278 }
279 OBJ_RELEASE(int1);
280 OBJ_RELEASE(int2);
281
282
283
284
285
286 test_no++;
287 expected_result = CQ_PRIVATE_DIFFERENT_NETWORK;
288 int1 = create_if(AF_INET, "192.168.0.1", 8, 0);
289 int2 = create_if(AF_INET, "10.27.27.27", 0, 0);
290 result = run_single_test(int1, int2);
291
292 if (result != expected_result) {
293 ++failed_no;
294 opal_output(0, "Failed test #%d", test_no);
295 }
296 OBJ_RELEASE(int1);
297 OBJ_RELEASE(int2);
298
299
300
301
302
303 test_no++;
304 expected_result = CQ_NO_CONNECTION;
305 int1 = create_if(AF_INET, "27.27.27.27", 24 , 0);
306 int2 = create_if(AF_INET, "192.168.0.1", 16, 0);
307 result = run_single_test(int1, int2);
308
309 if (result != expected_result) {
310 ++failed_no;
311 opal_output(0, "Failed test #%d", test_no);
312 }
313 OBJ_RELEASE(int1);
314 OBJ_RELEASE(int2);
315
316
317
318
319
320 test_no++;
321 expected_result = CQ_NO_CONNECTION;
322 int1 = create_if(AF_INET, "192.168.0.1", 24, 0);
323 int2 = create_if(AF_INET, "27.27.27.27", 8, 0);
324 result = run_single_test(int1, int2);
325
326 if (result != expected_result) {
327 ++failed_no;
328 opal_output(0, "Failed test #%d", test_no);
329 }
330 OBJ_RELEASE(int1);
331 OBJ_RELEASE(int2);
332
333
334
335
336 expected_result = CQ_NO_CONNECTION;
337 int1 = create_if(AF_INET, "8.8.8.8", 24, 0);
338 int2 = create_if(AF_INET6, "2001:4860:4860:0:0:0:0:8888", 0, 0);
339 result = run_single_test(int1, int2);
340 test_no++;
341 if (result != expected_result) {
342 ++failed_no;
343 opal_output(0, "Failed test #%d", test_no);
344 }
345 OBJ_RELEASE(int1);
346 OBJ_RELEASE(int2);
347
348
349
350
351 expected_result = CQ_NO_CONNECTION;
352 int1 = create_if(AF_INET6, "2001:4860:4860:0:0:0:0:8888", 64, 0);
353 int2 = create_if(AF_INET, "8.8.8.8", 0, 0);
354 result = run_single_test(int1, int2);
355 test_no++;
356 if (result != expected_result) {
357 ++failed_no;
358 opal_output(0, "Failed test #%d", test_no);
359 }
360 OBJ_RELEASE(int1);
361 OBJ_RELEASE(int2);
362
363 opal_output(0, "Finished Reachable IPv4 Tests. %d/%d successful", test_no-failed_no, test_no);
364
365 if (0 == failed_no) {
366 return 0;
367 } else {
368 return 1;
369 }
370 }
371
372
373
374
375
376
377
378 int ranking_test()
379 {
380 opal_if_t *int1;
381 opal_if_t *int2;
382 int result1;
383 int result2;
384 int test_no = 0;
385 int failed_no = 0;
386
387
388
389
390
391
392
393
394
395
396
397
398
399 test_no++;
400
401 int1 = create_if(AF_INET, "31.14.15.92", 24, 0);
402 int2 = create_if(AF_INET, "31.14.15.27", 0, 0);
403 result1 = run_single_test(int1, int2);
404 OBJ_RELEASE(int1);
405 OBJ_RELEASE(int2);
406
407 int1 = create_if(AF_INET, "31.14.15.92", 24, 1);
408 int2 = create_if(AF_INET, "31.14.15.27", 0, 0);
409 result2 = run_single_test(int1, int2);
410 OBJ_RELEASE(int1);
411 OBJ_RELEASE(int2);
412
413 if (!(result1 > result2)) {
414 ++failed_no;
415 opal_output(0, "Failed test #%d", test_no);
416 }
417
418
419
420
421
422 test_no++;
423
424 int1 = create_if(AF_INET, "31.14.15.92", 24, 0);
425 int2 = create_if(AF_INET, "31.14.15.27", 0, 0);
426 result1 = run_single_test(int1, int2);
427 OBJ_RELEASE(int1);
428 OBJ_RELEASE(int2);
429
430 int1 = create_if(AF_INET, "31.14.15.92", 24, 1);
431 int2 = create_if(AF_INET, "31.14.15.27", 0, 2);
432 result2 = run_single_test(int1, int2);
433 OBJ_RELEASE(int1);
434 OBJ_RELEASE(int2);
435
436 if (!(result1 < result2)) {
437 ++failed_no;
438 opal_output(0, "Failed test #%d", test_no);
439 }
440
441
442
443
444
445
446 test_no++;
447
448 int1 = create_if(AF_INET, "31.14.15.92", 24, 0);
449 int2 = create_if(AF_INET, "31.14.15.27", 0, 0);
450 result1 = run_single_test(int1, int2);
451 OBJ_RELEASE(int1);
452 OBJ_RELEASE(int2);
453
454 int1 = create_if(AF_INET, "31.14.15.92", 24, 1);
455 int2 = create_if(AF_INET, "31.14.15.27", 0, 1);
456 result2 = run_single_test(int1, int2);
457 OBJ_RELEASE(int1);
458 OBJ_RELEASE(int2);
459
460 if (!(result1 < result2)) {
461 ++failed_no;
462 opal_output(0, "Failed test #%d", test_no);
463 }
464
465
466
467
468
469
470 test_no++;
471
472 int1 = create_if(AF_INET, "31.14.15.92", 24, 1);
473 int2 = create_if(AF_INET, "31.14.15.27", 0, 3);
474 result1 = run_single_test(int1, int2);
475 OBJ_RELEASE(int1);
476 OBJ_RELEASE(int2);
477
478 int1 = create_if(AF_INET, "31.14.15.92", 24, 1);
479 int2 = create_if(AF_INET, "31.14.15.27", 0, 2);
480 result2 = run_single_test(int1, int2);
481 OBJ_RELEASE(int1);
482 OBJ_RELEASE(int2);
483
484 if (!(result1 < result2)) {
485 ++failed_no;
486 opal_output(0, "Failed test #%d", test_no);
487 }
488
489
490
491
492
493
494 test_no++;
495
496 int1 = create_if(AF_INET, "31.14.15.92", 24, 1);
497 int2 = create_if(AF_INET, "31.14.15.27", 0, 10);
498 result1 = run_single_test(int1, int2);
499 OBJ_RELEASE(int1);
500 OBJ_RELEASE(int2);
501
502 int1 = create_if(AF_INET, "31.14.15.92", 24, 1);
503 int2 = create_if(AF_INET, "31.14.15.27", 0, 3);
504 result2 = run_single_test(int1, int2);
505 OBJ_RELEASE(int1);
506 OBJ_RELEASE(int2);
507
508 if (!(result1 < result2)) {
509 ++failed_no;
510 opal_output(0, "Failed test #%d", test_no);
511 }
512
513
514
515
516
517 test_no++;
518
519 int1 = create_if(AF_INET, "31.14.15.92", 24, 5);
520 int2 = create_if(AF_INET, "31.14.15.27", 0, 5);
521 result1 = run_single_test(int1, int2);
522 OBJ_RELEASE(int1);
523 OBJ_RELEASE(int2);
524
525 int1 = create_if(AF_INET, "31.14.15.92", 24, 10);
526 int2 = create_if(AF_INET, "31.14.15.27", 0, 10);
527 result2 = run_single_test(int1, int2);
528 OBJ_RELEASE(int1);
529 OBJ_RELEASE(int2);
530
531 if (!(result1 < result2)) {
532 ++failed_no;
533 opal_output(0, "Failed test #%d", test_no);
534 }
535
536
537
538
539
540
541 test_no++;
542
543 int1 = create_if(AF_INET, "31.14.15.92", 24, 10);
544 int2 = create_if(AF_INET, "31.14.15.27", 0, 11);
545 result1 = run_single_test(int1, int2);
546 OBJ_RELEASE(int1);
547 OBJ_RELEASE(int2);
548
549 int1 = create_if(AF_INET, "31.14.15.92", 24, 10);
550 int2 = create_if(AF_INET, "31.14.15.27", 0, 10);
551 result2 = run_single_test(int1, int2);
552 OBJ_RELEASE(int1);
553 OBJ_RELEASE(int2);
554
555 if (!(result1 < result2)) {
556 ++failed_no;
557 opal_output(0, "Failed test #%d", test_no);
558 }
559
560
561
562
563
564
565 test_no++;
566
567 int1 = create_if(AF_INET, "31.14.15.92", 24, 10);
568 int2 = create_if(AF_INET, "31.14.15.27", 0, 11);
569 result1 = run_single_test(int1, int2);
570 OBJ_RELEASE(int1);
571 OBJ_RELEASE(int2);
572
573 int1 = create_if(AF_INET, "31.14.15.92", 24, 11);
574 int2 = create_if(AF_INET, "31.14.15.27", 0, 10);
575 result2 = run_single_test(int1, int2);
576 OBJ_RELEASE(int1);
577 OBJ_RELEASE(int2);
578
579 if (!(result1 == result2)) {
580 ++failed_no;
581 opal_output(0, "Failed test #%d", test_no);
582 }
583
584
585
586
587
588 test_no++;
589
590 int1 = create_if(AF_INET, "31.14.15.92", 24, 10);
591 int2 = create_if(AF_INET, "31.14.15.27", 0, 14);
592 result1 = run_single_test(int1, int2);
593 OBJ_RELEASE(int1);
594 OBJ_RELEASE(int2);
595
596 int1 = create_if(AF_INET, "31.14.15.92", 24, 11);
597 int2 = create_if(AF_INET, "31.14.15.27", 0, 15);
598 result2 = run_single_test(int1, int2);
599 OBJ_RELEASE(int1);
600 OBJ_RELEASE(int2);
601
602 if (!(result1 < result2)) {
603 ++failed_no;
604 opal_output(0, "Failed test #%d", test_no);
605 }
606
607 opal_output(0, "Finished Reachable Weighted Ranking Tests. %d/%d successful", test_no-failed_no, test_no);
608 if (0 == failed_no) {
609 return 0;
610 } else {
611 return 1;
612 }
613 }
614
615
616
617
618
619
620
621 int loop_test()
622 {
623 int test_no = 0;
624 int failed_no = 0;
625
626 opal_list_t *if_list1, *if_list2;
627 opal_if_t *intf;
628 opal_reachable_t *results;
629
630 int i;
631
632
633
634
635
636 test_no++;
637
638 if_list1 = OBJ_NEW(opal_list_t);
639 if_list2 = OBJ_NEW(opal_list_t);
640
641 results = opal_reachable.reachable(if_list1, if_list2);
642
643 OBJ_RELEASE(if_list1);
644 OBJ_RELEASE(if_list2);
645
646 if (!(0 == results->num_local && 0 == results->num_remote)) {
647 ++failed_no;
648 opal_output(0, "Failed test #%d", test_no);
649 }
650 OBJ_RELEASE(results);
651
652
653
654
655
656 test_no++;
657
658 if_list1 = OBJ_NEW(opal_list_t);
659 if_list2 = OBJ_NEW(opal_list_t);
660
661 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
662 opal_list_append(if_list2, &(intf->super));
663 results = opal_reachable.reachable(if_list1, if_list2);
664
665 OBJ_RELEASE(if_list1);
666 OBJ_RELEASE(if_list2);
667
668 if (!(0 == results->num_local && 1 == results->num_remote)) {
669 ++failed_no;
670 opal_output(0, "Failed test #%d", test_no);
671 }
672 OBJ_RELEASE(results);
673
674
675
676
677
678 test_no++;
679
680 if_list1 = OBJ_NEW(opal_list_t);
681 if_list2 = OBJ_NEW(opal_list_t);
682 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
683 opal_list_append(if_list1, &(intf->super));
684 results = opal_reachable.reachable(if_list1, if_list2);
685
686 OBJ_RELEASE(if_list1);
687 OBJ_RELEASE(if_list2);
688
689 if (!(1 == results->num_local && 0 == results->num_remote)) {
690 ++failed_no;
691 opal_output(0, "Failed test #%d", test_no);
692 }
693 OBJ_RELEASE(results);
694
695
696
697
698
699
700 test_no++;
701
702 if_list1 = OBJ_NEW(opal_list_t);
703 if_list2 = OBJ_NEW(opal_list_t);
704 for (i = 0; i < 3; i++) {
705 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
706 opal_list_append(if_list1, &(intf->super));
707 }
708 for (i = 0; i < 14; i++) {
709 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
710 opal_list_append(if_list2, &(intf->super));
711 }
712 results = opal_reachable.reachable(if_list1, if_list2);
713
714 OBJ_RELEASE(if_list1);
715 OBJ_RELEASE(if_list2);
716
717 if (!(3 == results->num_local && 14 == results->num_remote)) {
718 ++failed_no;
719 opal_output(0, "Failed test #%d", test_no);
720 }
721 OBJ_RELEASE(results);
722
723
724
725
726
727
728 test_no++;
729
730 if_list1 = OBJ_NEW(opal_list_t);
731 if_list2 = OBJ_NEW(opal_list_t);
732 for (i = 0; i < 14; i++) {
733 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
734 opal_list_append(if_list1, &(intf->super));
735 }
736 for (i = 0; i < 3; i++) {
737 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
738 opal_list_append(if_list2, &(intf->super));
739 }
740 results = opal_reachable.reachable(if_list1, if_list2);
741
742 OBJ_RELEASE(if_list1);
743 OBJ_RELEASE(if_list2);
744
745 if (!(14 == results->num_local && 3 == results->num_remote)) {
746 ++failed_no;
747 opal_output(0, "Failed test #%d", test_no);
748 }
749 OBJ_RELEASE(results);
750
751
752
753
754
755
756 test_no++;
757
758 if_list1 = OBJ_NEW(opal_list_t);
759 if_list2 = OBJ_NEW(opal_list_t);
760 for (i = 0; i < 27; i++) {
761 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
762 opal_list_append(if_list1, &(intf->super));
763 }
764 for (i = 0; i < 27; i++) {
765 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
766 opal_list_append(if_list2, &(intf->super));
767 }
768 results = opal_reachable.reachable(if_list1, if_list2);
769
770 OBJ_RELEASE(if_list1);
771 OBJ_RELEASE(if_list2);
772
773 if (!(27 == results->num_local && 27 == results->num_remote)) {
774 ++failed_no;
775 opal_output(0, "Failed test #%d", test_no);
776 }
777 OBJ_RELEASE(results);
778
779
780
781
782
783
784 test_no++;
785 if_list1 = OBJ_NEW(opal_list_t);
786 if_list2 = OBJ_NEW(opal_list_t);
787
788 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
789 opal_list_append(if_list1, &(intf->super));
790 intf = create_if(AF_INET, "31.14.20.92", 24, 0);
791 opal_list_append(if_list1, &(intf->super));
792
793 intf = create_if(AF_INET, "31.14.19.93", 24, 0);
794 opal_list_append(if_list2, &(intf->super));
795 intf = create_if(AF_INET, "31.14.20.93", 24, 0);
796 opal_list_append(if_list2, &(intf->super));
797
798 results = opal_reachable.reachable(if_list1, if_list2);
799
800 OBJ_RELEASE(if_list1);
801 OBJ_RELEASE(if_list2);
802
803 if (!(CQ_PUBLIC_SAME_NETWORK == results->weights[0][0] &&
804 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[0][1] &&
805 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[1][0] &&
806 CQ_PUBLIC_SAME_NETWORK == results->weights[1][1])) {
807 ++failed_no;
808 opal_output(0, "Failed test #%d", test_no);
809 }
810 OBJ_RELEASE(results);
811
812
813
814
815
816
817 test_no++;
818 if_list1 = OBJ_NEW(opal_list_t);
819 if_list2 = OBJ_NEW(opal_list_t);
820
821 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
822 opal_list_append(if_list1, &(intf->super));
823 intf = create_if(AF_INET, "31.14.20.92", 24, 0);
824 opal_list_append(if_list1, &(intf->super));
825
826 intf = create_if(AF_INET, "31.14.19.93", 24, 0);
827 opal_list_append(if_list2, &(intf->super));
828 intf = create_if(AF_INET, "31.14.20.93", 24, 0);
829 opal_list_append(if_list2, &(intf->super));
830 intf = create_if(AF_INET, "31.14.21.93", 24, 0);
831 opal_list_append(if_list2, &(intf->super));
832
833 results = opal_reachable.reachable(if_list1, if_list2);
834
835 OBJ_RELEASE(if_list1);
836 OBJ_RELEASE(if_list2);
837
838 if (!(CQ_PUBLIC_SAME_NETWORK == results->weights[0][0] &&
839 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[0][1] &&
840 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[0][2] &&
841 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[1][0] &&
842 CQ_PUBLIC_SAME_NETWORK == results->weights[1][1]) &&
843 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[1][2]) {
844 ++failed_no;
845 opal_output(0, "Failed test #%d", test_no);
846 }
847 OBJ_RELEASE(results);
848
849
850
851
852
853
854 test_no++;
855 if_list1 = OBJ_NEW(opal_list_t);
856 if_list2 = OBJ_NEW(opal_list_t);
857
858 intf = create_if(AF_INET, "31.14.19.92", 24, 0);
859 opal_list_append(if_list1, &(intf->super));
860 intf = create_if(AF_INET, "31.14.20.92", 24, 0);
861 opal_list_append(if_list1, &(intf->super));
862 intf = create_if(AF_INET, "31.14.21.93", 24, 0);
863 opal_list_append(if_list1, &(intf->super));
864
865 intf = create_if(AF_INET, "31.14.19.93", 24, 0);
866 opal_list_append(if_list2, &(intf->super));
867 intf = create_if(AF_INET, "31.14.20.93", 24, 0);
868 opal_list_append(if_list2, &(intf->super));
869
870 results = opal_reachable.reachable(if_list1, if_list2);
871
872 OBJ_RELEASE(if_list1);
873 OBJ_RELEASE(if_list2);
874
875 if (!(CQ_PUBLIC_SAME_NETWORK == results->weights[0][0] &&
876 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[0][1] &&
877 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[1][0] &&
878 CQ_PUBLIC_SAME_NETWORK == results->weights[1][1] &&
879 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[2][0]) &&
880 CQ_PUBLIC_DIFFERENT_NETWORK == results->weights[2][1]) {
881 ++failed_no;
882 opal_output(0, "Failed test #%d", test_no);
883 }
884 OBJ_RELEASE(results);
885
886 opal_output(0, "Finished Reachable Weighted Loop Tests. %d/%d successful", test_no-failed_no, test_no);
887
888 if (0 == failed_no) {
889 return 0;
890 } else {
891 return 1;
892 }
893
894 }
895
896
897
898
899
900 int test_ipv6()
901 {
902 int failed_no = 0;
903
904 #if OPAL_ENABLE_IPV6
905 opal_if_t *int1;
906 opal_if_t *int2;
907 int expected_result;
908 int result;
909 int test_no = 0;
910
911
912
913
914
915 expected_result = CQ_PUBLIC_SAME_NETWORK;
916 int1 = create_if(AF_INET6, "2001:4860:4860:0:0:0:0:8888", 64, 0);
917 int2 = create_if(AF_INET6, "2001:4860:4860:0:0:0:0:8889", 8, 0);
918 result = run_single_test(int1, int2);
919 test_no++;
920 if (result != expected_result) {
921 ++failed_no;
922 opal_output(0, "Failed test #%d", test_no);
923 }
924 OBJ_RELEASE(int1);
925 OBJ_RELEASE(int2);
926
927
928
929
930
931 expected_result = CQ_PUBLIC_DIFFERENT_NETWORK;
932 int1 = create_if(AF_INET6, "2001:4860:4860:0:0:0:0:8888", 64, 0);
933 int2 = create_if(AF_INET6, "2001:4860:4860:1:0:0:0:8888", 0, 0);
934 result = run_single_test(int1, int2);
935 test_no++;
936 if (result != expected_result) {
937 ++failed_no;
938 opal_output(0, "Failed test #%d", test_no);
939 }
940 OBJ_RELEASE(int1);
941 OBJ_RELEASE(int2);
942
943 expected_result = CQ_PRIVATE_SAME_NETWORK;
944 int1 = create_if(AF_INET6, "fe80::8888", 64, 0);
945 int2 = create_if(AF_INET6, "fe80::8889", 64, 0);
946 result = run_single_test(int1, int2);
947 test_no++;
948 if (result != expected_result) {
949 ++failed_no;
950 opal_output(0, "Failed test #%d", test_no);
951 }
952 OBJ_RELEASE(int1);
953 OBJ_RELEASE(int2);
954
955 expected_result = CQ_NO_CONNECTION;
956 int1 = create_if(AF_INET6, "2001::8888", 64, 0);
957 int2 = create_if(AF_INET6, "fe80::8889", 64, 0);
958 result = run_single_test(int1, int2);
959 test_no++;
960 if (result != expected_result) {
961 ++failed_no;
962 opal_output(0, "Failed test #%d", test_no);
963 }
964 OBJ_RELEASE(int1);
965 OBJ_RELEASE(int2);
966
967 opal_output(0, "Finished Reachable Weighted IPv6 Tests. %d/%d successful", test_no-failed_no, test_no);
968
969 if (0 == failed_no) {
970 return 0;
971 } else {
972 return 1;
973 }
974 #else
975 opal_output(0, "No IPv6 support; skipped tests");
976 return 0;
977 #endif
978 }
979
980 int main(int argc, char **argv)
981 {
982 int failed = 0;
983 int total = 0;
984
985 opal_init(&argc, &argv);
986 opal_output(0, "\n\nBeginning Reachable Weighted tests\n\n");
987
988 total++;
989 if (ipv4_test()) {
990 failed++;
991 }
992
993 total++;
994 if (ranking_test()) {
995 failed++;
996 }
997
998 total++;
999 if (loop_test()) {
1000 failed++;
1001 }
1002
1003 total++;
1004 if (test_ipv6()) {
1005 failed++;
1006 }
1007
1008 if (0 != failed) {
1009 opal_output(0, "\n\nFailed %d/%d Reachable Weighted Test Suites :(\n\n", failed, total);
1010 } else {
1011 opal_output(0, "\n\nPassed %d/%d Reachable Weighted Test Suites :)\n\n", total, total);
1012 }
1013
1014 return failed;
1015 }