From: Harshal <embedkari167@gmail.com>
To: shuah@kernel.org, skhan@linuxfoundation.org
Cc: Harshal <embedkari167@gmail.com>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] selftests: firmware: Add details in error logging
Date: Tue, 15 Jul 2025 02:56:33 +0530 [thread overview]
Message-ID: <20250714212650.17935-1-embedkari167@gmail.com> (raw)
Specify details in logs of failed cases
Signed-off-by: Harshal <embedkari167@gmail.com>
---
v2:
- revert back to exit() instead of die() to avoid modifying system behaviour
v1: https://lore.kernel.org/all/c7c071ed-6a4e-4a9c-ba9d-c745fd42c22f@linuxfoundation.org/
tools/testing/selftests/firmware/fw_namespace.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/firmware/fw_namespace.c b/tools/testing/selftests/firmware/fw_namespace.c
index 04757dc7e546..5b0032498ede 100644
--- a/tools/testing/selftests/firmware/fw_namespace.c
+++ b/tools/testing/selftests/firmware/fw_namespace.c
@@ -38,7 +38,7 @@ static void trigger_fw(const char *fw_name, const char *sys_path)
fd = open(sys_path, O_WRONLY);
if (fd < 0)
- die("open failed: %s\n",
+ die("open of sys_path failed: %s\n",
strerror(errno));
if (write(fd, fw_name, strlen(fw_name)) != strlen(fw_name))
exit(EXIT_FAILURE);
@@ -52,10 +52,10 @@ static void setup_fw(const char *fw_path)
fd = open(fw_path, O_WRONLY | O_CREAT, 0600);
if (fd < 0)
- die("open failed: %s\n",
+ die("open of firmware file failed: %s\n",
strerror(errno));
if (write(fd, fw, sizeof(fw) -1) != sizeof(fw) -1)
- die("write failed: %s\n",
+ die("write to firmware file failed: %s\n",
strerror(errno));
close(fd);
}
@@ -66,7 +66,7 @@ static bool test_fw_in_ns(const char *fw_name, const char *sys_path, bool block_
if (block_fw_in_parent_ns)
if (mount("test", "/lib/firmware", "tmpfs", MS_RDONLY, NULL) == -1)
- die("blocking firmware in parent ns failed\n");
+ die("blocking firmware in parent namespace failed\n");
child = fork();
if (child == -1) {
@@ -99,11 +99,11 @@ static bool test_fw_in_ns(const char *fw_name, const char *sys_path, bool block_
strerror(errno));
}
if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) == -1)
- die("remount root in child ns failed\n");
+ die("remount root in child namespace failed\n");
if (!block_fw_in_parent_ns) {
if (mount("test", "/lib/firmware", "tmpfs", MS_RDONLY, NULL) == -1)
- die("blocking firmware in child ns failed\n");
+ die("blocking firmware in child namespace failed\n");
} else
umount("/lib/firmware");
@@ -129,8 +129,8 @@ int main(int argc, char **argv)
die("error: failed to build full fw_path\n");
setup_fw(fw_path);
-
setvbuf(stdout, NULL, _IONBF, 0);
+
/* Positive case: firmware in PID1 mount namespace */
printf("Testing with firmware in parent namespace (assumed to be same file system as PID1)\n");
if (!test_fw_in_ns(fw_name, sys_path, false))
--
2.43.0
next reply other threads:[~2025-07-14 21:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 21:26 Harshal [this message]
2025-07-14 21:39 ` [PATCH v2] selftests: firmware: Add details in error logging Shuah Khan
2025-07-20 18:21 ` Harshal Wadhwa
2025-07-24 20:29 ` Shuah Khan
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=20250714212650.17935-1-embedkari167@gmail.com \
--to=embedkari167@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
/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