kselftest.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * kselftest.h: kselftest framework return codes to include from
  3. * selftests.
  4. *
  5. * Copyright (c) 2014 Shuah Khan <shuahkh@osg.samsung.com>
  6. * Copyright (c) 2014 Samsung Electronics Co., Ltd.
  7. *
  8. * This file is released under the GPLv2.
  9. */
  10. #ifndef __KSELFTEST_H
  11. #define __KSELFTEST_H
  12. #include <stdlib.h>
  13. #include <unistd.h>
  14. /* define kselftest exit codes */
  15. #define KSFT_PASS 0
  16. #define KSFT_FAIL 1
  17. #define KSFT_XFAIL 2
  18. #define KSFT_XPASS 3
  19. #define KSFT_SKIP 4
  20. /* counters */
  21. struct ksft_count {
  22. unsigned int ksft_pass;
  23. unsigned int ksft_fail;
  24. unsigned int ksft_xfail;
  25. unsigned int ksft_xpass;
  26. unsigned int ksft_xskip;
  27. };
  28. static struct ksft_count ksft_cnt;
  29. static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; }
  30. static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; }
  31. static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; }
  32. static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; }
  33. static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; }
  34. static inline void ksft_print_cnts(void)
  35. {
  36. printf("Pass: %d Fail: %d Xfail: %d Xpass: %d, Xskip: %d\n",
  37. ksft_cnt.ksft_pass, ksft_cnt.ksft_fail,
  38. ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass,
  39. ksft_cnt.ksft_xskip);
  40. }
  41. static inline int ksft_exit_pass(void)
  42. {
  43. exit(KSFT_PASS);
  44. }
  45. static inline int ksft_exit_fail(void)
  46. {
  47. exit(KSFT_FAIL);
  48. }
  49. static inline int ksft_exit_xfail(void)
  50. {
  51. exit(KSFT_XFAIL);
  52. }
  53. static inline int ksft_exit_xpass(void)
  54. {
  55. exit(KSFT_XPASS);
  56. }
  57. static inline int ksft_exit_skip(void)
  58. {
  59. exit(KSFT_SKIP);
  60. }
  61. #endif /* __KSELFTEST_H */