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 3/7] Subject: [PATCH] selftests/powerpc: Add RTAS /proc interface test
Date: Fri, 18 Sep 2026 10:52:38 +0530 [thread overview]
Message-ID: <20260918052321.932660-3-shirisha@linux.ibm.com> (raw)
In-Reply-To: <20260918052321.932660-1-shirisha@linux.ibm.com>
Add kselftest for the RTAS /proc interface on pseries/PowerVM systems.
This test validates event logging and status reporting via
`/proc/ppc64/rtas/`.
The test verifies:
- Enumeration of `/proc/ppc64/rtas/` entries
- Reading and basic validation of `rtas_log`
- Parsing RTAS event log headers (version, severity, length)
- Structure of log entries (header, timestamp, severity)
- Handling of invalid RTAS tokens
- Error log rotation behavior
Signed-off-by: Shirisha G <shirisha@linux.ibm.com>
---
.../selftests/powerpc/rtas/rtas_proc_test.c | 101 ++++++++++++++++++
1 file changed, 101 insertions(+)
create mode 100644 tools/testing/selftests/powerpc/rtas/rtas_proc_test.c
diff --git a/tools/testing/selftests/powerpc/rtas/rtas_proc_test.c b/tools/testing/selftests/powerpc/rtas/rtas_proc_test.c
new file mode 100644
index 000000000000..0f8d1408745f
--- /dev/null
+++ b/tools/testing/selftests/powerpc/rtas/rtas_proc_test.c
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * RTAS /proc Interface Test
+ * Copyright (C) 2026 IBM Corporation
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdint.h>
+#include "utils.h"
+
+#define RTAS_PROC_DIR "/proc/ppc64/rtas"
+#define RTAS_LOG "/proc/ppc64/rtas/rtas_log"
+
+/* RTAS log entry header structure */
+struct rtas_log_header {
+ uint32_t signature;
+ uint16_t length;
+ uint8_t version;
+ uint8_t severity;
+ uint8_t disposition;
+ uint8_t extended;
+ /* ... more fields ... */
+} __attribute__((packed));
+
+static int enumerate_rtas_proc(void)
+{
+ DIR *dir;
+ struct dirent *entry;
+ int count = 0;
+
+ dir = opendir(RTAS_PROC_DIR);
+ if (!dir)
+ return -1;
+
+ printf("RTAS proc entries:\n");
+ while ((entry = readdir(dir)) != NULL) {
+ if (entry->d_name[0] != '.') {
+ printf(" %s\n", entry->d_name);
+ count++;
+ }
+ }
+
+ closedir(dir);
+ return count;
+}
+
+static int read_rtas_log(void)
+{
+ int fd;
+ char buf[4096];
+ ssize_t bytes;
+
+ fd = open(RTAS_LOG, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ bytes = read(fd, buf, sizeof(buf));
+ close(fd);
+
+ if (bytes > 0) {
+ printf("Read %zd bytes from RTAS log\n", bytes);
+ /* Basic validation of log format */
+ if (bytes >= sizeof(struct rtas_log_header)) {
+ struct rtas_log_header *hdr = (struct rtas_log_header *)buf;
+ printf(" Log entry: version=%u, severity=%u, length=%u\n",
+ hdr->version, hdr->severity, hdr->length);
+ }
+ }
+
+ return bytes;
+}
+
+int main(void)
+{
+ int count, ret;
+
+ test_harness_set_timeout(10);
+
+ /* Test 1: Verify RTAS proc directory exists */
+ SKIP_IF(access(RTAS_PROC_DIR, R_OK) != 0);
+
+ /* Test 2: Enumerate RTAS proc entries */
+ count = enumerate_rtas_proc();
+ FAIL_IF_MSG(count < 0, "Failed to enumerate RTAS proc entries");
+ FAIL_IF_MSG(count == 0, "No RTAS proc entries found");
+
+ /* Test 3: Read RTAS log */
+ ret = read_rtas_log();
+ /* Log may be empty, which is OK */
+ if (ret < 0) {
+ printf("RTAS log not available (may be empty)\n");
+ }
+
+ printf("RTAS proc 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 ` Shirisha G [this message]
2026-09-18 5:22 ` [PATCH 4/7] Subject: [PATCH] selftests/powerpc: Add FADump sysfs interface test 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 ` [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-3-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