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 | |
| 34 | # Generate MO traffic |
| 35 | proc = ue.run_netns_wait('ping', ('ping', '-c', '1', epc.tun_addr())) |
| 36 | output = proc.get_stdout() |
| 37 | |
| 38 | # Check PRACH transmissions |
Andre Puschmann | 29263b7 | 2021-01-05 14:18:52 +0100 | [diff] [blame] | 39 | num_prachs = 2 |
Andre Puschmann | 898a5aa | 2020-05-27 21:46:26 +0200 | [diff] [blame] | 40 | num_prach_sent = ue.get_counter('prach_sent') |
Andre Puschmann | 29263b7 | 2021-01-05 14:18:52 +0100 | [diff] [blame] | 41 | if num_prach_sent != num_prachs: |
| 42 | 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] | 43 | |
Andre Puschmann | 29263b7 | 2021-01-05 14:18:52 +0100 | [diff] [blame] | 44 | # Check PRACH receptions |
| 45 | num_prach_received = enb.get_counter('prach_received') |
| 46 | if num_prach_sent != num_prachs: |
| 47 | raise Exception("Expected to have received exactly {} PRACHs, but in fact received {}".format(num_prachs, num_prach_received)) |
| 48 | |
| 49 | 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] | 50 | print(output) |
| 51 | test.set_report_stdout(output) |