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