selftests/powerpc: Add a helper for checking if we're on ppc64le
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 26 Jul 2018 12:24:57 +0000 (22:24 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 7 Aug 2018 11:49:25 +0000 (21:49 +1000)
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>
tools/testing/selftests/powerpc/include/utils.h
tools/testing/selftests/powerpc/utils.c

index 735815b..c58c370 100644 (file)
@@ -48,6 +48,8 @@ static inline bool have_hwcap2(unsigned long ftr2)
 }
 #endif
 
+bool is_ppc64le(void);
+
 /* Yes, this is evil */
 #define FAIL_IF(x)                                             \
 do {                                                           \
index d469168..aa8fc1e 100644 (file)
 #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;
+}