From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: Shirisha G <shirisha@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: linux-kselftest@vger.kernel.org, maddy@linux.ibm.com,
venkat88@linux.ibm.com
Subject: Re: [PATCH 4/7] Subject: [PATCH] selftests/powerpc: Add FADump sysfs interface test
Date: Tue, 24 Nov 2026 19:45:04 +0530 [thread overview]
Message-ID: <1ebc499d-3a44-44ba-96d2-11888cbdecee@linux.ibm.com> (raw)
In-Reply-To: <20260918052321.932660-4-shirisha@linux.ibm.com>
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 <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
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;
> +}
next prev parent reply other threads:[~2026-11-24 14:15 UTC|newest]
Thread overview: 9+ 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-11-24 14:15 ` Sourabh Jain [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
2026-11-24 14:28 ` Sourabh Jain
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=1ebc499d-3a44-44ba-96d2-11888cbdecee@linux.ibm.com \
--to=sourabhjain@linux.ibm.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=shirisha@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