diff options
author | Simon Guo <wei.guo.simon@gmail.com> | 2016-09-30 10:32:51 +0800 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-11-17 17:11:47 +1100 |
commit | 15ec3997aa3bffc461f7b47ca9365d4b0323c671 (patch) | |
tree | 60fe7489443c2b596d7f8bda2106444d98214439 /tools/testing/selftests/powerpc/include/utils.h | |
parent | efe71a67b5aa89e0348ac862ca92a57d98d3fd8d (diff) |
selftests/powerpc: Move shared headers into new include dir
There are some functions, especially register related, which can
be shared across multiple selftests/powerpc test directories.
This patch creates a new include directory to store those shared
files, so that the file layout becomes more neat.
Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
[mpe: Reworked to move the headers only]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'tools/testing/selftests/powerpc/include/utils.h')
-rw-r--r-- | tools/testing/selftests/powerpc/include/utils.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/tools/testing/selftests/powerpc/include/utils.h b/tools/testing/selftests/powerpc/include/utils.h new file mode 100644 index 000000000000..53405e8a52ab --- /dev/null +++ b/tools/testing/selftests/powerpc/include/utils.h @@ -0,0 +1,77 @@ +/* + * Copyright 2013, Michael Ellerman, IBM Corp. + * Licensed under GPLv2. + */ + +#ifndef _SELFTESTS_POWERPC_UTILS_H +#define _SELFTESTS_POWERPC_UTILS_H + +#define __cacheline_aligned __attribute__((aligned(128))) + +#include <stdint.h> +#include <stdbool.h> +#include <linux/auxvec.h> +#include "reg.h" + +/* Avoid headaches with PRI?64 - just use %ll? always */ +typedef unsigned long long u64; +typedef signed long long s64; + +/* Just for familiarity */ +typedef uint32_t u32; +typedef uint16_t u16; +typedef uint8_t u8; + +void test_harness_set_timeout(uint64_t time); +int test_harness(int (test_function)(void), char *name); +extern void *get_auxv_entry(int type); +int pick_online_cpu(void); + +static inline bool have_hwcap(unsigned long ftr) +{ + return ((unsigned long)get_auxv_entry(AT_HWCAP) & ftr) == ftr; +} + +#ifdef AT_HWCAP2 +static inline bool have_hwcap2(unsigned long ftr2) +{ + return ((unsigned long)get_auxv_entry(AT_HWCAP2) & ftr2) == ftr2; +} +#else +static inline bool have_hwcap2(unsigned long ftr2) +{ + return false; +} +#endif + +/* Yes, this is evil */ +#define FAIL_IF(x) \ +do { \ + if ((x)) { \ + fprintf(stderr, \ + "[FAIL] Test FAILED on line %d\n", __LINE__); \ + return 1; \ + } \ +} while (0) + +/* The test harness uses this, yes it's gross */ +#define MAGIC_SKIP_RETURN_VALUE 99 + +#define SKIP_IF(x) \ +do { \ + if ((x)) { \ + fprintf(stderr, \ + "[SKIP] Test skipped on line %d\n", __LINE__); \ + return MAGIC_SKIP_RETURN_VALUE; \ + } \ +} while (0) + +#define _str(s) #s +#define str(s) _str(s) + +/* POWER9 feature */ +#ifndef PPC_FEATURE2_ARCH_3_00 +#define PPC_FEATURE2_ARCH_3_00 0x00800000 +#endif + +#endif /* _SELFTESTS_POWERPC_UTILS_H */ |