lwip_check.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef LWIP_HDR_LWIP_CHECK_H
  2. #define LWIP_HDR_LWIP_CHECK_H
  3. /* Common header file for lwIP unit tests using the check framework */
  4. #include <config.h>
  5. #include <check.h>
  6. #include <stdlib.h>
  7. #define FAIL_RET() do { fail(); return; } while(0)
  8. #define EXPECT(x) fail_unless(x)
  9. #define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0)
  10. #define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0)
  11. #define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL)
  12. #if (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13)
  13. typedef struct {
  14. TFun func;
  15. const char *name;
  16. } testfunc;
  17. #define TESTFUNC(x) {(x), "" # x "" }
  18. /* Modified function from check.h, supplying function name */
  19. #define tcase_add_named_test(tc,tf) \
  20. _tcase_add_test((tc),(tf).func,(tf).name,0, 0, 0, 1)
  21. #else
  22. /* From 0.13.0 check keeps track of the method name internally */
  23. typedef const TTest * testfunc;
  24. #define TESTFUNC(x) x
  25. #define tcase_add_named_test(tc,tf) tcase_add_test(tc,tf)
  26. #endif
  27. /** typedef for a function returning a test suite */
  28. typedef Suite* (suite_getter_fn)(void);
  29. /** Create a test suite */
  30. Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown);
  31. #ifdef LWIP_UNITTESTS_LIB
  32. int lwip_unittests_run(void)
  33. #endif
  34. /* helper functions */
  35. #define SKIP_POOL(x) (1 << x)
  36. #define SKIP_HEAP (1 << MEMP_MAX)
  37. void lwip_check_ensure_no_alloc(unsigned int skip);
  38. #endif /* LWIP_HDR_LWIP_CHECK_H */