Pau Espin Pedrol | 510ed80 | 2018-05-07 14:13:23 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | from osmo_gsm_tester.testenv import * |
| 3 | |
| 4 | def call_test_setup_run(bts_setup_cb=None): |
| 5 | hlr = suite.hlr() |
| 6 | bts = suite.bts() |
| 7 | mgw_msc = suite.mgw() |
| 8 | mgw_bsc = suite.mgw() |
| 9 | stp = suite.stp() |
| 10 | msc = suite.msc(hlr, mgw_msc, stp) |
| 11 | bsc = suite.bsc(msc, mgw_bsc, stp) |
| 12 | ms_mo = suite.modem() |
| 13 | ms_mt = suite.modem() |
| 14 | |
| 15 | if bts_setup_cb is not None: |
| 16 | bts_setup_cb(bts) |
| 17 | |
| 18 | hlr.start() |
| 19 | stp.start() |
| 20 | msc.start() |
| 21 | mgw_msc.start() |
| 22 | mgw_bsc.start() |
| 23 | |
| 24 | bsc.bts_add(bts) |
| 25 | bsc.start() |
| 26 | |
| 27 | bts.start() |
| 28 | wait(bsc.bts_is_connected, bts) |
| 29 | |
| 30 | hlr.subscriber_add(ms_mo) |
| 31 | hlr.subscriber_add(ms_mt) |
| 32 | |
| 33 | ms_mo.connect(msc.mcc_mnc()) |
| 34 | ms_mt.connect(msc.mcc_mnc()) |
| 35 | |
| 36 | ms_mo.log_info() |
| 37 | ms_mt.log_info() |
| 38 | |
| 39 | print('waiting for modems to attach...') |
| 40 | wait(ms_mo.is_connected, msc.mcc_mnc()) |
| 41 | wait(ms_mt.is_connected, msc.mcc_mnc()) |
| 42 | wait(msc.subscriber_attached, ms_mo, ms_mt) |
| 43 | |
| 44 | assert len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0 |
| 45 | mo_cid = ms_mo.call_dial(ms_mt) |
| 46 | mt_cid = ms_mt.call_wait_incoming(ms_mo) |
| 47 | print('dial success') |
| 48 | |
| 49 | assert not ms_mo.call_is_active(mo_cid) and not ms_mt.call_is_active(mt_cid) |
| 50 | ms_mt.call_answer(mt_cid) |
| 51 | wait(ms_mo.call_is_active, mo_cid) |
| 52 | wait(ms_mt.call_is_active, mt_cid) |
| 53 | print('answer success, call established and ongoing') |
| 54 | |
| 55 | sleep(5) # maintain the call active for 5 seconds |
| 56 | |
| 57 | assert ms_mo.call_is_active(mo_cid) and ms_mt.call_is_active(mt_cid) |
| 58 | ms_mt.call_hangup(mt_cid) |
| 59 | wait(lambda: len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0) |
| 60 | print('hangup success') |