kselftest.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. /* counters */
  15. struct ksft_count {
  16. unsigned int ksft_pass;
  17. unsigned int ksft_fail;
  18. unsigned int ksft_xfail;
  19. unsigned int ksft_xpass;
  20. unsigned int ksft_xskip;
  21. };
  22. static struct ksft_count ksft_cnt;
  23. static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; }
  24. static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; }
  25. static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; }
  26. static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; }
  27. static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; }
  28. static inline void ksft_print_cnts(void)
  29. {
  30. printf("Pass: %d Fail: %d Xfail: %d Xpass: %d, Xskip: %d\n",
  31. ksft_cnt.ksft_pass, ksft_cnt.ksft_fail,
  32. ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass,
  33. ksft_cnt.ksft_xskip);
  34. }
  35. static inline int ksft_exit_pass(void)
  36. {
  37. exit(0);
  38. }
  39. static inline int ksft_exit_fail(void)
  40. {
  41. exit(1);
  42. }
  43. static inline int ksft_exit_xfail(void)
  44. {
  45. exit(2);
  46. }
  47. static inline int ksft_exit_xpass(void)
  48. {
  49. exit(3);
  50. }
  51. static inline int ksft_exit_skip(void)
  52. {
  53. exit(4);
  54. }
  55. #endif /* __KSELFTEST_H */