Pau Espin Pedrol | 7fa19ac | 2018-09-21 12:25:54 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | from osmo_gsm_tester.testenv import * |
| 3 | |
| 4 | |
| 5 | def activate_pdp(ms_mo, ms_mt): |
| 6 | # We need to use inet46 since ofono qmi only uses ipv4v6 eua (OS#2713) |
| 7 | ctx_id_v4_mo = ms_mo.activate_context(apn='inet46', protocol=ms_mo.CTX_PROT_IPv4) |
| 8 | print('ms_mo pdp ctx %r activated' % repr(ctx_id_v4_mo)) |
| 9 | ctx_id_v4_mt = ms_mt.activate_context(apn='inet46', protocol=ms_mt.CTX_PROT_IPv4) |
| 10 | print('ms_mt pdp ctx %r activated' % repr(ctx_id_v4_mt)) |
| 11 | sleep(5) |
| 12 | ms_mo.deactivate_context(ctx_id_v4_mo) |
| 13 | ms_mt.deactivate_context(ctx_id_v4_mt) |
| 14 | |
| 15 | def make_call(ms_mo, ms_mt): |
| 16 | assert len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0 |
| 17 | mo_cid = ms_mo.call_dial(ms_mt) |
| 18 | mt_cid = ms_mt.call_wait_incoming(ms_mo) |
| 19 | print('dial success') |
| 20 | |
| 21 | assert not ms_mo.call_is_active(mo_cid) and not ms_mt.call_is_active(mt_cid) |
| 22 | ms_mt.call_answer(mt_cid) |
| 23 | wait(ms_mo.call_is_active, mo_cid) |
| 24 | wait(ms_mt.call_is_active, mt_cid) |
| 25 | print('answer success, call established and ongoing') |
| 26 | |
| 27 | sleep(5) # maintain the call active for 5 seconds |
| 28 | |
| 29 | assert ms_mo.call_is_active(mo_cid) and ms_mt.call_is_active(mt_cid) |
| 30 | ms_mo.call_hangup(mo_cid) |
| 31 | ms_mt.call_hangup(mt_cid) |
| 32 | wait(lambda: len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0) |
| 33 | print('hangup success') |
| 34 | |
| 35 | hlr = suite.hlr() |
| 36 | bts = suite.bts() |
| 37 | pcu = bts.pcu() |
| 38 | mgw_msc = suite.mgw() |
| 39 | mgw_bsc = suite.mgw() |
| 40 | stp = suite.stp() |
| 41 | ggsn = suite.ggsn() |
| 42 | sgsn = suite.sgsn(hlr, ggsn) |
| 43 | msc = suite.msc(hlr, mgw_msc, stp) |
| 44 | bsc = suite.bsc(msc, mgw_bsc, stp) |
| 45 | ms_mo = suite.modem() |
| 46 | ms_mt = suite.modem() |
| 47 | |
| 48 | bsc.bts_add(bts) |
| 49 | sgsn.bts_add(bts) |
| 50 | |
| 51 | print('start network...') |
| 52 | hlr.start() |
| 53 | stp.start() |
| 54 | ggsn.start() |
| 55 | sgsn.start() |
| 56 | msc.start() |
| 57 | mgw_msc.start() |
| 58 | mgw_bsc.start() |
| 59 | bsc.start() |
| 60 | |
| 61 | bts.start() |
| 62 | wait(bsc.bts_is_connected, bts) |
| 63 | print('Waiting for bts to be ready...') |
| 64 | wait(bts.ready_for_pcu) |
| 65 | pcu.start() |
| 66 | |
| 67 | hlr.subscriber_add(ms_mo) |
| 68 | hlr.subscriber_add(ms_mt) |
| 69 | |
| 70 | ms_mo.connect(msc.mcc_mnc()) |
| 71 | ms_mt.connect(msc.mcc_mnc()) |
| 72 | ms_mo.attach() |
| 73 | ms_mt.attach() |
| 74 | |
| 75 | ms_mo.log_info() |
| 76 | ms_mt.log_info() |
| 77 | |
| 78 | print('waiting for modems to attach...') |
| 79 | wait(ms_mo.is_connected, msc.mcc_mnc()) |
| 80 | wait(ms_mt.is_connected, msc.mcc_mnc()) |
| 81 | wait(msc.subscriber_attached, ms_mo) |
| 82 | wait(msc.subscriber_attached, ms_mt) |
| 83 | |
| 84 | print('waiting for modems to attach to data services...') |
| 85 | wait(ms_mo.is_attached) |
| 86 | wait(ms_mt.is_attached) |
| 87 | |
| 88 | print('1: activate_pdp') |
| 89 | activate_pdp(ms_mo, ms_mt) |
| 90 | print('2: make_call') |
| 91 | make_call(ms_mo, ms_mt) |
| 92 | print('3: Wait 30 seconds to let PCU handle the PDCH channels again') |
| 93 | sleep(30) |
| 94 | print('3: activate_pdp') |
| 95 | activate_pdp(ms_mo, ms_mt) |
| 96 | print('4: make_call') |
| 97 | make_call(ms_mo, ms_mt) |
| 98 | print('Done!') |