[PATCH 22/27] selftests/landlock: Fix messages and comments in helper programs
From: Günther Noack
Date: Thu Oct 08 2026 - 10:33:09 EST
* sandbox-and-launch: Describe the actual argument order.
* sandbox-and-launch, wait-pipe, wait-pipe-sandbox: Report failed
read(2) calls as read failures, not write failures.
* wait-pipe-sandbox: Terminate error messages with a newline, and fix
comments naming "." instead of the opened "/".
Assisted-by: LLM
Signed-off-by: Günther Noack <gnoack3000@xxxxxxxxx>
---
.../selftests/landlock/sandbox-and-launch.c | 6 +++---
.../selftests/landlock/wait-pipe-sandbox.c | 16 ++++++++--------
tools/testing/selftests/landlock/wait-pipe.c | 2 +-
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/tools/testing/selftests/landlock/sandbox-and-launch.c b/tools/testing/selftests/landlock/sandbox-and-launch.c
index 3e32e1a51ac5..8b33ddadc63e 100644
--- a/tools/testing/selftests/landlock/sandbox-and-launch.c
+++ b/tools/testing/selftests/landlock/sandbox-and-launch.c
@@ -25,8 +25,8 @@ int main(int argc, char *argv[])
char buf;
/*
- * The first argument must be the file descriptor number of a pipe.
- * The second argument must be the program to execute.
+ * The first argument must be the program to execute. The second and
+ * third arguments must be the file descriptor numbers of two pipes.
*/
if (argc != 4) {
fprintf(stderr, "Wrong number of arguments (not three)\n");
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
/* Waits for the parent to try to umount. */
if (read(pipe_parent, &buf, 1) != 1) {
- perror("Failed to write to the third argument");
+ perror("Failed to read from the third argument");
return 1;
}
diff --git a/tools/testing/selftests/landlock/wait-pipe-sandbox.c b/tools/testing/selftests/landlock/wait-pipe-sandbox.c
index 87dbc9164430..dbc0c2747e9f 100644
--- a/tools/testing/selftests/landlock/wait-pipe-sandbox.c
+++ b/tools/testing/selftests/landlock/wait-pipe-sandbox.c
@@ -31,7 +31,7 @@ static int sync_with(int pipe_child, int pipe_parent)
/* Waits for the parent do its test. */
if (read(pipe_parent, &buf, 1) != 1) {
- perror("Failed to write to the second argument");
+ perror("Failed to read from the second argument");
return 1;
}
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
/* Tries to send a signal, denied by layer1. */
if (!kill(getppid(), 0)) {
- fprintf(stderr, "Successfully sent a signal to the parent");
+ fprintf(stderr, "Successfully sent a signal to the parent\n");
return 1;
}
@@ -88,13 +88,13 @@ int main(int argc, char *argv[])
/* Tries to send a signal, denied by layer1. */
if (!kill(getppid(), 0)) {
- fprintf(stderr, "Successfully sent a signal to the parent");
+ fprintf(stderr, "Successfully sent a signal to the parent\n");
return 1;
}
- /* Tries to open ., denied by layer2. */
+ /* Tries to open /, denied by layer2. */
if (open("/", O_RDONLY | O_DIRECTORY | O_CLOEXEC) >= 0) {
- fprintf(stderr, "Successfully opened /");
+ fprintf(stderr, "Successfully opened /\n");
return 1;
}
@@ -115,15 +115,15 @@ int main(int argc, char *argv[])
}
close(ruleset_fd);
- /* Tries to open ., denied by layer2. */
+ /* Tries to open /, denied by layer2. */
if (open("/", O_RDONLY | O_DIRECTORY | O_CLOEXEC) >= 0) {
- fprintf(stderr, "Successfully opened /");
+ fprintf(stderr, "Successfully opened /\n");
return 1;
}
/* Tries to send a signal, denied by layer3. */
if (!kill(getppid(), 0)) {
- fprintf(stderr, "Successfully sent a signal to the parent");
+ fprintf(stderr, "Successfully sent a signal to the parent\n");
return 1;
}
diff --git a/tools/testing/selftests/landlock/wait-pipe.c b/tools/testing/selftests/landlock/wait-pipe.c
index 0dbcd260a0fa..3cfa4dce5f35 100644
--- a/tools/testing/selftests/landlock/wait-pipe.c
+++ b/tools/testing/selftests/landlock/wait-pipe.c
@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
/* Waits for the parent do its test. */
if (read(pipe_parent, &buf, 1) != 1) {
- perror("Failed to write to the second argument");
+ perror("Failed to read from the second argument");
return 1;
}
--
2.56.0