@@ -988,6 +988,7 @@ pipe10 pipe10
pipe11 pipe11
pipe12 pipe12
pipe13 pipe13
+pipe14 pipe14
pipe2_01 pipe2_01
pipe2_02 pipe2_02
@@ -11,3 +11,4 @@
/pipe11
/pipe12
/pipe13
+/pipe14
new file mode 100644
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 SUSE LLC Avinesh Kumar <avinesh.kumar@suse.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that, if the write end of a pipe is closed, then a process reading
+ * from the pipe will see end-of-file (i.e., read() returns 0) once it has
+ * read all remaining data in the pipe.
+ */
+
+#include "tst_test.h"
+
+static int fds[2];
+
+static void run(void)
+{
+ char wrbuf[] = "abcdefghijklmnopqrstuvwxyz";
+ char rdbuf[30];
+
+ memset(rdbuf, 0, sizeof(rdbuf));
+ SAFE_PIPE(fds);
+
+ SAFE_WRITE(SAFE_WRITE_ALL, fds[1], wrbuf, sizeof(wrbuf));
+ SAFE_CLOSE(fds[1]);
+
+ SAFE_READ(0, fds[0], rdbuf, sizeof(wrbuf));
+
+ TST_EXP_VAL(SAFE_READ(0, fds[0], rdbuf, 1), 0);
+ SAFE_CLOSE(fds[0]);
+}
+
+static void cleanup(void)
+{
+ if (fds[0] > 0)
+ SAFE_CLOSE(fds[0]);
+ if (fds[1] > 0)
+ SAFE_CLOSE(fds[1]);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .cleanup = cleanup
+};
New test to verify, if the write end of a pipe is closed, then a process reading from the pipe will see end-of-file (i.e., read() returns 0) once it has read all remaining data in the pipe. Signed-off-by: Avinesh Kumar <akumar@suse.de> --- runtest/syscalls | 1 + testcases/kernel/syscalls/pipe/.gitignore | 1 + testcases/kernel/syscalls/pipe/pipe14.c | 46 +++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 testcases/kernel/syscalls/pipe/pipe14.c