-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a -timeout
option to ocamltest
#10113
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,3 +65,5 @@ val test_pass : Variables.t | |
val test_skip : Variables.t | ||
|
||
val test_fail : Variables.t | ||
|
||
val timeout : Variables.t |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,10 @@ | |
/* */ | ||
/**************************************************************************/ | ||
|
||
/* Run programs with rediretions and timeouts under Windows */ | ||
/* Run programs with redirections and timeouts under Windows */ | ||
|
||
/* GetTickCount64() requires Windows Vista or Server 2008 */ | ||
#define _WIN32_WINNT 0x0600 | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
@@ -257,7 +260,8 @@ int run_command(const command_settings *settings) | |
STARTUPINFO startup_info; | ||
PROCESS_INFORMATION process_info; | ||
BOOL wait_result; | ||
DWORD status, stamp, cur; | ||
DWORD status; | ||
ULONGLONG stamp, cur; | ||
DWORD timeout = (settings->timeout > 0) ? settings->timeout * 1000 : INFINITE; | ||
|
||
JOBOBJECT_ASSOCIATE_COMPLETION_PORT port = {NULL, NULL}; | ||
|
@@ -359,7 +363,7 @@ int run_command(const command_settings *settings) | |
ResumeThread(process_info.hThread); | ||
CloseHandle(process_info.hThread); | ||
|
||
stamp = GetTickCount(); | ||
stamp = GetTickCount64(); | ||
while ((wait_result = GetQueuedCompletionStatus(port.CompletionPort, | ||
&completion_code, | ||
&completion_key, | ||
|
@@ -369,10 +373,12 @@ int run_command(const command_settings *settings) | |
{ | ||
if (timeout != INFINITE) | ||
{ | ||
cur = GetTickCount(); | ||
stamp = (cur > stamp ? cur - stamp : MAXDWORD - stamp + cur); | ||
timeout = (timeout > stamp ? timeout - stamp : 0); | ||
stamp = cur; | ||
cur = GetTickCount64(); | ||
if (cur > stamp) { | ||
ULONGLONG elapsed = cur - stamp; | ||
timeout = (timeout > elapsed ? timeout - elapsed : 0); | ||
stamp = cur; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am assuming that this is a refactoring. I'm not sure because I am not brave enough this afternoon to read the previous version carefully. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the commit message says, it's a bug fix. The previous code would set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the propensity of our CI systems to witness random events, the original code was attempting to deal with I think |
||
} | ||
} | ||
if (wait_result) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh. Apparently this code was written before record punning was popular, and I don't think that using it only some of the definitions of the record would improve the codebase. (But feel free to help review existing ocamltest refactoring PRs (#9614) or provide your own!)