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