@@ -217,6 +217,7 @@ const char *tst_strsig(int sig);
*/
const char *tst_strstatus(int status);
+float tst_timeout_mul(void);
void tst_set_timeout(int timeout);
#ifndef TST_NO_DEFAULT_MAIN
@@ -992,26 +992,31 @@ static void sigint_handler(int sig LTP_ATTRIBUTE_UNUSED)
}
}
-void tst_set_timeout(int timeout)
+float tst_timeout_mul(void)
{
char *mul = getenv("LTP_TIMEOUT_MUL");
- if (timeout == -1) {
- tst_res(TINFO, "Timeout per run is disabled");
- return;
- }
-
- results->timeout = timeout;
-
if (mul) {
float m = atof(mul);
if (m < 1)
tst_brk(TBROK, "Invalid timeout multiplier '%s'", mul);
- results->timeout = results->timeout * m + 0.5;
+ return m;
+ }
+
+ return 1;
+}
+
+void tst_set_timeout(int timeout)
+{
+ if (timeout == -1) {
+ tst_res(TINFO, "Timeout per run is disabled");
+ return;
}
+ results->timeout = timeout * tst_timeout_mul() + 0.5;
+
tst_res(TINFO, "Timeout per run is %uh %02um %02us",
results->timeout/3600, (results->timeout%3600)/60,
results->timeout % 60);
Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com> --- V2: * Remove code which performs extra loop if one thread is behind the other because it only works when thread A sets exit after it has finished looping. * Scale the execution time by LTP_TIMEOUT_MUL include/tst_test.h | 1 + lib/tst_test.c | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-)