blob: 21650e751cf6210ba9b3c1097c2a53c54595bcbf [file] [log] [blame]
Andre Puschmann898a5aa2020-05-27 21:46:26 +02001#!/usr/bin/env python3
2from osmo_gsm_tester.testenv import *
Andre Puschmann44620672021-04-15 10:50:36 +02003import os
4
5# Overlay suite-specific templates folder if it exists
6if os.path.isdir(os.path.join(os.path.dirname(__file__), 'templates')):
7 tenv.set_overlay_template_dir(os.path.join(os.path.dirname(__file__), 'templates'))
Andre Puschmann898a5aa2020-05-27 21:46:26 +02008
9epc = tenv.epc()
10enb = tenv.enb()
11ue = tenv.modem()
12
13epc.subscriber_add(ue)
14epc.start()
15enb.ue_add(ue)
16enb.start(epc)
17
18print('waiting for ENB to connect to EPC...')
19wait(epc.enb_is_connected, enb)
20print('ENB is connected to EPC')
21
22ue.connect(enb)
23print('waiting for UE to attach...')
Pau Espin Pedrol57e37f92020-06-11 17:12:26 +020024wait(ue.is_registered)
Andre Puschmann898a5aa2020-05-27 21:46:26 +020025print('UE is RRC connected')
26
27print('waiting until RRC connection gets released...')
28wait(lambda: not ue.is_rrc_connected())
29print('UE is RRC idle')
30
31# Wait a bit
32sleep(5)
33
Andre Puschmannd1732d72021-01-22 16:14:15 +010034# Generate MT traffic, send single ping (10s timeout)
35proc = epc.prepare_process('ping', ('ping', '-w', '10', '-c', '1', ue.get_assigned_addr()))
Andre Puschmannb0ebcbc2020-06-12 12:08:02 +020036proc.launch_sync()
Andre Puschmann898a5aa2020-05-27 21:46:26 +020037output = proc.get_stdout()
38
39# Check paging received
40num_paging_received = ue.get_counter('paging_received')
41if num_paging_received != 1:
42 raise Exception("Expected to receive exactly 1 paging message, but in fact received {}".format(num_paging_received))
43
44# Check PRACH transmissions
Andre Puschmann29263b72021-01-05 14:18:52 +010045num_prachs = 2
Andre Puschmann898a5aa2020-05-27 21:46:26 +020046num_prach_sent = ue.get_counter('prach_sent')
Andre Puschmann29263b72021-01-05 14:18:52 +010047if num_prach_sent != num_prachs:
48 raise Exception("Expected to have sent exactly {} PRACHs, but in fact sent {}".format(num_prachs, num_prach_sent))
Andre Puschmann898a5aa2020-05-27 21:46:26 +020049
Andre Puschmann29263b72021-01-05 14:18:52 +010050# Check PRACH receptions
51num_prach_received = enb.get_counter('prach_received')
52if num_prach_sent != num_prachs:
53 raise Exception("Expected to have received exactly {} PRACHs, but in fact received {}".format(num_prachs, num_prach_received))
54
55output += "\nnum_prach_sent={}\nnum_prach_received={}\n".format(num_prach_sent, num_prach_received)
Andre Puschmann898a5aa2020-05-27 21:46:26 +020056print(output)
57test.set_report_stdout(output)