utils.h 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2013, Michael Ellerman, IBM Corp.
  3. * Licensed under GPLv2.
  4. */
  5. #ifndef _SELFTESTS_POWERPC_UTILS_H
  6. #define _SELFTESTS_POWERPC_UTILS_H
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. /* Avoid headaches with PRI?64 - just use %ll? always */
  10. typedef unsigned long long u64;
  11. typedef signed long long s64;
  12. /* Just for familiarity */
  13. typedef uint32_t u32;
  14. typedef uint8_t u8;
  15. int test_harness(int (test_function)(void), char *name);
  16. /* Yes, this is evil */
  17. #define FAIL_IF(x) \
  18. do { \
  19. if ((x)) { \
  20. fprintf(stderr, \
  21. "[FAIL] Test FAILED on line %d\n", __LINE__); \
  22. return 1; \
  23. } \
  24. } while (0)
  25. /* The test harness uses this, yes it's gross */
  26. #define MAGIC_SKIP_RETURN_VALUE 99
  27. #define SKIP_IF(x) \
  28. do { \
  29. if ((x)) { \
  30. fprintf(stderr, \
  31. "[SKIP] Test skipped on line %d\n", __LINE__); \
  32. return MAGIC_SKIP_RETURN_VALUE; \
  33. } \
  34. } while (0)
  35. #define _str(s) #s
  36. #define str(s) _str(s)
  37. #endif /* _SELFTESTS_POWERPC_UTILS_H */