tester.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. *
  3. * Embedded Linux library
  4. *
  5. * Copyright (C) 2021 Intel Corporation. All rights reserved.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #ifndef __ELL_TESTER_H
  23. #define __ELL_TESTER_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #include <stdbool.h>
  28. #include <stddef.h>
  29. #include <stdint.h>
  30. struct l_tester;
  31. enum l_tester_stage {
  32. L_TESTER_STAGE_INVALID,
  33. L_TESTER_STAGE_PRE_SETUP,
  34. L_TESTER_STAGE_SETUP,
  35. L_TESTER_STAGE_RUN,
  36. L_TESTER_STAGE_TEARDOWN,
  37. L_TESTER_STAGE_POST_TEARDOWN,
  38. };
  39. typedef void (*l_tester_destroy_func_t)(void *user_data);
  40. typedef void (*l_tester_data_func_t)(const void *test_data);
  41. typedef void (*l_tester_finish_func_t)(struct l_tester *tester);
  42. typedef void (*l_tester_wait_func_t)(void *user_data);
  43. struct l_tester *l_tester_new(const char *prefix, const char *substring,
  44. bool list_cases);
  45. void l_tester_destroy(struct l_tester *tester);
  46. void l_tester_start(struct l_tester *tester,
  47. l_tester_finish_func_t finish_func);
  48. bool l_tester_summarize(struct l_tester *tester);
  49. void l_tester_add_full(struct l_tester *tester, const char *name,
  50. const void *test_data,
  51. l_tester_data_func_t pre_setup_func,
  52. l_tester_data_func_t setup_func,
  53. l_tester_data_func_t test_func,
  54. l_tester_data_func_t teardown_func,
  55. l_tester_data_func_t post_teardown_func,
  56. unsigned int timeout,
  57. void *user_data,
  58. l_tester_destroy_func_t destroy);
  59. void l_tester_add(struct l_tester *tester, const char *name,
  60. const void *test_data,
  61. l_tester_data_func_t setup_func,
  62. l_tester_data_func_t test_func,
  63. l_tester_data_func_t teardown_func);
  64. void l_tester_pre_setup_complete(struct l_tester *tester);
  65. void l_tester_pre_setup_failed(struct l_tester *tester);
  66. void l_tester_setup_complete(struct l_tester *tester);
  67. void l_tester_setup_failed(struct l_tester *tester);
  68. void l_tester_test_passed(struct l_tester *tester);
  69. void l_tester_test_failed(struct l_tester *tester);
  70. void l_tester_test_abort(struct l_tester *tester);
  71. void l_tester_teardown_complete(struct l_tester *tester);
  72. void l_tester_teardown_failed(struct l_tester *tester);
  73. void l_tester_post_teardown_complete(struct l_tester *tester);
  74. void l_tester_post_teardown_failed(struct l_tester *tester);
  75. enum l_tester_stage l_tester_get_stage(struct l_tester *tester);
  76. void *l_tester_get_data(struct l_tester *tester);
  77. void l_tester_wait(struct l_tester *tester, unsigned int seconds,
  78. l_tester_wait_func_t func, void *user_data);
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #endif /* __ELL_TESTER_H */