Pau Espin Pedrol | 680ba03 | 2020-10-14 14:49:05 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | from osmo_gsm_tester.testenv import * |
| 3 | |
| 4 | hlr = tenv.hlr() |
| 5 | bts = tenv.bts() |
| 6 | mgw_msc = tenv.mgw() |
| 7 | mgw_bsc = tenv.mgw() |
| 8 | stp = tenv.stp() |
| 9 | msc = tenv.msc(hlr, mgw_msc, stp) |
| 10 | bsc = tenv.bsc(msc, mgw_bsc, stp) |
| 11 | ms_mo = tenv.modem() |
| 12 | ms_mt = tenv.modem() |
| 13 | |
| 14 | hlr.start() |
| 15 | stp.start() |
| 16 | |
| 17 | # Set MSC to route emergency call to ms_mt: |
| 18 | msc.set_emergency_call_msisdn(ms_mt.msisdn()) |
| 19 | msc.start() |
| 20 | |
| 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_registered, msc.mcc_mnc()) |
| 41 | wait(ms_mt.is_registered, 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 | # Calling emergency number should be redirected to ms_mt as configured further above: |
| 46 | emerg_numbers = ms_mo.emergency_numbers() |
| 47 | assert len(emerg_numbers) > 0 |
| 48 | print('dialing Emergency Number %s' % (emerg_numbers[0])) |
| 49 | mo_cid = ms_mo.call_dial(emerg_numbers[0]) |
| 50 | mt_cid = ms_mt.call_wait_incoming(ms_mo) |
| 51 | print('dial success') |
| 52 | |
| 53 | assert not ms_mo.call_is_active(mo_cid) and not ms_mt.call_is_active(mt_cid) |
| 54 | ms_mt.call_answer(mt_cid) |
| 55 | wait(ms_mo.call_is_active, mo_cid) |
| 56 | wait(ms_mt.call_is_active, mt_cid) |
| 57 | print('answer success, call established and ongoing') |
| 58 | |
| 59 | sleep(5) # maintain the call active for 5 seconds |
| 60 | |
| 61 | assert ms_mo.call_is_active(mo_cid) and ms_mt.call_is_active(mt_cid) |
| 62 | ms_mt.call_hangup(mt_cid) |
| 63 | wait(lambda: len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0) |
| 64 | print('hangup success') |