This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/8062 tests: voice: Move logic to testlib.py This way we can have several tests sharing similar logic. Change-Id: I5cfcc56970380a7c5400186fac5f504263d63c5f --- M src/osmo_gsm_tester/testenv.py A suites/voice/lib/testlib.py M suites/voice/mo_mt_call.py 3 files changed, 73 insertions(+), 51 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/62/8062/1 diff --git a/src/osmo_gsm_tester/testenv.py b/src/osmo_gsm_tester/testenv.py index 26b492e..15ab7ba 100644 --- a/src/osmo_gsm_tester/testenv.py +++ b/src/osmo_gsm_tester/testenv.py @@ -52,4 +52,14 @@ Timeout = suite_module.Timeout Sms = sms_module.Sms +def add_subdir_to_import_path(subdir_name): + import os, sys, inspect + frame, filename, lineno, function, code_context, index = inspect.stack()[1] + print("filename=%s" %filename) + subdir = os.path.realpath(os.path.join(os.path.split(filename)[0], subdir_name)) + if subdir not in sys.path: + sys.path.insert(0, subdir) + #TODO: we may beed another API to remove the subdir at the end of the test? + #Maybe clean it automatically when returning from test in test.py. + # vim: expandtab tabstop=4 shiftwidth=4 diff --git a/suites/voice/lib/testlib.py b/suites/voice/lib/testlib.py new file mode 100755 index 0000000..f949809 --- /dev/null +++ b/suites/voice/lib/testlib.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +from osmo_gsm_tester.testenv import * + +def call_test_setup_run(bts_setup_cb=None): + hlr = suite.hlr() + bts = suite.bts() + mgw_msc = suite.mgw() + mgw_bsc = suite.mgw() + stp = suite.stp() + msc = suite.msc(hlr, mgw_msc, stp) + bsc = suite.bsc(msc, mgw_bsc, stp) + ms_mo = suite.modem() + ms_mt = suite.modem() + + if bts_setup_cb is not None: + bts_setup_cb(bts) + + hlr.start() + stp.start() + msc.start() + mgw_msc.start() + mgw_bsc.start() + + bsc.bts_add(bts) + bsc.start() + + bts.start() + wait(bsc.bts_is_connected, bts) + + hlr.subscriber_add(ms_mo) + hlr.subscriber_add(ms_mt) + + ms_mo.connect(msc.mcc_mnc()) + ms_mt.connect(msc.mcc_mnc()) + + ms_mo.log_info() + ms_mt.log_info() + + print('waiting for modems to attach...') + wait(ms_mo.is_connected, msc.mcc_mnc()) + wait(ms_mt.is_connected, msc.mcc_mnc()) + wait(msc.subscriber_attached, ms_mo, ms_mt) + + assert len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0 + mo_cid = ms_mo.call_dial(ms_mt) + mt_cid = ms_mt.call_wait_incoming(ms_mo) + print('dial success') + + assert not ms_mo.call_is_active(mo_cid) and not ms_mt.call_is_active(mt_cid) + ms_mt.call_answer(mt_cid) + wait(ms_mo.call_is_active, mo_cid) + wait(ms_mt.call_is_active, mt_cid) + print('answer success, call established and ongoing') + + sleep(5) # maintain the call active for 5 seconds + + assert ms_mo.call_is_active(mo_cid) and ms_mt.call_is_active(mt_cid) + ms_mt.call_hangup(mt_cid) + wait(lambda: len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0) + print('hangup success') diff --git a/suites/voice/mo_mt_call.py b/suites/voice/mo_mt_call.py index aeda80d..4021762 100755 --- a/suites/voice/mo_mt_call.py +++ b/suites/voice/mo_mt_call.py @@ -1,56 +1,8 @@ #!/usr/bin/env python3 from osmo_gsm_tester.testenv import * -hlr = suite.hlr() -bts = suite.bts() -mgw_msc = suite.mgw() -mgw_bsc = suite.mgw() -stp = suite.stp() -msc = suite.msc(hlr, mgw_msc, stp) -bsc = suite.bsc(msc, mgw_bsc, stp) -ms_mo = suite.modem() -ms_mt = suite.modem() +add_subdir_to_import_path("lib") +from testlib import call_test_setup_run -hlr.start() -stp.start() -msc.start() -mgw_msc.start() -mgw_bsc.start() -bsc.bts_add(bts) -bsc.start() - -bts.start() -wait(bsc.bts_is_connected, bts) - -hlr.subscriber_add(ms_mo) -hlr.subscriber_add(ms_mt) - -ms_mo.connect(msc.mcc_mnc()) -ms_mt.connect(msc.mcc_mnc()) - -ms_mo.log_info() -ms_mt.log_info() - -print('waiting for modems to attach...') -wait(ms_mo.is_connected, msc.mcc_mnc()) -wait(ms_mt.is_connected, msc.mcc_mnc()) -wait(msc.subscriber_attached, ms_mo, ms_mt) - -assert len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0 -mo_cid = ms_mo.call_dial(ms_mt) -mt_cid = ms_mt.call_wait_incoming(ms_mo) -print('dial success') - -assert not ms_mo.call_is_active(mo_cid) and not ms_mt.call_is_active(mt_cid) -ms_mt.call_answer(mt_cid) -wait(ms_mo.call_is_active, mo_cid) -wait(ms_mt.call_is_active, mt_cid) -print('answer success, call established and ongoing') - -sleep(5) # maintain the call active for 5 seconds - -assert ms_mo.call_is_active(mo_cid) and ms_mt.call_is_active(mt_cid) -ms_mt.call_hangup(mt_cid) -wait(lambda: len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0) -print('hangup success') +call_test_setup_run() -- To view, visit https://gerrit.osmocom.org/8062 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5cfcc56970380a7c5400186fac5f504263d63c5f Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-tester Gerrit-Branch: master Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>