diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2018-07-26 15:24:57 +0300 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-08-07 14:49:25 +0300 |
commit | 95f9b3af401f5b4daeb908a2c658e820e969f4e3 (patch) | |
tree | 625d0c9d15d97876d0d243409249cf9b5edf3080 /tools/testing/selftests/powerpc/utils.c | |
parent | 7cd129b4b5370030a5c0b8031a54b2d1d92fa546 (diff) | |
download | linux-95f9b3af401f5b4daeb908a2c658e820e969f4e3.tar.xz |
selftests/powerpc: Add a helper for checking if we're on ppc64le
Some of our selftests have only been tested on ppc64le and crash or
behave weirdly on ppc64/ppc32. So add a helper for checking the UTS
machine.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'tools/testing/selftests/powerpc/utils.c')
-rw-r--r-- | tools/testing/selftests/powerpc/utils.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/testing/selftests/powerpc/utils.c b/tools/testing/selftests/powerpc/utils.c index d46916867a6f..aa8fc1e6365b 100644 --- a/tools/testing/selftests/powerpc/utils.c +++ b/tools/testing/selftests/powerpc/utils.c @@ -11,8 +11,10 @@ #include <link.h> #include <sched.h> #include <stdio.h> +#include <string.h> #include <sys/stat.h> #include <sys/types.h> +#include <sys/utsname.h> #include <unistd.h> #include "utils.h" @@ -104,3 +106,18 @@ int pick_online_cpu(void) printf("No cpus in affinity mask?!\n"); return -1; } + +bool is_ppc64le(void) +{ + struct utsname uts; + int rc; + + errno = 0; + rc = uname(&uts); + if (rc) { + perror("uname"); + return false; + } + + return strcmp(uts.machine, "ppc64le") == 0; +} |