]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
tests: use memcmp to compare chassis and port ID
authorVincent Bernat <bernat@luffy.cx>
Tue, 3 Apr 2012 12:17:07 +0000 (14:17 +0200)
committerVincent Bernat <bernat@luffy.cx>
Tue, 3 Apr 2012 12:20:14 +0000 (14:20 +0200)
Chassis and port ID are not null-terminated string. We cannot compare
them with strcmp.

tests/check_lldp.c

index f87b51e673fdf9d261295696c45a156e7f5de29d..0316960e36b767853eacda762976e596dc398277 100644 (file)
@@ -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);