From: Vincent Bernat Date: Tue, 3 Apr 2012 12:17:07 +0000 (+0200) Subject: tests: use memcmp to compare chassis and port ID X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b7e07696d49fcf5d12108483e6fd087f5d48d96;p=thirdparty%2Flldpd.git tests: use memcmp to compare chassis and port ID Chassis and port ID are not null-terminated string. We cannot compare them with strcmp. --- diff --git a/tests/check_lldp.c b/tests/check_lldp.c index f87b51e6..0316960e 100644 --- a/tests/check_lldp.c +++ b/tests/check_lldp.c @@ -15,8 +15,9 @@ check_received_port( struct lldpd_port *rport) { ck_assert_int_eq(rport->p_id_subtype, sport->p_id_subtype); - ck_assert_str_eq(rport->p_id, sport->p_id); ck_assert_int_eq(rport->p_id_len, sport->p_id_len); + fail_unless(memcmp(rport->p_id, sport->p_id, + rport->p_id_len) == 0); ck_assert_str_eq(rport->p_descr, sport->p_descr); ck_assert_int_eq(rport->p_mfs, sport->p_mfs); return; @@ -28,8 +29,9 @@ check_received_chassis( struct lldpd_chassis *rchassis) { ck_assert_int_eq(rchassis->c_id_subtype, schassis->c_id_subtype); - ck_assert_str_eq(rchassis->c_id, schassis->c_id); ck_assert_int_eq(rchassis->c_id_len, schassis->c_id_len); + fail_unless(memcmp(rchassis->c_id, schassis->c_id, + rchassis->c_id_len) == 0); ck_assert_str_eq(rchassis->c_name, schassis->c_name); ck_assert_str_eq(rchassis->c_descr, schassis->c_descr); ck_assert_int_eq(rchassis->c_cap_available, schassis->c_cap_available);