utils.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 uint16_t u16;
  15. typedef uint8_t u8;
  16. int test_harness(int (test_function)(void), char *name);
  17. /* Yes, this is evil */
  18. #define FAIL_IF(x) \
  19. do { \
  20. if ((x)) { \
  21. fprintf(stderr, \
  22. "[FAIL] Test FAILED on line %d\n", __LINE__); \
  23. return 1; \
  24. } \
  25. } while (0)
  26. /* The test harness uses this, yes it's gross */
  27. #define MAGIC_SKIP_RETURN_VALUE 99
  28. #define SKIP_IF(x) \
  29. do { \
  30. if ((x)) { \
  31. fprintf(stderr, \
  32. "[SKIP] Test skipped on line %d\n", __LINE__); \
  33. return MAGIC_SKIP_RETURN_VALUE; \
  34. } \
  35. } while (0)
  36. #define _str(s) #s
  37. #define str(s) _str(s)
  38. #endif /* _SELFTESTS_POWERPC_UTILS_H */