Skip to content

Commit

Permalink
selftests/powerpc: Add a helper for checking if we're on ppc64le
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Ellerman committed Aug 7, 2018
1 parent 7cd129b commit 95f9b3a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down
17 changes: 17 additions & 0 deletions tools/testing/selftests/powerpc/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

0 comments on commit 95f9b3a

Please sign in to comment.