crt: tests: t_assert: write child process' output to stdout

After the child process terminates, read the rest of the data it has written
to the pipe and write it to stdout; this allows to examine assertion message
printed by the child process.

Signed-off-by: Kirill Makurin <maiddaisuki@outlook.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-crt/testcases/t_assert.c b/mingw-w64-crt/testcases/t_assert.c
index 7e74ea7..3c3da94 100644
--- a/mingw-w64-crt/testcases/t_assert.c
+++ b/mingw-w64-crt/testcases/t_assert.c
@@ -36,7 +36,6 @@
         assert(process != -1);
 
         size = read(pipefd[0], buf, sizeof(buf));
-        close(pipefd[0]);
         assert(size > 0); /* some data were written by child process */
         assert(strnlen(buf, sizeof(buf)) > 0);
 
@@ -44,6 +43,13 @@
         assert(_cwait(&exit_code, process, _WAIT_CHILD) == process);
         assert(exit_code != 0);
 
+        /* read the rest of data in the pipe and write it to stdout */
+        if (size < (ssize_t)sizeof(buf)) {
+            size += read(pipefd[0], &buf[size], sizeof(buf) - size);
+        }
+        close(pipefd[0]);
+        write(STDOUT_FILENO, buf, size);
+
         return 0;
     }