blob: 28a497541d289282d419c6528a390d14075efe93 [file] [log] [blame]
Pau Espin Pedrole07e1b62018-05-07 16:25:41 +02001#!/usr/bin/env python3
2from osmo_gsm_tester.testenv import *
3
4def call_test_setup_run(bts_setup_cb=None, gprs_enable=True):
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 if gprs_enable:
19 ggsn = suite.ggsn()
20 sgsn = suite.sgsn(hlr, ggsn)
21 sgsn.bts_add(bts)
22 ggsn.start()
23 sgsn.start()
24
25 hlr.start()
26 stp.start()
27 msc.start()
28 mgw_msc.start()
29 mgw_bsc.start()
30
31 bsc.bts_add(bts)
32 bsc.start()
33
34 bts.start()
35 wait(bsc.bts_is_connected, bts)
36
37 hlr.subscriber_add(ms_mo)
38 hlr.subscriber_add(ms_mt)
39
40 ms_mo.connect(msc.mcc_mnc())
41 ms_mt.connect(msc.mcc_mnc())
42
43 ms_mo.log_info()
44 ms_mt.log_info()
45
46 print('waiting for modems to attach...')
47 wait(ms_mo.is_connected, msc.mcc_mnc())
48 wait(ms_mt.is_connected, msc.mcc_mnc())
49 wait(msc.subscriber_attached, ms_mo, ms_mt)
50
51 assert len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0
52 mo_cid = ms_mo.call_dial(ms_mt)
53 mt_cid = ms_mt.call_wait_incoming(ms_mo)
54 print('dial success')
55
56 assert not ms_mo.call_is_active(mo_cid) and not ms_mt.call_is_active(mt_cid)
57 ms_mt.call_answer(mt_cid)
58 wait(ms_mo.call_is_active, mo_cid)
59 wait(ms_mt.call_is_active, mt_cid)
60 print('answer success, call established and ongoing')
61
62 sleep(5) # maintain the call active for 5 seconds
63
64 assert ms_mo.call_is_active(mo_cid) and ms_mt.call_is_active(mt_cid)
65 ms_mt.call_hangup(mt_cid)
66 wait(lambda: len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0)
67 print('hangup success')