vtest: Add "option timeout" to adjust the timeout per test case

parent fec25970
......@@ -45,6 +45,7 @@ CMD_GLOBAL(include)
#endif
CMD_TOP(client)
CMD_TOP(feature)
CMD_TOP(option)
CMD_TOP(filewrite)
CMD_TOP(haproxy)
#ifdef VTEST_WITH_VTC_LOGEXPECT
......
varnishtest "Test varnishtest itself"
option timeout 60s
option timeout x1.1
shell -exit 1 -expect {varnishtest [options]} {varnishtest -h}
shell -exit 1 -match {-D.*Define macro} {varnishtest -h}
......
......@@ -660,3 +660,52 @@ cmd_feature(CMD_ARGS)
return;
}
}
static void
set_timeout(struct vtclog *vl, const char *val)
{
double num;
char *s = NULL;
if (val == NULL || *val == '\0') {
vtc_fatal(vl, "FAIL test, missing \"option timeout\" value");
return;
}
if (*val == 'x') {
num = strtod(val + 1, &s);
num *= vtc_maxdur;
} else
num = VNUM_duration(val);
if (isnan(num) || (s != NULL && *s != '\0')) {
vtc_fatal(vl, "FAIL test, invalid \"option timeout\": %s", val);
return;
}
vtc_maxdur = num;
vtc_log(vl, 4, "new timeout %.2f", vtc_maxdur);
}
/* SECTION: option <option> <value>
*
* Set varnishtest options
*
* timeout <duration>
* Override -t argument
* timeout x<factor>
* Scale timeout by a <factor>
*/
void v_matchproto_(cmd_f)
cmd_option(CMD_ARGS)
{
(void)priv;
if (av == NULL)
return;
av++;
if (!strcmp(av[0], "timeout"))
set_timeout(vl, av[1]);
else
vtc_fatal(vl, "FAIL test, unknown option: %s", av[0]);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment