From 5c8fd3158dfb7123064046ba64f8375a337aef47 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Fri, 19 Jun 2020 15:36:33 +0200 Subject: [PATCH] unit: Support check v0.13.0 and later Function name no longer needs to be fed separately when adding tests. Also fix collision of non-static net_test variables in dhcp and netif tests. --- test/unit/core/test_netif.c | 2 +- test/unit/dhcp/test_dhcp.c | 2 +- test/unit/lwip_check.h | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/unit/core/test_netif.c b/test/unit/core/test_netif.c index 35d44714..c5fa75d4 100644 --- a/test/unit/core/test_netif.c +++ b/test/unit/core/test_netif.c @@ -9,7 +9,7 @@ #error "This tests needs LWIP_NETIF_EXT_STATUS_CALLBACK enabled" #endif -struct netif net_test; +static struct netif net_test; /* Setups/teardown functions */ diff --git a/test/unit/dhcp/test_dhcp.c b/test/unit/dhcp/test_dhcp.c index 4cefa33a..d84900de 100644 --- a/test/unit/dhcp/test_dhcp.c +++ b/test/unit/dhcp/test_dhcp.c @@ -6,7 +6,7 @@ #include "lwip/etharp.h" #include "netif/ethernet.h" -struct netif net_test; +static struct netif net_test; static const u8_t broadcast[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; diff --git a/test/unit/lwip_check.h b/test/unit/lwip_check.h index 522a9c3e..0246c59b 100644 --- a/test/unit/lwip_check.h +++ b/test/unit/lwip_check.h @@ -13,6 +13,7 @@ #define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0) #define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL) +#if (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13) typedef struct { TFun func; const char *name; @@ -24,6 +25,15 @@ typedef struct { #define tcase_add_named_test(tc,tf) \ _tcase_add_test((tc),(tf).func,(tf).name,0, 0, 0, 1) +#else +/* From 0.13.0 check keeps track of the method name internally */ +typedef const TTest * testfunc; + +#define TESTFUNC(x) x + +#define tcase_add_named_test(tc,tf) tcase_add_test(tc,tf) +#endif + /** typedef for a function returning a test suite */ typedef Suite* (suite_getter_fn)(void);