From: Benjamin Gray <bgray@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: npiggin@gmail.com, Benjamin Gray <bgray@linux.ibm.com>
Subject: [PATCH v2 10/12] selftests/powerpc: Add more utility macros
Date: Thu, 30 Mar 2023 16:50:38 +1100 [thread overview]
Message-ID: <20230330055040.434133-11-bgray@linux.ibm.com> (raw)
In-Reply-To: <20230330055040.434133-1-bgray@linux.ibm.com>
* Include unistd.h for _exit()
* Include stdio.h for fprintf()
* Adds _MSG assertion variants to provide more context behind why a
failure occurred.
* Move ARRAY_SIZE macro to utils.h
The _MSG variants and ARRAY_SIZE will be used by the following
DEXCR selftests.
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
---
v1: * Remove the signal handler variants
* Describe why headers are included
---
.../testing/selftests/powerpc/include/utils.h | 27 ++++++++++++++++++-
.../powerpc/pmu/sampling_tests/misc.h | 2 --
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/powerpc/include/utils.h b/tools/testing/selftests/powerpc/include/utils.h
index eed7dd7582b2..65b242842ff5 100644
--- a/tools/testing/selftests/powerpc/include/utils.h
+++ b/tools/testing/selftests/powerpc/include/utils.h
@@ -9,11 +9,17 @@
#define __cacheline_aligned __attribute__((aligned(128)))
#include <stdint.h>
+#include <stdio.h>
#include <stdbool.h>
#include <linux/auxvec.h>
#include <linux/perf_event.h>
#include <asm/cputable.h>
#include "reg.h"
+#include <unistd.h>
+
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
/* Avoid headaches with PRI?64 - just use %ll? always */
typedef unsigned long long u64;
@@ -64,7 +70,6 @@ struct perf_event_read {
};
#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 30)
-#include <unistd.h>
#include <sys/syscall.h>
static inline pid_t gettid(void)
@@ -113,6 +118,16 @@ do { \
} \
} while (0)
+#define FAIL_IF_MSG(x, msg) \
+do { \
+ if ((x)) { \
+ fprintf(stderr, \
+ "[FAIL] Test FAILED on line %d: %s\n", \
+ __LINE__, msg); \
+ return 1; \
+ } \
+} while (0)
+
#define FAIL_IF_EXIT(x) \
do { \
if ((x)) { \
@@ -122,6 +137,16 @@ do { \
} \
} while (0)
+#define FAIL_IF_EXIT_MSG(x, msg) \
+do { \
+ if ((x)) { \
+ fprintf(stderr, \
+ "[FAIL] Test FAILED on line %d: %s\n", \
+ __LINE__, msg); \
+ _exit(1); \
+ } \
+} while (0)
+
/* The test harness uses this, yes it's gross */
#define MAGIC_SKIP_RETURN_VALUE 99
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
index 4181755cf5a0..64e25cce1435 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
@@ -18,8 +18,6 @@
#define MMCR1_RSQ 0x200000000000ULL /* radix scope qual field */
#define BHRB_DISABLE 0x2000000000ULL /* MMCRA BHRB DISABLE bit */
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
extern int ev_mask_pmcxsel, ev_shift_pmcxsel;
extern int ev_mask_marked, ev_shift_marked;
extern int ev_mask_comb, ev_shift_comb;
--
2.39.2
next prev parent reply other threads:[~2023-03-30 5:55 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 5:50 [PATCH v2 00/12] Add static DEXCR support Benjamin Gray
2023-03-30 5:50 ` [PATCH v2 01/12] powerpc/book3s: Add missing <linux/sched.h> include Benjamin Gray
2023-05-08 3:36 ` Russell Currey
2023-03-30 5:50 ` [PATCH v2 02/12] powerpc/ptrace: Add missing <linux/regset.h> include Benjamin Gray
2023-05-08 3:39 ` Russell Currey
2023-03-30 5:50 ` [PATCH v2 03/12] powerpc/dexcr: Add initial Dynamic Execution Control Register (DEXCR) support Benjamin Gray
2023-05-08 3:44 ` Russell Currey
2023-03-30 5:50 ` [PATCH v2 04/12] powerpc/dexcr: Handle hashchk exception Benjamin Gray
2023-05-08 4:00 ` Russell Currey
2023-03-30 5:50 ` [PATCH v2 05/12] powerpc/dexcr: Support userspace ROP protection Benjamin Gray
2023-05-08 4:10 ` Russell Currey
2023-03-30 5:50 ` [PATCH v2 06/12] powerpc/dexcr: Support custom default DEXCR value Benjamin Gray
2023-05-08 4:24 ` Russell Currey
2023-03-30 5:50 ` [PATCH v2 07/12] powerpc/ptrace: Expose DEXCR and HDEXCR registers to ptrace Benjamin Gray
2023-05-08 4:30 ` Russell Currey
2023-03-30 5:50 ` [PATCH v2 08/12] powerpc/ptrace: Expose HASHKEYR register " Benjamin Gray
2023-05-08 4:32 ` Russell Currey
2023-03-30 5:50 ` [PATCH v2 09/12] Documentation: Document PowerPC kernel DEXCR interface Benjamin Gray
2023-05-08 4:40 ` Russell Currey
2023-03-30 5:50 ` Benjamin Gray [this message]
2023-05-08 4:43 ` [PATCH v2 10/12] selftests/powerpc: Add more utility macros Russell Currey
2023-03-30 5:50 ` [PATCH v2 11/12] selftests/powerpc/dexcr: Add hashst/hashchk test Benjamin Gray
2023-03-30 5:50 ` [PATCH v2 12/12] selftests/powerpc/dexcr: Add DEXCR status utility lsdexcr Benjamin Gray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230330055040.434133-11-bgray@linux.ibm.com \
--to=bgray@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).