Lines Matching full:test

9 #include <kunit/test.h>
31 static void kunit_ida_init(struct kunit *test, struct ida *ida) in kunit_ida_init() argument
33 kunit_alloc_resource(test, __ida_init, __ida_destroy, GFP_KERNEL, ida); in kunit_ida_init()
36 static struct tb_switch *alloc_switch(struct kunit *test, u64 route, in alloc_switch() argument
43 sw = kunit_kzalloc(test, sizeof(*sw), GFP_KERNEL); in alloc_switch()
55 sw->ports = kunit_kzalloc(test, size, GFP_KERNEL); in alloc_switch()
64 kunit_ida_init(test, &sw->ports[i].in_hopids); in alloc_switch()
65 kunit_ida_init(test, &sw->ports[i].out_hopids); in alloc_switch()
72 static struct tb_switch *alloc_host(struct kunit *test) in alloc_host() argument
76 sw = alloc_switch(test, 0, 7, 13); in alloc_host()
145 static struct tb_switch *alloc_dev_default(struct kunit *test, in alloc_dev_default() argument
152 sw = alloc_switch(test, route, 1, 19); in alloc_dev_default()
275 static struct tb_switch *alloc_dev_with_dpin(struct kunit *test, in alloc_dev_with_dpin() argument
281 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_with_dpin()
296 static void tb_test_path_basic(struct kunit *test) in tb_test_path_basic() argument
301 host = alloc_host(test); in tb_test_path_basic()
307 KUNIT_EXPECT_PTR_EQ(test, p, dst_port); in tb_test_path_basic()
310 KUNIT_EXPECT_TRUE(test, !p); in tb_test_path_basic()
313 static void tb_test_path_not_connected_walk(struct kunit *test) in tb_test_path_not_connected_walk() argument
318 host = alloc_host(test); in tb_test_path_not_connected_walk()
320 dev = alloc_dev_default(test, NULL, 3, true); in tb_test_path_not_connected_walk()
326 KUNIT_EXPECT_PTR_EQ(test, p, src_port); in tb_test_path_not_connected_walk()
329 KUNIT_EXPECT_PTR_EQ(test, p, &host->ports[3]); in tb_test_path_not_connected_walk()
332 KUNIT_EXPECT_TRUE(test, !p); in tb_test_path_not_connected_walk()
337 KUNIT_EXPECT_PTR_EQ(test, p, dst_port); in tb_test_path_not_connected_walk()
340 KUNIT_EXPECT_PTR_EQ(test, p, &dev->ports[1]); in tb_test_path_not_connected_walk()
343 KUNIT_EXPECT_TRUE(test, !p); in tb_test_path_not_connected_walk()
352 static void tb_test_path_single_hop_walk(struct kunit *test) in tb_test_path_single_hop_walk() argument
373 host = alloc_host(test); in tb_test_path_single_hop_walk()
374 dev = alloc_dev_default(test, host, 1, true); in tb_test_path_single_hop_walk()
383 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_single_hop_walk()
384 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
385 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_single_hop_walk()
386 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_single_hop_walk()
391 KUNIT_EXPECT_EQ(test, i, (int)ARRAY_SIZE(test_data)); in tb_test_path_single_hop_walk()
395 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_single_hop_walk()
396 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
397 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_single_hop_walk()
398 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_single_hop_walk()
403 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_single_hop_walk()
406 static void tb_test_path_daisy_chain_walk(struct kunit *test) in tb_test_path_daisy_chain_walk() argument
431 host = alloc_host(test); in tb_test_path_daisy_chain_walk()
432 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_daisy_chain_walk()
433 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_daisy_chain_walk()
442 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_daisy_chain_walk()
443 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
444 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_daisy_chain_walk()
445 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_daisy_chain_walk()
450 KUNIT_EXPECT_EQ(test, i, (int)ARRAY_SIZE(test_data)); in tb_test_path_daisy_chain_walk()
454 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_daisy_chain_walk()
455 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
456 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_daisy_chain_walk()
457 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_daisy_chain_walk()
462 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_daisy_chain_walk()
465 static void tb_test_path_simple_tree_walk(struct kunit *test) in tb_test_path_simple_tree_walk() argument
492 host = alloc_host(test); in tb_test_path_simple_tree_walk()
493 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_simple_tree_walk()
494 alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_simple_tree_walk()
495 dev3 = alloc_dev_default(test, dev1, 0x501, true); in tb_test_path_simple_tree_walk()
496 alloc_dev_default(test, dev1, 0x701, true); in tb_test_path_simple_tree_walk()
505 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_simple_tree_walk()
506 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
507 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_simple_tree_walk()
508 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_simple_tree_walk()
513 KUNIT_EXPECT_EQ(test, i, (int)ARRAY_SIZE(test_data)); in tb_test_path_simple_tree_walk()
517 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_simple_tree_walk()
518 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
519 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_simple_tree_walk()
520 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_simple_tree_walk()
525 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_simple_tree_walk()
528 static void tb_test_path_complex_tree_walk(struct kunit *test) in tb_test_path_complex_tree_walk() argument
571 host = alloc_host(test); in tb_test_path_complex_tree_walk()
572 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_complex_tree_walk()
573 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_complex_tree_walk()
574 dev3 = alloc_dev_with_dpin(test, dev2, 0x50301, true); in tb_test_path_complex_tree_walk()
575 alloc_dev_default(test, dev1, 0x501, true); in tb_test_path_complex_tree_walk()
576 dev5 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_path_complex_tree_walk()
577 dev6 = alloc_dev_default(test, dev5, 0x70701, true); in tb_test_path_complex_tree_walk()
578 dev7 = alloc_dev_default(test, dev6, 0x3070701, true); in tb_test_path_complex_tree_walk()
579 alloc_dev_default(test, dev7, 0x303070701, true); in tb_test_path_complex_tree_walk()
580 dev9 = alloc_dev_default(test, dev7, 0x503070701, true); in tb_test_path_complex_tree_walk()
589 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_complex_tree_walk()
590 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
591 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_complex_tree_walk()
592 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_complex_tree_walk()
597 KUNIT_EXPECT_EQ(test, i, (int)ARRAY_SIZE(test_data)); in tb_test_path_complex_tree_walk()
601 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_complex_tree_walk()
602 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
603 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_complex_tree_walk()
604 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_complex_tree_walk()
609 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_complex_tree_walk()
612 static void tb_test_path_max_length_walk(struct kunit *test) in tb_test_path_max_length_walk() argument
671 host = alloc_host(test); in tb_test_path_max_length_walk()
672 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_max_length_walk()
673 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_max_length_walk()
674 dev3 = alloc_dev_default(test, dev2, 0x30301, true); in tb_test_path_max_length_walk()
675 dev4 = alloc_dev_default(test, dev3, 0x3030301, true); in tb_test_path_max_length_walk()
676 dev5 = alloc_dev_default(test, dev4, 0x303030301, true); in tb_test_path_max_length_walk()
677 dev6 = alloc_dev_with_dpin(test, dev5, 0x30303030301, true); in tb_test_path_max_length_walk()
678 dev7 = alloc_dev_default(test, host, 0x3, true); in tb_test_path_max_length_walk()
679 dev8 = alloc_dev_default(test, dev7, 0x303, true); in tb_test_path_max_length_walk()
680 dev9 = alloc_dev_default(test, dev8, 0x30303, true); in tb_test_path_max_length_walk()
681 dev10 = alloc_dev_default(test, dev9, 0x3030303, true); in tb_test_path_max_length_walk()
682 dev11 = alloc_dev_default(test, dev10, 0x303030303, true); in tb_test_path_max_length_walk()
683 dev12 = alloc_dev_default(test, dev11, 0x30303030303, true); in tb_test_path_max_length_walk()
692 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_max_length_walk()
693 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
694 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_max_length_walk()
695 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_max_length_walk()
700 KUNIT_EXPECT_EQ(test, i, (int)ARRAY_SIZE(test_data)); in tb_test_path_max_length_walk()
704 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_max_length_walk()
705 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
706 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_max_length_walk()
707 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_max_length_walk()
712 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_max_length_walk()
715 static void tb_test_path_not_connected(struct kunit *test) in tb_test_path_not_connected() argument
721 host = alloc_host(test); in tb_test_path_not_connected()
722 dev1 = alloc_dev_default(test, host, 0x3, false); in tb_test_path_not_connected()
724 dev2 = alloc_dev_default(test, NULL, 0x303, false); in tb_test_path_not_connected()
730 KUNIT_ASSERT_TRUE(test, path == NULL); in tb_test_path_not_connected()
732 KUNIT_ASSERT_TRUE(test, path == NULL); in tb_test_path_not_connected()
743 static void tb_test_path_not_bonded_lane0(struct kunit *test) in tb_test_path_not_bonded_lane0() argument
774 host = alloc_host(test); in tb_test_path_not_bonded_lane0()
775 dev = alloc_dev_default(test, host, 0x3, false); in tb_test_path_not_bonded_lane0()
781 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_not_bonded_lane0()
782 KUNIT_ASSERT_EQ(test, path->path_length, (int)ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane0()
789 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
790 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane0()
791 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane0()
793 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
794 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane0()
795 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane0()
801 static void tb_test_path_not_bonded_lane1(struct kunit *test) in tb_test_path_not_bonded_lane1() argument
836 host = alloc_host(test); in tb_test_path_not_bonded_lane1()
837 dev = alloc_dev_default(test, host, 0x1, false); in tb_test_path_not_bonded_lane1()
843 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_not_bonded_lane1()
844 KUNIT_ASSERT_EQ(test, path->path_length, (int)ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane1()
851 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
852 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane1()
853 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane1()
855 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
856 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane1()
857 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane1()
863 static void tb_test_path_not_bonded_lane1_chain(struct kunit *test) in tb_test_path_not_bonded_lane1_chain() argument
914 host = alloc_host(test); in tb_test_path_not_bonded_lane1_chain()
915 dev1 = alloc_dev_default(test, host, 0x1, false); in tb_test_path_not_bonded_lane1_chain()
916 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_not_bonded_lane1_chain()
917 dev3 = alloc_dev_default(test, dev2, 0x50701, false); in tb_test_path_not_bonded_lane1_chain()
923 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_not_bonded_lane1_chain()
924 KUNIT_ASSERT_EQ(test, path->path_length, (int)ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane1_chain()
931 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
932 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane1_chain()
933 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane1_chain()
935 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
936 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane1_chain()
937 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane1_chain()
943 static void tb_test_path_not_bonded_lane1_chain_reverse(struct kunit *test) in tb_test_path_not_bonded_lane1_chain_reverse() argument
994 host = alloc_host(test); in tb_test_path_not_bonded_lane1_chain_reverse()
995 dev1 = alloc_dev_default(test, host, 0x1, false); in tb_test_path_not_bonded_lane1_chain_reverse()
996 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_not_bonded_lane1_chain_reverse()
997 dev3 = alloc_dev_with_dpin(test, dev2, 0x50701, false); in tb_test_path_not_bonded_lane1_chain_reverse()
1003 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_not_bonded_lane1_chain_reverse()
1004 KUNIT_ASSERT_EQ(test, path->path_length, (int)ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane1_chain_reverse()
1011 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1012 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane1_chain_reverse()
1013 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane1_chain_reverse()
1015 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1016 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane1_chain_reverse()
1017 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane1_chain_reverse()
1023 static void tb_test_path_mixed_chain(struct kunit *test) in tb_test_path_mixed_chain() argument
1085 host = alloc_host(test); in tb_test_path_mixed_chain()
1086 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_mixed_chain()
1087 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_mixed_chain()
1088 dev3 = alloc_dev_default(test, dev2, 0x50701, false); in tb_test_path_mixed_chain()
1089 dev4 = alloc_dev_default(test, dev3, 0x3050701, true); in tb_test_path_mixed_chain()
1095 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_mixed_chain()
1096 KUNIT_ASSERT_EQ(test, path->path_length, (int)ARRAY_SIZE(test_data)); in tb_test_path_mixed_chain()
1103 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1104 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_mixed_chain()
1105 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_mixed_chain()
1107 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1108 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_mixed_chain()
1109 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_mixed_chain()
1115 static void tb_test_path_mixed_chain_reverse(struct kunit *test) in tb_test_path_mixed_chain_reverse() argument
1177 host = alloc_host(test); in tb_test_path_mixed_chain_reverse()
1178 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_mixed_chain_reverse()
1179 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_mixed_chain_reverse()
1180 dev3 = alloc_dev_default(test, dev2, 0x50701, false); in tb_test_path_mixed_chain_reverse()
1181 dev4 = alloc_dev_default(test, dev3, 0x3050701, true); in tb_test_path_mixed_chain_reverse()
1187 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_mixed_chain_reverse()
1188 KUNIT_ASSERT_EQ(test, path->path_length, (int)ARRAY_SIZE(test_data)); in tb_test_path_mixed_chain_reverse()
1195 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()
1196 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_mixed_chain_reverse()
1197 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_mixed_chain_reverse()
1199 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()
1200 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_mixed_chain_reverse()
1201 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_mixed_chain_reverse()
1207 static void tb_test_tunnel_pcie(struct kunit *test) in tb_test_tunnel_pcie() argument
1224 host = alloc_host(test); in tb_test_tunnel_pcie()
1225 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_pcie()
1226 dev2 = alloc_dev_default(test, dev1, 0x501, true); in tb_test_tunnel_pcie()
1231 KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); in tb_test_tunnel_pcie()
1232 KUNIT_EXPECT_EQ(test, tunnel1->type, (enum tb_tunnel_type)TB_TUNNEL_PCI); in tb_test_tunnel_pcie()
1233 KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, down); in tb_test_tunnel_pcie()
1234 KUNIT_EXPECT_PTR_EQ(test, tunnel1->dst_port, up); in tb_test_tunnel_pcie()
1235 KUNIT_ASSERT_EQ(test, tunnel1->npaths, (size_t)2); in tb_test_tunnel_pcie()
1236 KUNIT_ASSERT_EQ(test, tunnel1->paths[0]->path_length, 2); in tb_test_tunnel_pcie()
1237 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[0].in_port, down); in tb_test_tunnel_pcie()
1238 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[1].out_port, up); in tb_test_tunnel_pcie()
1239 KUNIT_ASSERT_EQ(test, tunnel1->paths[1]->path_length, 2); in tb_test_tunnel_pcie()
1240 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[0].in_port, up); in tb_test_tunnel_pcie()
1241 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[1].out_port, down); in tb_test_tunnel_pcie()
1246 KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); in tb_test_tunnel_pcie()
1247 KUNIT_EXPECT_EQ(test, tunnel2->type, (enum tb_tunnel_type)TB_TUNNEL_PCI); in tb_test_tunnel_pcie()
1248 KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, down); in tb_test_tunnel_pcie()
1249 KUNIT_EXPECT_PTR_EQ(test, tunnel2->dst_port, up); in tb_test_tunnel_pcie()
1250 KUNIT_ASSERT_EQ(test, tunnel2->npaths, (size_t)2); in tb_test_tunnel_pcie()
1251 KUNIT_ASSERT_EQ(test, tunnel2->paths[0]->path_length, 2); in tb_test_tunnel_pcie()
1252 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[0].in_port, down); in tb_test_tunnel_pcie()
1253 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[1].out_port, up); in tb_test_tunnel_pcie()
1254 KUNIT_ASSERT_EQ(test, tunnel2->paths[1]->path_length, 2); in tb_test_tunnel_pcie()
1255 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[0].in_port, up); in tb_test_tunnel_pcie()
1256 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[1].out_port, down); in tb_test_tunnel_pcie()
1262 static void tb_test_tunnel_dp(struct kunit *test) in tb_test_tunnel_dp() argument
1276 host = alloc_host(test); in tb_test_tunnel_dp()
1277 dev = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_dp()
1283 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dp()
1284 KUNIT_EXPECT_EQ(test, tunnel->type, (enum tb_tunnel_type)TB_TUNNEL_DP); in tb_test_tunnel_dp()
1285 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp()
1286 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp()
1287 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)3); in tb_test_tunnel_dp()
1288 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 2); in tb_test_tunnel_dp()
1289 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp()
1290 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[1].out_port, out); in tb_test_tunnel_dp()
1291 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 2); in tb_test_tunnel_dp()
1292 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp()
1293 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[1].out_port, out); in tb_test_tunnel_dp()
1294 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 2); in tb_test_tunnel_dp()
1295 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp()
1296 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[1].out_port, in); in tb_test_tunnel_dp()
1300 static void tb_test_tunnel_dp_chain(struct kunit *test) in tb_test_tunnel_dp_chain() argument
1319 host = alloc_host(test); in tb_test_tunnel_dp_chain()
1320 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_dp_chain()
1321 alloc_dev_default(test, dev1, 0x301, true); in tb_test_tunnel_dp_chain()
1322 alloc_dev_default(test, dev1, 0x501, true); in tb_test_tunnel_dp_chain()
1323 dev4 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_tunnel_dp_chain()
1329 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dp_chain()
1330 KUNIT_EXPECT_EQ(test, tunnel->type, (enum tb_tunnel_type)TB_TUNNEL_DP); in tb_test_tunnel_dp_chain()
1331 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp_chain()
1332 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp_chain()
1333 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)3); in tb_test_tunnel_dp_chain()
1334 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 3); in tb_test_tunnel_dp_chain()
1335 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp_chain()
1336 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[2].out_port, out); in tb_test_tunnel_dp_chain()
1337 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 3); in tb_test_tunnel_dp_chain()
1338 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp_chain()
1339 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[2].out_port, out); in tb_test_tunnel_dp_chain()
1340 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 3); in tb_test_tunnel_dp_chain()
1341 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp_chain()
1342 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[2].out_port, in); in tb_test_tunnel_dp_chain()
1346 static void tb_test_tunnel_dp_tree(struct kunit *test) in tb_test_tunnel_dp_tree() argument
1368 host = alloc_host(test); in tb_test_tunnel_dp_tree()
1369 dev1 = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_dp_tree()
1370 dev2 = alloc_dev_with_dpin(test, dev1, 0x303, true); in tb_test_tunnel_dp_tree()
1371 dev3 = alloc_dev_default(test, dev1, 0x503, true); in tb_test_tunnel_dp_tree()
1372 alloc_dev_default(test, dev1, 0x703, true); in tb_test_tunnel_dp_tree()
1373 dev5 = alloc_dev_default(test, dev3, 0x50503, true); in tb_test_tunnel_dp_tree()
1379 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dp_tree()
1380 KUNIT_EXPECT_EQ(test, tunnel->type, (enum tb_tunnel_type)TB_TUNNEL_DP); in tb_test_tunnel_dp_tree()
1381 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp_tree()
1382 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp_tree()
1383 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)3); in tb_test_tunnel_dp_tree()
1384 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 4); in tb_test_tunnel_dp_tree()
1385 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp_tree()
1386 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[3].out_port, out); in tb_test_tunnel_dp_tree()
1387 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 4); in tb_test_tunnel_dp_tree()
1388 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp_tree()
1389 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[3].out_port, out); in tb_test_tunnel_dp_tree()
1390 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 4); in tb_test_tunnel_dp_tree()
1391 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp_tree()
1392 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[3].out_port, in); in tb_test_tunnel_dp_tree()
1396 static void tb_test_tunnel_dp_max_length(struct kunit *test) in tb_test_tunnel_dp_max_length() argument
1426 host = alloc_host(test); in tb_test_tunnel_dp_max_length()
1427 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_dp_max_length()
1428 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_tunnel_dp_max_length()
1429 dev3 = alloc_dev_default(test, dev2, 0x30301, true); in tb_test_tunnel_dp_max_length()
1430 dev4 = alloc_dev_default(test, dev3, 0x3030301, true); in tb_test_tunnel_dp_max_length()
1431 dev5 = alloc_dev_default(test, dev4, 0x303030301, true); in tb_test_tunnel_dp_max_length()
1432 dev6 = alloc_dev_with_dpin(test, dev5, 0x30303030301, true); in tb_test_tunnel_dp_max_length()
1433 dev7 = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_dp_max_length()
1434 dev8 = alloc_dev_default(test, dev7, 0x303, true); in tb_test_tunnel_dp_max_length()
1435 dev9 = alloc_dev_default(test, dev8, 0x30303, true); in tb_test_tunnel_dp_max_length()
1436 dev10 = alloc_dev_default(test, dev9, 0x3030303, true); in tb_test_tunnel_dp_max_length()
1437 dev11 = alloc_dev_default(test, dev10, 0x303030303, true); in tb_test_tunnel_dp_max_length()
1438 dev12 = alloc_dev_default(test, dev11, 0x30303030303, true); in tb_test_tunnel_dp_max_length()
1444 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dp_max_length()
1445 KUNIT_EXPECT_EQ(test, tunnel->type, (enum tb_tunnel_type)TB_TUNNEL_DP); in tb_test_tunnel_dp_max_length()
1446 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp_max_length()
1447 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp_max_length()
1448 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)3); in tb_test_tunnel_dp_max_length()
1449 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 13); in tb_test_tunnel_dp_max_length()
1451 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp_max_length()
1453 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[6].in_port, in tb_test_tunnel_dp_max_length()
1455 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[6].out_port, in tb_test_tunnel_dp_max_length()
1458 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[12].out_port, out); in tb_test_tunnel_dp_max_length()
1459 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 13); in tb_test_tunnel_dp_max_length()
1460 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp_max_length()
1461 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[6].in_port, in tb_test_tunnel_dp_max_length()
1463 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[6].out_port, in tb_test_tunnel_dp_max_length()
1465 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[12].out_port, out); in tb_test_tunnel_dp_max_length()
1466 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 13); in tb_test_tunnel_dp_max_length()
1467 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp_max_length()
1468 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[6].in_port, in tb_test_tunnel_dp_max_length()
1470 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[6].out_port, in tb_test_tunnel_dp_max_length()
1472 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[12].out_port, in); in tb_test_tunnel_dp_max_length()
1476 static void tb_test_tunnel_usb3(struct kunit *test) in tb_test_tunnel_usb3() argument
1493 host = alloc_host(test); in tb_test_tunnel_usb3()
1494 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_usb3()
1495 dev2 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_tunnel_usb3()
1500 KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); in tb_test_tunnel_usb3()
1501 KUNIT_EXPECT_EQ(test, tunnel1->type, (enum tb_tunnel_type)TB_TUNNEL_USB3); in tb_test_tunnel_usb3()
1502 KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, down); in tb_test_tunnel_usb3()
1503 KUNIT_EXPECT_PTR_EQ(test, tunnel1->dst_port, up); in tb_test_tunnel_usb3()
1504 KUNIT_ASSERT_EQ(test, tunnel1->npaths, (size_t)2); in tb_test_tunnel_usb3()
1505 KUNIT_ASSERT_EQ(test, tunnel1->paths[0]->path_length, 2); in tb_test_tunnel_usb3()
1506 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[0].in_port, down); in tb_test_tunnel_usb3()
1507 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[1].out_port, up); in tb_test_tunnel_usb3()
1508 KUNIT_ASSERT_EQ(test, tunnel1->paths[1]->path_length, 2); in tb_test_tunnel_usb3()
1509 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[0].in_port, up); in tb_test_tunnel_usb3()
1510 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[1].out_port, down); in tb_test_tunnel_usb3()
1515 KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); in tb_test_tunnel_usb3()
1516 KUNIT_EXPECT_EQ(test, tunnel2->type, (enum tb_tunnel_type)TB_TUNNEL_USB3); in tb_test_tunnel_usb3()
1517 KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, down); in tb_test_tunnel_usb3()
1518 KUNIT_EXPECT_PTR_EQ(test, tunnel2->dst_port, up); in tb_test_tunnel_usb3()
1519 KUNIT_ASSERT_EQ(test, tunnel2->npaths, (size_t)2); in tb_test_tunnel_usb3()
1520 KUNIT_ASSERT_EQ(test, tunnel2->paths[0]->path_length, 2); in tb_test_tunnel_usb3()
1521 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[0].in_port, down); in tb_test_tunnel_usb3()
1522 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[1].out_port, up); in tb_test_tunnel_usb3()
1523 KUNIT_ASSERT_EQ(test, tunnel2->paths[1]->path_length, 2); in tb_test_tunnel_usb3()
1524 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[0].in_port, up); in tb_test_tunnel_usb3()
1525 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[1].out_port, down); in tb_test_tunnel_usb3()
1531 static void tb_test_tunnel_port_on_path(struct kunit *test) in tb_test_tunnel_port_on_path() argument
1551 host = alloc_host(test); in tb_test_tunnel_port_on_path()
1552 dev1 = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_port_on_path()
1553 dev2 = alloc_dev_with_dpin(test, dev1, 0x303, true); in tb_test_tunnel_port_on_path()
1554 dev3 = alloc_dev_default(test, dev1, 0x503, true); in tb_test_tunnel_port_on_path()
1555 dev4 = alloc_dev_default(test, dev1, 0x703, true); in tb_test_tunnel_port_on_path()
1556 dev5 = alloc_dev_default(test, dev3, 0x50503, true); in tb_test_tunnel_port_on_path()
1562 KUNIT_ASSERT_TRUE(test, dp_tunnel != NULL); in tb_test_tunnel_port_on_path()
1564 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, in)); in tb_test_tunnel_port_on_path()
1565 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, out)); in tb_test_tunnel_port_on_path()
1568 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1571 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1574 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1577 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1580 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1583 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1586 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1589 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1592 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()