blob: b4fba4bf3bccaf567063a8e1f68dcfa6eda7f1e5 [file] [log] [blame]
Pau Espin Pedrol66c05422020-10-15 18:07:06 +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()
13ms_mo_emerg = tenv.modem()
14ms_mt_emerg = tenv.modem()
15
16# Configure timeslots so that only 1 concurrent call (MO MT, 2 MS) is allowed
17bts.set_num_trx(1)
18bts.set_trx_phy_channel(0, 0, 'CCCH+SDCCH4')
19bts.set_trx_phy_channel(0, 1, 'TCH/F')
20bts.set_trx_phy_channel(0, 2, 'TCH/F')
21bts.set_trx_phy_channel(0, 3, 'PDCH')
22bts.set_trx_phy_channel(0, 4, 'PDCH')
23bts.set_trx_phy_channel(0, 5, 'PDCH')
24bts.set_trx_phy_channel(0, 6, 'PDCH')
25bts.set_trx_phy_channel(0, 7, 'PDCH')
26
27hlr.start()
28stp.start()
29
30# Set MSC to route emergency call to ms_mt_emerg:
31msc.set_emergency_call_msisdn(ms_mt_emerg.msisdn())
32msc.start()
33
34mgw_msc.start()
35mgw_bsc.start()
36
37bsc.bts_add(bts)
38bsc.start()
39
40bts.start()
41wait(bsc.bts_is_connected, bts)
42
43hlr.subscriber_add(ms_mo)
44hlr.subscriber_add(ms_mt)
45hlr.subscriber_add(ms_mo_emerg)
46hlr.subscriber_add(ms_mt_emerg)
47
48ms_mo.connect(msc.mcc_mnc())
49ms_mt.connect(msc.mcc_mnc())
50ms_mo_emerg.connect(msc.mcc_mnc())
51ms_mt_emerg.connect(msc.mcc_mnc())
52
53ms_mo.log_info()
54ms_mt.log_info()
55ms_mo_emerg.log_info()
56ms_mt_emerg.log_info()
57
58print('waiting for modems to attach...')
59wait(ms_mo.is_registered, msc.mcc_mnc())
60wait(ms_mt.is_registered, msc.mcc_mnc())
61wait(ms_mo_emerg.is_registered, msc.mcc_mnc())
62wait(ms_mt_emerg.is_registered, msc.mcc_mnc())
63wait(msc.subscriber_attached, ms_mo, ms_mt, ms_mo_emerg, ms_mt_emerg)
64
65# Initiating first call between ms_mo and ms_mt. It should be dropped when later an emergency call comes in
66assert len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0
67mo_cid = ms_mo.call_dial(ms_mt)
68mt_cid = ms_mt.call_wait_incoming(ms_mo)
69print('dial success')
70assert not ms_mo.call_is_active(mo_cid) and not ms_mt.call_is_active(mt_cid)
71ms_mt.call_answer(mt_cid)
72assert len(ms_mo.call_id_list()) == 1 and len(ms_mt.call_id_list()) == 1
73
74sleep(5) # maintain the normal call active for 5 seconds
75
76assert len(ms_mo.call_id_list()) == 1 and len(ms_mt.call_id_list()) == 1
77assert len(ms_mo_emerg.call_id_list()) == 0 and len(ms_mt_emerg.call_id_list()) == 0
78# Calling emergency number should be redirected to ms_mt as configured further above:
79emerg_numbers = ms_mo_emerg.emergency_numbers()
80assert len(emerg_numbers) > 0
81print('dialing Emergency Number %s' % (emerg_numbers[0]))
82mo_cid_emerg = ms_mo_emerg.call_dial(emerg_numbers[0])
83mt_cid_emerg = ms_mt_emerg.call_wait_incoming(ms_mo_emerg)
84print('dial success')
85assert not ms_mo_emerg.call_is_active(mo_cid_emerg) and not ms_mt_emerg.call_is_active(mt_cid_emerg)
86ms_mt_emerg.call_answer(mt_cid_emerg)
87wait(ms_mo_emerg.call_is_active, mo_cid_emerg)
88wait(ms_mt_emerg.call_is_active, mt_cid_emerg)
89print('answer success, call established and ongoing')
90
91# Now the emergency call is ongoing, and the previous one should have been gone:
92assert len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0
93
94sleep(5) # maintain the emergency call active for 5 seconds
95
96assert ms_mo_emerg.call_is_active(mo_cid_emerg) and ms_mt.call_is_active(mt_cid_emerg)
97ms_mt_emerg.call_hangup(mt_cid_emerg)
98wait(lambda: len(ms_mo_emerg.call_id_list()) == 0 and len(ms_mt_emerg.call_id_list()) == 0)
99print('hangup success')