selftests/powerpc: Add helper to exit on failure
authorSandipan Das <sandipan@linux.ibm.com>
Mon, 27 Jul 2020 04:00:38 +0000 (09:30 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 29 Jul 2020 11:02:10 +0000 (21:02 +1000)
This adds a helper similar to FAIL_IF() which lets a
program exit with code 1 (to indicate failure) when
the given condition is true.

Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/dac282d5c2e96e7816dc522e4e20d56d7c79c898.1595821792.git.sandipan@linux.ibm.com
tools/testing/selftests/powerpc/include/utils.h

index 7f259f3..69d1687 100644 (file)
@@ -72,6 +72,15 @@ do {                                                         \
        }                                                       \
 } while (0)
 
+#define FAIL_IF_EXIT(x)                                                \
+do {                                                           \
+       if ((x)) {                                              \
+               fprintf(stderr,                                 \
+               "[FAIL] Test FAILED on line %d\n", __LINE__);   \
+               _exit(1);                                       \
+       }                                                       \
+} while (0)
+
 /* The test harness uses this, yes it's gross */
 #define MAGIC_SKIP_RETURN_VALUE        99