From af0835812d8a34be336007c6d35595cc50409b56 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 17 Nov 2020 03:48:04 +0100 Subject: speed up py tests: add --fast-shutdown option to osmo-bsc For each VTY and CTRL test run, we wait three seconds for OML shutdown. That adds up to quite a bit of boring wait time. Skip the final shutdown sleep() for many py tests: - VTY transcript tests - tests run by vty_test_runner.py - tests run by ctrl_test_runner.py - tests run by osmotestvty.py Tests run by osmotestconfig.py do not allow passing arbitrary cmdline options from the osmoappdesc.py, so they are as slow as before. Change-Id: I506349c532b13751f674e4b9a132219d823f19e1 --- osmoappdesc.py | 2 +- src/osmo-bsc/osmo_bsc_main.c | 9 ++++++++- tests/Makefile.am | 2 +- tests/ctrl_test_runner.py | 2 +- tests/vty_test_runner.py | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/osmoappdesc.py b/osmoappdesc.py index 08c3252c1..74a046828 100644 --- a/osmoappdesc.py +++ b/osmoappdesc.py @@ -22,7 +22,7 @@ app_configs = { apps = [(4242, "src/osmo-bsc/osmo-bsc", "OsmoBSC", "osmo-bsc") ] -vty_command = ["./src/osmo-bsc/osmo-bsc", "-c", +vty_command = ["./src/osmo-bsc/osmo-bsc", "--fast-shutdown", "-c", "doc/examples/osmo-bsc/osmo-bsc.cfg"] vty_app = apps[0] diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c index 00d2f3833..dddd6b501 100644 --- a/src/osmo-bsc/osmo_bsc_main.c +++ b/src/osmo-bsc/osmo_bsc_main.c @@ -88,6 +88,7 @@ struct gsm_network *bsc_gsmnet = 0; static const char *config_file = "osmo-bsc.cfg"; static const char *rf_ctrl = NULL; static int daemonize = 0; +static bool fast_shutdown = false; static void print_usage() { @@ -108,6 +109,7 @@ static void print_help() printf(" -e --log-level number Set a global loglevel.\n"); printf(" -r --rf-ctl NAME A unix domain socket to listen for cmds.\n"); printf(" -t --testmode A special mode to provoke failures at the MSC.\n"); + printf(" --fast-shutdown Omit shutdown delay, for rapid testing purposes.\n"); printf("\nVTY reference generation:\n"); printf(" --vty-ref-mode MODE VTY reference generation mode:\n"); @@ -135,6 +137,9 @@ static void handle_long_options(const char *prog_name, const int long_option) get_value_string(vty_ref_gen_mode_desc, vty_ref_mode)); vty_dump_xml_ref_mode(stdout, (enum vty_ref_gen_mode) vty_ref_mode); exit(0); + case 3: + fast_shutdown = true; + break; default: fprintf(stderr, "%s: error parsing cmdline options\n", prog_name); exit(2); @@ -160,6 +165,7 @@ static void handle_options(int argc, char **argv) {"testmode", 0, 0, 't'}, {"vty-ref-mode", 1, &long_option, 1}, {"vty-ref-xml", 0, &long_option, 2}, + {"fast-shutdown", 0, &long_option, 3}, {0, 0, 0, 0} }; @@ -693,7 +699,8 @@ static void signal_handler(int signal) case SIGTERM: bsc_shutdown_net(bsc_gsmnet); osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL); - sleep(3); + if (!fast_shutdown) + sleep(3); exit(0); break; case SIGABRT: diff --git a/tests/Makefile.am b/tests/Makefile.am index c061baaf1..1493ac29c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -70,7 +70,7 @@ VTY_TEST ?= *.vty vty-test: osmo_verify_transcript_vty.py -v \ -n OsmoBSC -p 4242 \ - -r "$(top_builddir)/src/osmo-bsc/osmo-bsc -c $(top_srcdir)/doc/examples/osmo-bsc/osmo-bsc-minimal.cfg" \ + -r "$(top_builddir)/src/osmo-bsc/osmo-bsc --fast-shutdown -c $(top_srcdir)/doc/examples/osmo-bsc/osmo-bsc-minimal.cfg" \ $(U) $(srcdir)/$(VTY_TEST) check-local: atconfig $(TESTSUITE) diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py index 5d2af859a..4b09a136d 100755 --- a/tests/ctrl_test_runner.py +++ b/tests/ctrl_test_runner.py @@ -150,7 +150,7 @@ class TestCtrlBSC(TestCtrlBase): os.unlink("tmp_dummy_sock") def ctrl_command(self): - return ["./src/osmo-bsc/osmo-bsc", "-r", "tmp_dummy_sock", "-c", + return ["./src/osmo-bsc/osmo-bsc", "--fast-shutdown", "-r", "tmp_dummy_sock", "-c", "doc/examples/osmo-bsc/osmo-bsc.cfg"] def ctrl_app(self): diff --git a/tests/vty_test_runner.py b/tests/vty_test_runner.py index 34ddcc7c1..172b14e5e 100755 --- a/tests/vty_test_runner.py +++ b/tests/vty_test_runner.py @@ -108,7 +108,7 @@ class TestVTYGenericBSC(TestVTYBase): class TestVTYBSC(TestVTYGenericBSC): def vty_command(self): - return ["./src/osmo-bsc/osmo-bsc", "-c", + return ["./src/osmo-bsc/osmo-bsc", "--fast-shutdown", "-c", "doc/examples/osmo-bsc/osmo-bsc.cfg"] def vty_app(self): -- cgit v1.2.3