| Michael Ellerman | 2fae0d7 | 2013-08-06 17:42:36 +1000 | [diff] [blame] | 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; |
| Greg Kurz | 58dae82 | 2015-02-23 16:14:44 +0100 | [diff] [blame] | 18 | typedef uint16_t u16; |
| Michael Ellerman | 2fae0d7 | 2013-08-06 17:42:36 +1000 | [diff] [blame] | 19 | typedef uint8_t u8; |
| 20 | |
| 21 | |
| 22 | int test_harness(int (test_function)(void), char *name); |
| Sam bobroff | 2b03fc1 | 2015-04-10 14:16:48 +1000 | [diff] [blame^] | 23 | extern void *get_auxv_entry(int type); |
| Michael Ellerman | 2fae0d7 | 2013-08-06 17:42:36 +1000 | [diff] [blame] | 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 | |
| Michael Ellerman | 33b4819 | 2014-06-10 22:23:09 +1000 | [diff] [blame] | 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 | |
| Michael Ellerman | 22d651d | 2014-01-21 15:22:17 +1100 | [diff] [blame] | 47 | #define _str(s) #s |
| 48 | #define str(s) _str(s) |
| 49 | |
| Michael Ellerman | 2fae0d7 | 2013-08-06 17:42:36 +1000 | [diff] [blame] | 50 | #endif /* _SELFTESTS_POWERPC_UTILS_H */ |