selftests/powerpc: Allow the tm-syscall test to build with old headers
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 15 Oct 2015 00:39:28 +0000 (11:39 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 15 Oct 2015 09:32:04 +0000 (20:32 +1100)
When building against older kernel headers, currently the tm-syscall
test fails to build because PPC_FEATURE2_HTM_NOSC is not defined.

Tweak the test so that if PPC_FEATURE2_HTM_NOSC is not defined it still
builds, but prints a warning at run time and marks the test as skipped.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
tools/testing/selftests/powerpc/tm/tm-syscall.c

index 1276e23da63bbdf91d328472f581e32e8979a0fa..e835bf7ec7aedd786a72c192b176e899d202e2c7 100644 (file)
@@ -77,13 +77,23 @@ pid_t getppid_tm(bool suspend)
        exit(-1);
 }
 
+static inline bool have_htm_nosc(void)
+{
+#ifdef PPC_FEATURE2_HTM_NOSC
+       return ((long)get_auxv_entry(AT_HWCAP2) & PPC_FEATURE2_HTM_NOSC);
+#else
+       printf("PPC_FEATURE2_HTM_NOSC not defined, can't check AT_HWCAP2\n");
+       return false;
+#endif
+}
+
 int tm_syscall(void)
 {
        unsigned count = 0;
        struct timeval end, now;
 
-       SKIP_IF(!((long)get_auxv_entry(AT_HWCAP2)
-                 & PPC_FEATURE2_HTM_NOSC));
+       SKIP_IF(!have_htm_nosc());
+
        setbuf(stdout, NULL);
 
        printf("Testing transactional syscalls for %d seconds...\n", TEST_DURATION);