Looking at the last cmd tests it shows multiple, flaky timeouts
at syswow64 at windows 10 with some non-english locales.
Unfortunately these timeouts seem to appear just on the
daily batch run of testbot.
Therefore would a change like this be acceptable to get a few of the
last lines written to stdout and stderr by the cmd tests?
---
programs/cmd/tests/batch.c | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c
index 2fae0a37edd..e1a2e2efdd4 100644
--- a/programs/cmd/tests/batch.c
+++ b/programs/cmd/tests/batch.c
@@ -74,6 +74,34 @@ static const char* convert_input_data(const char *data, DWORD size, DWORD *new_s
return new_data;
}
+static void timeout_helper(HANDLE file, const char* description)
+{
+ char buf[255] = {};
+ DWORD size = 0;
+ DWORD start = 0;
+ int i;
+
+ size = GetFileSize(file, NULL);
+ if (size > sizeof(buf))
+ start = size - sizeof(buf);
+
+ if (SetFilePointer(file, start, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
+ ok(0, "timeout_helper: SetFilePointer failed\n");
+ return;
+ }
+
+ if (ReadFile(file, buf, sizeof(buf)-1, &size, NULL) == 0) {
+ ok(0, "timeout_helper: ReadFile failed\n");
+ return;
+ }
+
+ for (i = 0; i < sizeof(buf); i++) {
+ if (buf[i] == '\n') buf[i] = '#';
+ if (buf[i] == '\r') buf[i] = '#';
+ }
+ ok(0, "timeout reaching, last lines of %s: ...%s\n", description, buf);
+}
+
static BOOL run_cmd(const char *cmd_data, DWORD cmd_size)
{
SECURITY_ATTRIBUTES sa = {sizeof(sa), 0, TRUE};
@@ -96,13 +124,13 @@ static BOOL run_cmd(const char *cmd_data, DWORD cmd_size)
if(!bres)
return FALSE;
- file = CreateFileA("test.out", GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, &sa, CREATE_ALWAYS,
+ file = CreateFileA("test.out", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, &sa, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
if(file == INVALID_HANDLE_VALUE)
return FALSE;
- fileerr = CreateFileA("test.err", GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, &sa, CREATE_ALWAYS,
+ fileerr = CreateFileA("test.err", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, &sa, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
ok(fileerr != INVALID_HANDLE_VALUE, "CreateFile stderr failed\n");
if(fileerr == INVALID_HANDLE_VALUE)
@@ -118,6 +146,12 @@ static BOOL run_cmd(const char *cmd_data, DWORD cmd_size)
return FALSE;
}
+ /* Short before reaching the 120 seconds timeout in testbot,
+ * make the last lines from stdout and stderr visible. */
+ if (WaitForSingleObject(pi.hProcess, 115000) == WAIT_TIMEOUT) {
+ timeout_helper(file, "stdout");
+ timeout_helper(fileerr, "stderr");
+ }
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
--
2.20.1