From 9551e80befc0f8ecc5ee8a7e025147358c2753ee Mon Sep 17 00:00:00 2001 From: Ilya Maximets Date: Tue, 14 Aug 2018 10:53:16 +0300 Subject: 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 Signed-off-by: Ben Pfaff --- tests/appctl.py | 3 +-- tests/atlocal.in | 4 ++++ tests/test-ovsdb.c | 6 +++--- tests/test-ovsdb.py | 4 +++- 4 files changed, 11 insertions(+), 6 deletions(-) (limited to 'tests') 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) -- cgit v1.2.1