lwip_check.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef __LWIP_CHECK_H__
  2. #define __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. /** typedef for a function returning a test suite */
  13. typedef Suite* (suite_getter_fn)(void);
  14. /** Create a test suite */
  15. static Suite* create_suite(const char* name, TFun *tests, size_t num_tests, SFun setup, SFun teardown)
  16. {
  17. size_t i;
  18. Suite *s = suite_create(name);
  19. for(i = 0; i < num_tests; i++) {
  20. /* Core test case */
  21. TCase *tc_core = tcase_create("Core");
  22. if ((setup != NULL) || (teardown != NULL)) {
  23. tcase_add_checked_fixture(tc_core, setup, teardown);
  24. }
  25. tcase_add_test(tc_core, tests[i]);
  26. suite_add_tcase(s, tc_core);
  27. }
  28. return s;
  29. }
  30. #endif /* __LWIP_CHECK_H__ */