From: Shirisha G <shirisha@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: linux-kselftest@vger.kernel.org, maddy@linux.ibm.com,
venkat88@linux.ibm.com, shirisha@linux.ibm.com
Subject: [PATCH 6/7] Subject: [PATCH] selftests/powerpc: Add common test utilities header
Date: Fri, 18 Sep 2026 10:52:41 +0530 [thread overview]
Message-ID: <20260918052321.932660-6-shirisha@linux.ibm.com> (raw)
In-Reply-To: <20260918052321.932660-1-shirisha@linux.ibm.com>
Introduce a shared header `utils.h` providing basic test harness
macros and timeout handling for PowerPC selftests. This consolidates
common functionality used across RTAS, NVRAM, FADump, and other
selftests.
The header defines:
- SKIP_IF() macro for conditional skip
- FAIL_IF() macro for unconditional failure
- FAIL_IF_MSG() macro for failure with message
- test_harness_set_timeout() helper for alarm-based timeouts
This reduces duplication and ensures consistent behavior across
selftests.
Signed-off-by: Shirisha G <shirisha@linux.ibm.com>
---
tools/testing/selftests/powerpc/rtas/utils.h | 39 ++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 tools/testing/selftests/powerpc/rtas/utils.h
diff --git a/tools/testing/selftests/powerpc/rtas/utils.h b/tools/testing/selftests/powerpc/rtas/utils.h
new file mode 100644
index 000000000000..58eef7642a3f
--- /dev/null
+++ b/tools/testing/selftests/powerpc/rtas/utils.h
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#ifndef _RTAS_TEST_UTILS_H
+#define _RTAS_TEST_UTILS_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Test macros */
+#define SKIP_IF(x) \
+ do { \
+ if (x) { \
+ fprintf(stderr, "SKIP: %s\n", #x); \
+ exit(4); \
+ } \
+ } while (0)
+
+#define FAIL_IF(x) \
+ do { \
+ if (x) { \
+ fprintf(stderr, "FAIL: %s\n", #x); \
+ exit(1); \
+ } \
+ } while (0)
+
+#define FAIL_IF_MSG(x, fmt, ...) \
+ do { \
+ if (x) { \
+ fprintf(stderr, "FAIL: " fmt "\n", ##__VA_ARGS__); \
+ exit(1); \
+ } \
+ } while (0)
+
+static inline void test_harness_set_timeout(int seconds)
+{
+ alarm(seconds);
+}
+
+#endif /* _RTAS_TEST_UTILS_H */
--
2.43.5
next prev parent reply other threads:[~2026-09-18 5:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 5:22 [PATCH 1/7] Subject: [PATCH] selftests/powerpc: Add RTAS real-time clock test Shirisha G
2026-09-18 5:22 ` [PATCH 2/7] Subject: [PATCH] selftests/powerpc: Add NVRAM access test Shirisha G
2026-09-18 5:22 ` [PATCH 3/7] Subject: [PATCH] selftests/powerpc: Add RTAS /proc interface test Shirisha G
2026-09-18 5:22 ` [PATCH 4/7] Subject: [PATCH] selftests/powerpc: Add FADump sysfs " Shirisha G
2026-09-18 5:22 ` [PATCH 5/7] Subject: [PATCH] selftests/powerpc: Add RTAS firmware flash " Shirisha G
2026-09-18 5:22 ` Shirisha G [this message]
2026-09-18 5:22 ` [PATCH 7/7] Subject: [PATCH] selftests/powerpc/rtas: consolidate TEST_GEN_PROGS definitions Shirisha G
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=20260918052321.932660-6-shirisha@linux.ibm.com \
--to=shirisha@linux.ibm.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=venkat88@linux.ibm.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