1195972f6Sopenharmony_ci#ifndef LWIP_HDR_LWIP_CHECK_H
2195972f6Sopenharmony_ci#define LWIP_HDR_LWIP_CHECK_H
3195972f6Sopenharmony_ci
4195972f6Sopenharmony_ci/* Common header file for lwIP unit tests using the check framework */
5195972f6Sopenharmony_ci
6195972f6Sopenharmony_ci#include <config.h>
7195972f6Sopenharmony_ci#include <check.h>
8195972f6Sopenharmony_ci#include <stdlib.h>
9195972f6Sopenharmony_ci
10195972f6Sopenharmony_ci#define FAIL_RET() do { fail(); return; } while(0)
11195972f6Sopenharmony_ci#define EXPECT(x) fail_unless(x)
12195972f6Sopenharmony_ci#define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0)
13195972f6Sopenharmony_ci#define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0)
14195972f6Sopenharmony_ci#define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL)
15195972f6Sopenharmony_ci
16195972f6Sopenharmony_ci#if (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13)
17195972f6Sopenharmony_citypedef struct {
18195972f6Sopenharmony_ci  TFun func;
19195972f6Sopenharmony_ci  const char *name;
20195972f6Sopenharmony_ci} testfunc;
21195972f6Sopenharmony_ci
22195972f6Sopenharmony_ci#define TESTFUNC(x) {(x), "" # x "" }
23195972f6Sopenharmony_ci
24195972f6Sopenharmony_ci/* Modified function from check.h, supplying function name */
25195972f6Sopenharmony_ci#define tcase_add_named_test(tc,tf) \
26195972f6Sopenharmony_ci   _tcase_add_test((tc),(tf).func,(tf).name,0, 0, 0, 1)
27195972f6Sopenharmony_ci
28195972f6Sopenharmony_ci#else
29195972f6Sopenharmony_ci/* From 0.13.0 check keeps track of the method name internally */
30195972f6Sopenharmony_citypedef const TTest * testfunc;
31195972f6Sopenharmony_ci
32195972f6Sopenharmony_ci#define TESTFUNC(x) x
33195972f6Sopenharmony_ci
34195972f6Sopenharmony_ci#define tcase_add_named_test(tc,tf) tcase_add_test(tc,tf)
35195972f6Sopenharmony_ci#endif
36195972f6Sopenharmony_ci
37195972f6Sopenharmony_ci/** typedef for a function returning a test suite */
38195972f6Sopenharmony_citypedef Suite* (suite_getter_fn)(void);
39195972f6Sopenharmony_ci
40195972f6Sopenharmony_ci/** Create a test suite */
41195972f6Sopenharmony_ciSuite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown);
42195972f6Sopenharmony_ci
43195972f6Sopenharmony_ci#ifdef LWIP_UNITTESTS_LIB
44195972f6Sopenharmony_ciint lwip_unittests_run(void)
45195972f6Sopenharmony_ci#endif
46195972f6Sopenharmony_ci
47195972f6Sopenharmony_ci/* helper functions */
48195972f6Sopenharmony_ci#define SKIP_POOL(x) (1 << x)
49195972f6Sopenharmony_ci#define SKIP_HEAP    (1 << MEMP_MAX)
50195972f6Sopenharmony_civoid lwip_check_ensure_no_alloc(unsigned int skip);
51195972f6Sopenharmony_ci
52195972f6Sopenharmony_ci#endif /* LWIP_HDR_LWIP_CHECK_H */
53