Hello Shirisha,
The commit title has a Subject: [PATCH] prefix, which is not needed.
This applies to all patches in this series.
On 18/09/26 10:52, Shirisha G wrote:
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 <[email protected]>
---
.../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
Why is the fadump sysfs test under rtas? It has hardly anything to do
with RTAS. Please find a better place for this test.
Here is an optimized version of this test case with fewer lines of code:
#include <stdio.h>
#include <unistd.h>
#include "utils.h"
#define FADUMP_SYSFS "/sys/kernel/fadump/"
static int test_fadump_sysfs(void)
{
long enabled, registered, mem_reserved;
SKIP_IF_MSG(access(FADUMP_SYSFS "enabled", R_OK),
"FADump not supported on this platform");
FAIL_IF(read_long(FADUMP_SYSFS "enabled", &enabled, 10));
FAIL_IF(enabled != 0 && enabled != 1);
/* Remaining attributes are only created when FADump is enabled */
SKIP_IF_MSG(!enabled, "FADump supported but not enabled");
FAIL_IF(read_long(FADUMP_SYSFS "registered", ®istered, 10));
FAIL_IF(read_long(FADUMP_SYSFS "mem_reserved", &mem_reserved, 10));
printf("registered=%ld mem_reserved=%ld\n", registered, mem_reserved);
FAIL_IF(registered != 0 && registered != 1);
FAIL_IF(!mem_reserved);
return 0;
}
int main(void)
{
test_harness_set_timeout(10);
return test_harness(test_fadump_sysfs, "fadump_test");
}
Can you please review the APIs used in the above test and use them in
the other
tests introduced in this patch series to make them more modular?
- Sourabh Jain
@@ -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;
+}