blob: 7fa9b6f53246d2b3c37a6065b255d0a8b536c500 [file] [log] [blame]
Pau Espin Pedrol680ba032020-10-14 14:49:05 +02001#!/usr/bin/env python3
2from osmo_gsm_tester.testenv import *
3
4hlr = tenv.hlr()
5bts = tenv.bts()
6mgw_msc = tenv.mgw()
7mgw_bsc = tenv.mgw()
8stp = tenv.stp()
9msc = tenv.msc(hlr, mgw_msc, stp)
10bsc = tenv.bsc(msc, mgw_bsc, stp)
11ms_mo = tenv.modem()
12ms_mt = tenv.modem()
13
14hlr.start()
15stp.start()
16
17# Set MSC to route emergency call to ms_mt:
18msc.set_emergency_call_msisdn(ms_mt.msisdn())
19msc.start()
20
21mgw_msc.start()
22mgw_bsc.start()
23
24bsc.bts_add(bts)
25bsc.start()
26
27bts.start()
28wait(bsc.bts_is_connected, bts)
29
30hlr.subscriber_add(ms_mo)
31hlr.subscriber_add(ms_mt)
32
33ms_mo.connect(msc.mcc_mnc())
34ms_mt.connect(msc.mcc_mnc())
35
36ms_mo.log_info()
37ms_mt.log_info()
38
39print('waiting for modems to attach...')
40wait(ms_mo.is_registered, msc.mcc_mnc())
41wait(ms_mt.is_registered, msc.mcc_mnc())
42wait(msc.subscriber_attached, ms_mo, ms_mt)
43
44assert 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:
46emerg_numbers = ms_mo.emergency_numbers()
47assert len(emerg_numbers) > 0
48print('dialing Emergency Number %s' % (emerg_numbers[0]))
49mo_cid = ms_mo.call_dial(emerg_numbers[0])
50mt_cid = ms_mt.call_wait_incoming(ms_mo)
51print('dial success')
52
53assert not ms_mo.call_is_active(mo_cid) and not ms_mt.call_is_active(mt_cid)
54ms_mt.call_answer(mt_cid)
55wait(ms_mo.call_is_active, mo_cid)
56wait(ms_mt.call_is_active, mt_cid)
57print('answer success, call established and ongoing')
58
59sleep(5) # maintain the call active for 5 seconds
60
61assert ms_mo.call_is_active(mo_cid) and ms_mt.call_is_active(mt_cid)
62ms_mt.call_hangup(mt_cid)
63wait(lambda: len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0)
64print('hangup success')