check_check.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Check: a unit test framework for C
  3. * Copyright (C) 2001, 2002 Arien Malec
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the
  17. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  18. * MA 02110-1301, USA.
  19. */
  20. #ifndef CHECK_CHECK_H
  21. #define CHECK_CHECK_H
  22. #ifndef TIMEOUT_TESTS_ENABLED
  23. #define TIMEOUT_TESTS_ENABLED 1
  24. #endif
  25. /*
  26. * Certain unit tests are known to leak memory. This
  27. * #define will prevent those unit tests from being built
  28. * if the program is to be used against valgrind.
  29. */
  30. #ifndef MEMORY_LEAKING_TESTS_ENABLED
  31. #define MEMORY_LEAKING_TESTS_ENABLED 1
  32. #endif
  33. extern int sub_ntests;
  34. void fork_setup (void);
  35. void fork_teardown (void);
  36. void setup_fixture(void);
  37. void teardown_fixture (void);
  38. void setup (void);
  39. void cleanup (void);
  40. Suite *make_sub_suite(void);
  41. Suite *make_sub2_suite(void);
  42. Suite *make_master_suite(void);
  43. Suite *make_list_suite(void);
  44. Suite *make_msg_suite(void);
  45. Suite *make_log_suite(void);
  46. Suite *make_log_internal_suite(void);
  47. Suite *make_limit_suite(void);
  48. Suite *make_fork_suite(void);
  49. Suite *make_fixture_suite(void);
  50. Suite *make_pack_suite(void);
  51. Suite *make_exit_suite(void);
  52. Suite *make_selective_suite(void);
  53. Suite *make_tag_suite(void);
  54. extern int master_tests_lineno[];
  55. void init_master_tests_lineno(int num_master_tests);
  56. /**
  57. * Record a test name.
  58. *
  59. * This is used to record the test names of each test in
  60. * check_check_sub.c. This allows the test name to be written
  61. * in the master_tests table in check_check_master.c and have
  62. * it verified at test time. With this data, one can easily
  63. * determine the name of a failed test.
  64. */
  65. void record_test_name(const char* test_name);
  66. /**
  67. * Retrieve the next recorded test which was run, or
  68. * NULL if no further tests are recorded.
  69. */
  70. char* get_next_test_name(FILE * file);
  71. /**
  72. * Record a line number for a test which is to fail.
  73. *
  74. * This is used to record the failure line numbers for
  75. * all tests in check_check_sub.c. Simply make this
  76. * call right before an assert to record the proper
  77. * line number. The line number is adjusted +1 internally,
  78. * to account for making this call before the failure.
  79. */
  80. void record_failure_line_num(const int line);
  81. /**
  82. * Once the failure file numbers have been recorded
  83. * to file and the file has been rewind(), this
  84. * call will extract the next line number from the
  85. * file.
  86. *
  87. * If there are no more lines to read, -1 is returned.
  88. */
  89. long get_next_failure_line_num(FILE * file);
  90. #endif /* CHECK_CHECK_H */