summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@samsung.com>2018-08-14 10:53:16 +0300
committerBen Pfaff <blp@ovn.org>2018-08-15 11:36:18 -0700
commit9551e80befc0f8ecc5ee8a7e025147358c2753ee (patch)
tree02defe18c297a92f9426f74918ed2f4bb335f51d /tests
parentcbcf40a847c0539fec36e82410f0966f13517964 (diff)
downloadopenvswitch-9551e80befc0f8ecc5ee8a7e025147358c2753ee.tar.gz
tests: Use environment variable for default timeout.
Introduce new 'OVS_CTL_TIMEOUT' environment variable that, if set, will be used as a default timeout for OVS control utilities. Setting it in 'atlocal.in' will cover all the hangs inside the testsuite, even when utils called in a subshell. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/appctl.py3
-rw-r--r--tests/atlocal.in4
-rw-r--r--tests/test-ovsdb.c6
-rw-r--r--tests/test-ovsdb.py4
4 files changed, 11 insertions, 6 deletions
diff --git a/tests/appctl.py b/tests/appctl.py
index e4f069665..b85b364fa 100644
--- a/tests/appctl.py
+++ b/tests/appctl.py
@@ -51,8 +51,7 @@ def main():
help="wait at most SECS seconds for a response")
args = parser.parse_args()
- if args.timeout:
- signal_alarm(int(args.timeout))
+ signal_alarm(int(args.timeout) if args.timeout else None)
ovs.vlog.Vlog.init()
target = args.target
diff --git a/tests/atlocal.in b/tests/atlocal.in
index a86de8bc1..abfc1acf3 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -216,3 +216,7 @@ unset OVN_SB_DB
# Prevent logging to syslog during tests.
OVS_SYSLOG_METHOD=null
export OVS_SYSLOG_METHOD
+
+# Set default timeout for control utils
+OVS_CTL_TIMEOUT=30
+export OVS_CTL_TIMEOUT
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index 4b216fe74..f3f0e4967 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -94,9 +94,9 @@ parse_options(int argc, char *argv[], struct test_ovsdb_pvt_context *pvt)
{NULL, 0, NULL, 0},
};
char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
+ unsigned int timeout = 0;
for (;;) {
- unsigned int timeout = 0;
int c;
c = getopt_long(argc, argv, short_options, long_options, NULL);
@@ -108,8 +108,6 @@ parse_options(int argc, char *argv[], struct test_ovsdb_pvt_context *pvt)
case 't':
if (!str_to_uint(optarg, 10, &timeout) || !timeout) {
ovs_fatal(0, "value %s on -t or --timeout is invalid", optarg);
- } else {
- time_alarm(timeout);
}
break;
@@ -140,6 +138,8 @@ parse_options(int argc, char *argv[], struct test_ovsdb_pvt_context *pvt)
}
}
free(short_options);
+
+ ctl_timeout_setup(timeout);
}
static void
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index ed5d21b0c..14491a2e9 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -822,6 +822,7 @@ def main(argv):
sys.stderr.write("%s: %s\n" % (ovs.util.PROGRAM_NAME, geo.msg))
sys.exit(1)
+ timeout = None
for key, value in options:
if key in ['-h', '--help']:
usage()
@@ -833,10 +834,11 @@ def main(argv):
except TypeError:
raise error.Error("value %s on -t or --timeout is not at "
"least 1" % value)
- signal_alarm(timeout)
else:
sys.exit(0)
+ signal_alarm(timeout)
+
if not args:
sys.stderr.write("%s: missing command argument "
"(use --help for help)\n" % ovs.util.PROGRAM_NAME)