From 727526815a2d2a10e35a1a2cc62add1a00baabf0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 30 Sep 2024 16:16:36 +0100 Subject: [PATCH 1/5] testprocess: Update iteration count as (presumably) intended Helps: https://github.com/libsdl-org/SDL/issues/11006 Signed-off-by: Simon McVittie --- test/testprocess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testprocess.c b/test/testprocess.c index 97645d0249f1c..9de8e4f02a615 100644 --- a/test/testprocess.c +++ b/test/testprocess.c @@ -454,7 +454,7 @@ static int process_testStdinToStdout(void *arg) total_written = 0; total_read = 0; - for (;;) { + for (iteration_count = 0; true; iteration_count++) { int log_this_iteration = (iteration_count % 32) == 32; char local_buffer[16 * 4094]; size_t amount_read; From a2c3bf044c36b2c4ec43ce0208ea62e067e4f0c5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 30 Sep 2024 16:17:32 +0100 Subject: [PATCH 2/5] testprocess: Show log messages as (presumably) intended The result of the `%` operator will be in the range 0 to 31, so it would never be 32, but it can be 0. Helps: https://github.com/libsdl-org/SDL/issues/11006 Signed-off-by: Simon McVittie --- test/testprocess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testprocess.c b/test/testprocess.c index 9de8e4f02a615..8cb2cc239b53c 100644 --- a/test/testprocess.c +++ b/test/testprocess.c @@ -455,7 +455,7 @@ static int process_testStdinToStdout(void *arg) total_written = 0; total_read = 0; for (iteration_count = 0; true; iteration_count++) { - int log_this_iteration = (iteration_count % 32) == 32; + int log_this_iteration = (iteration_count % 32) == 0; char local_buffer[16 * 4094]; size_t amount_read; SDL_IOStatus io_status; From 53d9c340d287ff08d1cf31f922eef5a5dafb0d9a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 30 Sep 2024 16:18:09 +0100 Subject: [PATCH 3/5] testprocess: Log a message when all data has been written This will make it more obvious when writing has finished and we are only waiting for reading. Helps: https://github.com/libsdl-org/SDL/issues/11006 Signed-off-by: Simon McVittie --- test/testprocess.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/testprocess.c b/test/testprocess.c index 8cb2cc239b53c..67c5a88cefb6a 100644 --- a/test/testprocess.c +++ b/test/testprocess.c @@ -477,6 +477,9 @@ static int process_testStdinToStdout(void *arg) } total_written += amount_written; SDL_FlushIO(process_stdin); + if (total_written == text_in_size) { + SDLTest_Log("All data written to stdin"); + } } /* FIXME: this needs a rate limit */ From d44e805855f9c850c0f9dfa3e60c96ab0f1d67bc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 30 Sep 2024 16:19:43 +0100 Subject: [PATCH 4/5] testprocess: Log on every iteration Helps: https://github.com/libsdl-org/SDL/issues/11006 Signed-off-by: Simon McVittie --- test/testprocess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testprocess.c b/test/testprocess.c index 67c5a88cefb6a..3ce05bbcb277e 100644 --- a/test/testprocess.c +++ b/test/testprocess.c @@ -455,7 +455,7 @@ static int process_testStdinToStdout(void *arg) total_written = 0; total_read = 0; for (iteration_count = 0; true; iteration_count++) { - int log_this_iteration = (iteration_count % 32) == 0; + bool log_this_iteration = true; char local_buffer[16 * 4094]; size_t amount_read; SDL_IOStatus io_status; From f53f9e994504a6d1d7180459ff6df298167e08cb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 30 Sep 2024 16:22:04 +0100 Subject: [PATCH 5/5] testprocess: Improve debug logging Helps: https://github.com/libsdl-org/SDL/issues/11006 Signed-off-by: Simon McVittie --- test/testprocess.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/testprocess.c b/test/testprocess.c index 3ce05bbcb277e..a6d9bdf1c15b1 100644 --- a/test/testprocess.c +++ b/test/testprocess.c @@ -466,7 +466,10 @@ static int process_testStdinToStdout(void *arg) } amount_written = SDL_WriteIO(process_stdin, text_in + total_written, text_in_size - total_written); if (log_this_iteration) { - SDLTest_Log("SDL_WriteIO() -> %u (%dth time)", (unsigned)amount_written, iteration_count); + SDLTest_Log("SDL_WriteIO() -> %u (%dth time), total written %u", + (unsigned)amount_written, + iteration_count, + (unsigned)(total_written + amount_written)); } if (amount_written == 0) { io_status = SDL_GetIOStatus(process_stdin); @@ -480,6 +483,9 @@ static int process_testStdinToStdout(void *arg) if (total_written == text_in_size) { SDLTest_Log("All data written to stdin"); } + else if (total_written > text_in_size) { + SDLTest_Log("Too much data written?!"); + } } /* FIXME: this needs a rate limit */ @@ -488,7 +494,10 @@ static int process_testStdinToStdout(void *arg) } amount_read = SDL_ReadIO(process_stdout, local_buffer, sizeof(local_buffer)); if (log_this_iteration) { - SDLTest_Log("SDL_ReadIO() -> %u (%dth time)", (unsigned)amount_read, iteration_count); + SDLTest_Log("SDL_ReadIO() -> %u (%dth time), total read %u", + (unsigned)amount_read, + iteration_count, + (unsigned)(total_read + amount_read)); } if (amount_read == 0) { io_status = SDL_GetIOStatus(process_stdout);