From 31375299d19d067cc4eb24ecf4bce2f95c0ef241 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 7 Jul 2009 09:57:01 +0200 Subject: [PATCH] Disable some tests when some features (dot1, dot3, lldpmed) are not enabled. --- tests/check_lldp.c | 62 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/tests/check_lldp.c b/tests/check_lldp.c index 810cebf3..42ebb133 100644 --- a/tests/check_lldp.c +++ b/tests/check_lldp.c @@ -123,7 +123,9 @@ setup() /* Prepare hardware */ memset(&hardware, 0, sizeof(struct lldpd_hardware)); TAILQ_INIT(&hardware.h_rports); +#ifdef ENABLE_DOT1 TAILQ_INIT(&hardware.h_lport.p_vlans); +#endif hardware.h_mtu = 1500; hardware.h_ifindex = 1; strcpy(hardware.h_ifname, "test"); @@ -241,11 +243,15 @@ Link Layer Discovery Protocol 0x6f, 0x6e, 0x0e, 0x04, 0x00, 0x10, 0x00, 0x10, 0x08, 0x15, 0x46, 0x61, 0x6b, 0x65, 0x20, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0xfe, - 0x09, 0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, +#ifdef ENABLE_DOT3 + 0xfe, 0x09, + 0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x00, - 0x12, 0x0f, 0x04, 0x05, 0xec, 0x00, 0x00 }; + 0x12, 0x0f, 0x04, 0x05, 0xec, +#endif + 0x00, 0x00 }; struct packet *pkt; /* Populate port and chassis */ @@ -278,6 +284,7 @@ Link Layer Discovery Protocol } END_TEST +#ifdef ENABLE_DOT1 START_TEST (test_send_vlan) { int n; @@ -399,11 +406,15 @@ Link Layer Discovery Protocol 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x56, 0x4c, 0x41, 0x4e, 0xfe, 0x11, 0x00, 0x80, 0xc2, 0x03, 0x02, 0xe5, 0x0a, 0x54, 0x68, 0x69, 0x72, - 0x64, 0x20, 0x56, 0x4c, 0x41, 0x4e, 0xfe, 0x09, + 0x64, 0x20, 0x56, 0x4c, 0x41, 0x4e, +#ifdef ENABLE_DOT3 + 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x00, 0x12, - 0x0f, 0x04, 0x05, 0xec, 0x00, 0x00 }; + 0x0f, 0x04, 0x05, 0xec, +#endif + 0x00, 0x00 }; struct packet *pkt; /* Populate port and chassis */ @@ -442,7 +453,9 @@ Link Layer Discovery Protocol fail_unless(TAILQ_NEXT(pkt, next) == NULL, "more than one packet sent"); } END_TEST +#endif +#ifdef ENABLE_LLDPMED START_TEST (test_send_med) { int n; @@ -598,11 +611,15 @@ Link Layer Discovery Protocol 0x00, 0x14, 0x00, 0x10, 0x08, 0x15, 0x46, 0x61, 0x6b, 0x65, 0x20, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0xfe, 0x09, 0x00, 0x12, 0x0f, + 0x69, 0x6f, 0x6e, +#ifdef ENABLE_DOT3 + 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x00, 0x12, 0x0f, 0x04, 0x05, - 0xec, 0xfe, 0x07, 0x00, 0x12, 0xbb, 0x01, 0x00, + 0xec, +#endif + 0xfe, 0x07, 0x00, 0x12, 0xbb, 0x01, 0x00, 0x2f, 0x03, 0xfe, 0x12, 0x00, 0x12, 0xbb, 0x05, 0x68, 0x61, 0x72, 0x64, 0x77, 0x61, 0x72, 0x65, 0x20, 0x72, 0x65, 0x76, 0x20, 0x35, 0xfe, 0x08, @@ -678,7 +695,9 @@ Link Layer Discovery Protocol fail_unless(TAILQ_NEXT(pkt, next) == NULL, "more than one packet sent"); } END_TEST +#endif +#ifdef ENABLE_DOT3 START_TEST (test_send_dot3) { int n; @@ -817,6 +836,7 @@ Link Layer Discovery Protocol fail_unless(TAILQ_NEXT(pkt, next) == NULL, "more than one packet sent"); } END_TEST +#endif START_TEST (test_recv_min) { @@ -1089,6 +1109,7 @@ Link Layer Discovery Protocol ck_assert_int_eq(nchassis->c_mgmt.s_addr, (u_int32_t)inet_addr("10.238.80.75")); ck_assert_int_eq(nchassis->c_mgmt_if, 3); +#ifdef ENABLE_DOT3 ck_assert_int_eq(nport->p_aggregid, 0); ck_assert_int_eq(nport->p_autoneg_enabled, 1); ck_assert_int_eq(nport->p_autoneg_support, 1); @@ -1102,6 +1123,8 @@ Link Layer Discovery Protocol ck_assert_int_eq(nport->p_mau_type, LLDP_DOT3_MAU_100BASETXFD); ck_assert_int_eq(nport->p_mfs, 1500); +#endif +#ifdef ENABLE_LLDPMED ck_assert_int_eq(nchassis->c_med_type, 0); ck_assert_str_eq(nchassis->c_med_hw, "ND991789702"); ck_assert_str_eq(nchassis->c_med_fw, "080012 "); /* Extra space */ @@ -1110,9 +1133,11 @@ Link Layer Discovery Protocol ck_assert_str_eq(nchassis->c_med_manuf, "NEC Computers SAS"); ck_assert_str_eq(nchassis->c_med_model, "POWERMATE VL350"); ck_assert_str_eq(nchassis->c_med_asset, "100207120"); +#endif } END_TEST +#ifdef ENABLE_DOT1 START_TEST (test_recv_vlans) { char pkt1[] = { @@ -1311,7 +1336,9 @@ Link Layer Discovery Protocol fail_unless(vlan == NULL); } END_TEST +#endif +#ifdef ENABLE_LLDPMED START_TEST (test_recv_med) { char pkt1[] = { @@ -1337,8 +1364,12 @@ START_TEST (test_recv_med) 0x5f, 0x30, 0x38, 0x5f, 0x35, 0x29, 0x29, 0x0e, 0x04, 0x00, 0x14, 0x00, 0x04, 0x10, 0x0c, 0x05, 0x01, 0x0f, 0xff, 0x7a, 0x94, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfe, 0x09, 0x00, 0x12, 0x0f, - 0x01, 0x03, 0x6c, 0x00, 0x00, 0x10, 0xfe, 0x07, + 0x00, 0x00, 0x00, +#ifdef ENABLE_DOT3 + 0xfe, 0x09, 0x00, 0x12, 0x0f, + 0x01, 0x03, 0x6c, 0x00, 0x00, 0x10, +#endif + 0xfe, 0x07, 0x00, 0x12, 0xbb, 0x01, 0x00, 0x0f, 0x04, 0xfe, 0x08, 0x00, 0x12, 0xbb, 0x02, 0x01, 0x40, 0x65, 0xae, 0xfe, 0x2e, 0x00, 0x12, 0xbb, 0x03, 0x02, @@ -1485,6 +1516,7 @@ Link Layer Discovery Protocol ck_assert_int_eq(nchassis->c_mgmt.s_addr, (u_int32_t)inet_addr("15.255.122.148")); ck_assert_int_eq(nchassis->c_mgmt_if, 0); +#ifdef ENABLE_DOT3 ck_assert_int_eq(nport->p_autoneg_enabled, 1); ck_assert_int_eq(nport->p_autoneg_support, 1); ck_assert_int_eq(nport->p_autoneg_advertised, @@ -1494,6 +1526,7 @@ Link Layer Discovery Protocol LLDP_DOT3_LINK_AUTONEG_10BASE_T); ck_assert_int_eq(nport->p_mau_type, LLDP_DOT3_MAU_100BASETXFD); +#endif ck_assert_int_eq(nchassis->c_med_cap_available, LLDPMED_CAP_CAP | LLDPMED_CAP_POLICY | LLDPMED_CAP_LOCATION | LLDPMED_CAP_MDI_PSE); @@ -1522,6 +1555,7 @@ Link Layer Discovery Protocol ck_assert_int_eq(nport->p_med_pow_devicetype, LLDPMED_POW_TYPE_PSE); } END_TEST +#endif Suite * lldp_suite(void) @@ -1540,16 +1574,26 @@ lldp_suite(void) TCase *tc_send = tcase_create("Send LLDP packets"); tcase_add_checked_fixture(tc_send, setup, teardown); tcase_add_test(tc_send, test_send_basic); +#ifdef ENABLE_DOT1 tcase_add_test(tc_send, test_send_vlan); +#endif +#ifdef ENABLE_LLDPMED tcase_add_test(tc_send, test_send_med); +#endif +#ifdef ENABLE_DOT3 tcase_add_test(tc_send, test_send_dot3); +#endif suite_add_tcase(s, tc_send); TCase *tc_receive = tcase_create("Receive LLDP packets"); tcase_add_test(tc_receive, test_recv_min); tcase_add_test(tc_receive, test_recv_lldpd); +#ifdef ENABLE_DOT1 tcase_add_test(tc_receive, test_recv_vlans); +#endif +#ifdef ENABLE_LLDPMED tcase_add_test(tc_receive, test_recv_med); +#endif suite_add_tcase(s, tc_receive); return s; -- 2.39.5