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 4/7] Subject: [PATCH] selftests/powerpc: Add FADump sysfs interface test
Date: Fri, 18 Sep 2026 10:52:39 +0530 [thread overview]
Message-ID: <20260918052321.932660-4-shirisha@linux.ibm.com> (raw)
In-Reply-To: <20260918052321.932660-1-shirisha@linux.ibm.com>
Add kselftest for Firmware-Assisted Dump (FADump) sysfs interface
on pseries/PowerVM systems. This test validates registration and
status reporting without triggering an actual crash.
The test verifies:
- Existence of `/sys/kernel/fadump/` directory
- Reading enabled and registered status
- Reserved memory size is non-zero when enabled
- Attribute readability and permissions
- Handling of invalid registration attempts
Signed-off-by: Shirisha G <shirisha@linux.ibm.com>
---
.../selftests/powerpc/rtas/fadump_test.c | 85 +++++++++++++++++++
1 file changed, 85 insertions(+)
create mode 100644 tools/testing/selftests/powerpc/rtas/fadump_test.c
diff --git a/tools/testing/selftests/powerpc/rtas/fadump_test.c b/tools/testing/selftests/powerpc/rtas/fadump_test.c
new file mode 100644
index 000000000000..92ff70e4b580
--- /dev/null
+++ b/tools/testing/selftests/powerpc/rtas/fadump_test.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Firmware-Assisted Dump (FADump) Test
+ * Copyright (C) 2026 IBM Corporation
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "utils.h"
+
+#define FADUMP_DIR "/sys/kernel/fadump"
+#define FADUMP_ENABLED "/sys/kernel/fadump/enabled"
+#define FADUMP_REGISTERED "/sys/kernel/fadump/registered"
+#define FADUMP_MEM_RESERVED "/sys/kernel/fadump/mem_reserved"
+#define FADUMP_REGISTER "/sys/kernel/fadump/fadump_register"
+
+static int read_sysfs_int(const char *path)
+{
+ FILE *fp;
+ int value = -1;
+
+ fp = fopen(path, "r");
+ if (fp) {
+ fscanf(fp, "%d", &value);
+ fclose(fp);
+ }
+ return value;
+}
+
+static unsigned long read_sysfs_ulong(const char *path)
+{
+ FILE *fp;
+ unsigned long value = 0;
+
+ fp = fopen(path, "r");
+ if (fp) {
+ fscanf(fp, "%lu", &value);
+ fclose(fp);
+ }
+ return value;
+}
+
+int main(void)
+{
+ int enabled, registered;
+ unsigned long mem_reserved;
+
+ test_harness_set_timeout(10);
+
+ /* Test 1: Verify FADump sysfs directory exists */
+ SKIP_IF(access(FADUMP_DIR, R_OK) != 0);
+
+ /* Test 2: Read enabled status */
+ enabled = read_sysfs_int(FADUMP_ENABLED);
+ FAIL_IF_MSG(enabled < 0, "Failed to read FADump enabled status");
+ printf("FADump enabled: %d\n", enabled);
+
+ /* Test 3: Read registered status */
+ registered = read_sysfs_int(FADUMP_REGISTERED);
+ FAIL_IF_MSG(registered < 0, "Failed to read FADump registered status");
+ printf("FADump registered: %d\n", registered);
+
+ /* Test 4: Read reserved memory */
+ mem_reserved = read_sysfs_ulong(FADUMP_MEM_RESERVED);
+ printf("FADump reserved memory: %lu bytes\n", mem_reserved);
+
+ if (enabled) {
+ FAIL_IF_MSG(mem_reserved == 0,
+ "FADump enabled but no memory reserved");
+ }
+
+ /* Test 5: Verify sysfs attributes are readable */
+ FAIL_IF(access(FADUMP_ENABLED, R_OK) != 0);
+ FAIL_IF(access(FADUMP_REGISTERED, R_OK) != 0);
+ FAIL_IF(access(FADUMP_MEM_RESERVED, R_OK) != 0);
+
+ /* Note: We don't test actual registration/unregistration here
+ * as it requires root and could affect system stability */
+
+ printf("FADump test passed\n");
+ return 0;
+}
--
2.43.5
next prev parent reply other threads:[~2026-09-18 5:23 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 ` Shirisha G [this message]
2026-09-18 5:22 ` [PATCH 5/7] Subject: [PATCH] selftests/powerpc: Add RTAS firmware flash " Shirisha G
2026-09-18 5:22 ` [PATCH 6/7] Subject: [PATCH] selftests/powerpc: Add common test utilities header Shirisha G
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-4-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