blob: b7d41086bb0a72978263da62440e04c600478bda [file] [log] [blame]
Michael Ellerman2fae0d72013-08-06 17:42:36 +10001/*
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 */
13typedef unsigned long long u64;
14typedef signed long long s64;
15
16/* Just for familiarity */
17typedef uint32_t u32;
Greg Kurz58dae822015-02-23 16:14:44 +010018typedef uint16_t u16;
Michael Ellerman2fae0d72013-08-06 17:42:36 +100019typedef uint8_t u8;
20
21
22int test_harness(int (test_function)(void), char *name);
Sam bobroff2b03fc12015-04-10 14:16:48 +100023extern void *get_auxv_entry(int type);
Michael Ellerman2fae0d72013-08-06 17:42:36 +100024
25/* Yes, this is evil */
26#define FAIL_IF(x) \
27do { \
28 if ((x)) { \
29 fprintf(stderr, \
30 "[FAIL] Test FAILED on line %d\n", __LINE__); \
31 return 1; \
32 } \
33} while (0)
34
Michael Ellerman33b48192014-06-10 22:23:09 +100035/* The test harness uses this, yes it's gross */
36#define MAGIC_SKIP_RETURN_VALUE 99
37
38#define SKIP_IF(x) \
39do { \
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 Ellerman22d651d2014-01-21 15:22:17 +110047#define _str(s) #s
48#define str(s) _str(s)
49
Michael Ellerman2fae0d72013-08-06 17:42:36 +100050#endif /* _SELFTESTS_POWERPC_UTILS_H */