Andre Puschmann | 898a5aa | 2020-05-27 21:46:26 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | from osmo_gsm_tester.testenv import * |
Andre Puschmann | 4462067 | 2021-04-15 10:50:36 +0200 | [diff] [blame] | 3 | import os |
| 4 | |
| 5 | # Overlay suite-specific templates folder if it exists |
| 6 | if 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 Puschmann | 898a5aa | 2020-05-27 21:46:26 +0200 | [diff] [blame] | 8 | |
| 9 | epc = tenv.epc() |
| 10 | enb = tenv.enb() |
| 11 | ue = tenv.modem() |
| 12 | |
| 13 | epc.subscriber_add(ue) |
| 14 | epc.start() |
| 15 | enb.ue_add(ue) |
| 16 | enb.start(epc) |
| 17 | |
| 18 | print('waiting for ENB to connect to EPC...') |
| 19 | wait(epc.enb_is_connected, enb) |
| 20 | print('ENB is connected to EPC') |
| 21 | |
| 22 | ue.connect(enb) |
| 23 | print('waiting for UE to attach...') |
Pau Espin Pedrol | 57e37f9 | 2020-06-11 17:12:26 +0200 | [diff] [blame] | 24 | wait(ue.is_registered) |
Andre Puschmann | 898a5aa | 2020-05-27 21:46:26 +0200 | [diff] [blame] | 25 | print('UE is RRC connected') |
| 26 | |
| 27 | print('waiting until RRC connection gets released...') |
| 28 | wait(lambda: not ue.is_rrc_connected()) |
| 29 | print('UE is RRC idle') |
| 30 | |
| 31 | # Wait a bit |
| 32 | sleep(5) |
| 33 | |
Andre Puschmann | d1732d7 | 2021-01-22 16:14:15 +0100 | [diff] [blame] | 34 | # Generate MT traffic, send single ping (10s timeout) |
| 35 | proc = epc.prepare_process('ping', ('ping', '-w', '10', '-c', '1', ue.get_assigned_addr())) |
Andre Puschmann | b0ebcbc | 2020-06-12 12:08:02 +0200 | [diff] [blame] | 36 | proc.launch_sync() |
Andre Puschmann | 898a5aa | 2020-05-27 21:46:26 +0200 | [diff] [blame] | 37 | output = proc.get_stdout() |
| 38 | |
| 39 | # Check paging received |
| 40 | num_paging_received = ue.get_counter('paging_received') |
| 41 | if 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 Puschmann | 29263b7 | 2021-01-05 14:18:52 +0100 | [diff] [blame] | 45 | num_prachs = 2 |
Andre Puschmann | 898a5aa | 2020-05-27 21:46:26 +0200 | [diff] [blame] | 46 | num_prach_sent = ue.get_counter('prach_sent') |
Andre Puschmann | 29263b7 | 2021-01-05 14:18:52 +0100 | [diff] [blame] | 47 | if 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 Puschmann | 898a5aa | 2020-05-27 21:46:26 +0200 | [diff] [blame] | 49 | |
Andre Puschmann | 29263b7 | 2021-01-05 14:18:52 +0100 | [diff] [blame] | 50 | # Check PRACH receptions |
| 51 | num_prach_received = enb.get_counter('prach_received') |
| 52 | if 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 | |
| 55 | output += "\nnum_prach_sent={}\nnum_prach_received={}\n".format(num_prach_sent, num_prach_received) |
Andre Puschmann | 898a5aa | 2020-05-27 21:46:26 +0200 | [diff] [blame] | 56 | print(output) |
| 57 | test.set_report_stdout(output) |