]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
check: more comparison with `ck_assert_ptr_eq()`
authorVincent Bernat <vincent@bernat.im>
Thu, 19 Feb 2015 18:59:53 +0000 (19:59 +0100)
committerVincent Bernat <vincent@bernat.im>
Thu, 19 Feb 2015 18:59:53 +0000 (19:59 +0100)
tests/Makefile.am
tests/check-compat.h [new file with mode: 0644]
tests/check_lldp.c
tests/check_marshal.c
tests/common.h

index 4d305186113eba7e0f158d131c1f884f0473872c..1278f6c0e5e62edc0a1f0f5e0b458a667f16dd71 100644 (file)
@@ -9,26 +9,27 @@ AM_CFLAGS += @CHECK_CFLAGS@
 LDADD = $(top_builddir)/src/daemon/liblldpd.la @CHECK_LIBS@ @LIBEVENT_LDFLAGS@
 
 check_marshal_SOURCES = check_marshal.c \
-       $(top_srcdir)/src/marshal.h
+       $(top_srcdir)/src/marshal.h \
+       check-compat.h
 
 check_pattern_SOURCES = check_pattern.c \
        $(top_srcdir)/src/daemon/lldpd.h
 
 check_lldp_SOURCES = check_lldp.c \
        $(top_srcdir)/src/daemon/lldpd.h \
-       common.h common.c
+       common.h common.c check-compat.h
 
 check_cdp_SOURCES = check_cdp.c \
        $(top_srcdir)/src/daemon/lldpd.h \
-       common.h common.c
+       common.h common.c check-compat.h
 
 check_sonmp_SOURCES = check_sonmp.c \
        $(top_srcdir)/src/daemon/lldpd.h \
-       common.h common.c
+       common.h common.c check-compat.h
 
 check_edp_SOURCES = check_edp.c \
        $(top_srcdir)/src/daemon/lldpd.h \
-       common.h common.c
+       common.h common.c check-compat.h
 
 check_fixedpoint_SOURCES = check_fixedpoint.c
 check_fixedpoint_LDADD = $(top_builddir)/src/lib/libfixedpoint.la $(LDADD)
diff --git a/tests/check-compat.h b/tests/check-compat.h
new file mode 100644 (file)
index 0000000..47abe6f
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef _CHECK_COMPAT_H
+#define _CHECK_COMPAT_H
+
+#if (CHECK_MAJOR_VERSION == 0 && (CHECK_MINOR_VERSION < 9 || (CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION < 10)))
+# define ck_assert_ptr_eq(X,Y) do {                                    \
+               void* _ck_x = (X);                                      \
+               void* _ck_y = (Y);                                      \
+               ck_assert_msg(_ck_x == _ck_y,                           \
+                             "Assertion '"#X"=="#Y"' failed: "#X"==%p, "#Y"==%p", \
+                             _ck_x, _ck_y);                            \
+       } while (0)
+#endif
+
+#endif
index 1b48372ba4a8e5e2b46f805ae9ecc683028503a0..8b81a9fd389496de8b0ce18b4329e7e8377f0f2f 100644 (file)
@@ -490,9 +490,9 @@ Link Layer Discovery Protocol
        ck_assert_int_eq(nport->p_id_len, ETHER_ADDR_LEN);
        fail_unless(memcmp(mac2, nport->p_id, ETHER_ADDR_LEN) == 0);
        ck_assert_int_eq(nchassis->c_ttl, 120);
-       ck_assert_int_eq(nchassis->c_name, NULL);
-       ck_assert_int_eq(nchassis->c_descr, NULL);
-       ck_assert_int_eq(nport->p_descr, NULL);
+       ck_assert_ptr_eq(nchassis->c_name, NULL);
+       ck_assert_ptr_eq(nchassis->c_descr, NULL);
+       ck_assert_ptr_eq(nport->p_descr, NULL);
 }
 END_TEST
 
index 1254dd269542edb345467f31f0c4c6cb32fdc1a3..438d2d05cab6308f6b0a4782f5af760384e9688c 100644 (file)
@@ -4,6 +4,7 @@
 #include <sys/queue.h>
 
 #define MARSHAL_EXPORT
+#include "check-compat.h"
 #include "../src/marshal.h"
 #include "../src/log.h"
 
    CK_FORK=no valgrind -v --leak-check=yes ./tests/check_marshal
 */
 
-#if (CHECK_MAJOR_VERSION == 0 && (CHECK_MINOR_VERSION < 9 || (CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION < 10)))
-# define ck_assert_ptr_eq(X,Y) do {                                    \
-               void* _ck_x = (X);                                      \
-               void* _ck_y = (Y);                                      \
-               ck_assert_msg(_ck_x == _ck_y,                           \
-                             "Assertion '"#X"=="#Y"' failed: "#X"==%p, "#Y"==%p", \
-                             _ck_x, _ck_y);                            \
-       } while (0)
-#endif
-
 /* Use this callback to avoid some logs */
 void donothing(int pri, const char *msg) {};
 
index 179aee6a7bb3faa588badc351c9f738574accc3f..ed6320c48a5c43c7ae3e9416ab0e736f0c11484c 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _COMMON_H
 #define _COMMON_H
 
+#include "check-compat.h"
 #include "../src/daemon/lldpd.h"
 
 /* See: