Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 1 | module FRNET_Tests { |
| 2 | |
| 3 | import from General_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | import from Osmocom_Gb_Types all; |
| 6 | |
| 7 | import from NS_Emulation all; |
| 8 | import from BSSGP_Emulation all; |
| 9 | |
| 10 | modulepar { |
Harald Welte | de6f3ee | 2020-11-11 19:01:46 +0100 | [diff] [blame] | 11 | integer mp_num_bvc := 10; |
Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 12 | NSConfigurations mp_nsconfig := { |
| 13 | { |
Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 14 | nsei := 123, |
| 15 | role_sgsn := true, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 16 | handle_sns := false, |
| 17 | nsvc := { |
| 18 | { |
| 19 | provider := { |
| 20 | fr := { |
Harald Welte | 9200930 | 2021-01-26 15:45:14 +0100 | [diff] [blame] | 21 | netdev := "hdlcnet1", |
Harald Welte | bfff717 | 2021-02-04 10:46:55 +0100 | [diff] [blame] | 22 | dlci := 1 |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 23 | } |
| 24 | }, |
Harald Welte | bfff717 | 2021-02-04 10:46:55 +0100 | [diff] [blame] | 25 | nsvci := 101 |
| 26 | }, { |
| 27 | provider := { |
| 28 | fr := { |
| 29 | netdev := "hdlcnet2", |
| 30 | dlci := 2 |
| 31 | } |
| 32 | }, |
| 33 | nsvci := 102 |
| 34 | }, { |
| 35 | provider := { |
| 36 | fr := { |
| 37 | netdev := "hdlcnet3", |
| 38 | dlci := 3 |
| 39 | } |
| 40 | }, |
| 41 | nsvci := 103 |
| 42 | }, { |
| 43 | provider := { |
| 44 | fr := { |
| 45 | netdev := "hdlcnet4", |
| 46 | dlci := 4 |
| 47 | } |
| 48 | }, |
| 49 | nsvci := 104 |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 50 | } |
| 51 | } |
Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 52 | } |
| 53 | }; |
| 54 | } |
| 55 | |
| 56 | type record GbInstance { |
| 57 | NS_CT vc_NS, |
| 58 | BSSGP_CT vc_BSSGP, |
| 59 | BssgpConfig cfg |
| 60 | }; |
| 61 | |
Harald Welte | de6f3ee | 2020-11-11 19:01:46 +0100 | [diff] [blame] | 62 | type record of GbInstance GbInstances; |
| 63 | type record of NSConfiguration NSConfigurations; |
| 64 | type record of BssgpCellId BssgpCellIds; |
Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 65 | |
| 66 | type component test_CT { |
| 67 | var GbInstances g_gb; |
| 68 | }; |
| 69 | |
Harald Welte | d6de984 | 2020-11-12 21:50:10 +0100 | [diff] [blame] | 70 | |
| 71 | private function CreateCallback(BssgpBvci bvci, BssgpCellId cell_id, OCT4 tlli, BssgpDecoded dec) runs on BSSGP_BVC_CT { |
| 72 | /* simply ignore any inbound traffic for now */ |
| 73 | } |
| 74 | |
Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 75 | private function f_init_gb(inout GbInstance gb, charstring id, integer offset) runs on test_CT { |
| 76 | var charstring id_idx := id & int2str(offset); |
| 77 | gb.vc_NS := NS_CT.create(id_idx & "-NSemu"); |
| 78 | gb.vc_BSSGP := BSSGP_CT.create(id_idx & "-BSSGPemu"); |
| 79 | connect(gb.vc_BSSGP:BSCP, gb.vc_NS:NS_SP); |
| 80 | gb.vc_NS.start(NSStart(mp_nsconfig[offset], id_idx)); |
| 81 | gb.vc_BSSGP.start(BssgpStart(gb.cfg, testcasename())); |
| 82 | } |
| 83 | |
Harald Welte | de6f3ee | 2020-11-11 19:01:46 +0100 | [diff] [blame] | 84 | function f_gen_bvc(integer base, integer idx) return BssgpBvcConfig { |
| 85 | var BssgpBvcConfig bvc := { |
| 86 | bvci := base + 100 + idx, |
| 87 | cell_id := { |
| 88 | ra_id := { |
| 89 | lai := { |
| 90 | mcc_mnc := '262F42'H, |
| 91 | lac := base + 300 + idx |
Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 92 | }, |
Harald Welte | de6f3ee | 2020-11-11 19:01:46 +0100 | [diff] [blame] | 93 | rac := 1 |
| 94 | }, |
| 95 | cell_id := base + 600 + idx |
| 96 | }, |
Harald Welte | 4d112c9 | 2020-11-12 19:48:31 +0100 | [diff] [blame] | 97 | depth := BSSGP_DECODE_DEPTH_LLC, |
Harald Welte | d6de984 | 2020-11-12 21:50:10 +0100 | [diff] [blame] | 98 | create_cb := refers(CreateCallback) |
Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 99 | }; |
Harald Welte | de6f3ee | 2020-11-11 19:01:46 +0100 | [diff] [blame] | 100 | return bvc; |
| 101 | } |
| 102 | |
| 103 | testcase TC_foo() runs on test_CT { |
| 104 | |
| 105 | for (var integer i := 0; i < lengthof(mp_nsconfig); i := i+1) { |
| 106 | g_gb[i].cfg := { |
| 107 | nsei := mp_nsconfig[i].nsei, |
| 108 | sgsn_role := true, |
| 109 | bvc := { } |
| 110 | }; |
| 111 | /* create 'mp_num_bvc' number of BVCs */ |
| 112 | for (var integer j := 0; j < mp_num_bvc; j := j+1) { |
| 113 | g_gb[i].cfg.bvc := g_gb[i].cfg.bvc & { f_gen_bvc(i * 1000, j) }; |
| 114 | } |
| 115 | f_init_gb(g_gb[i], "gb", i); |
| 116 | } |
| 117 | |
Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 118 | while (true) { |
| 119 | f_sleep(100.0); |
| 120 | } |
| 121 | } |
| 122 | |
Harald Welte | d077075 | 2020-11-11 19:03:41 +0100 | [diff] [blame] | 123 | control { |
| 124 | execute( TC_foo() ); |
| 125 | } |
| 126 | |
Harald Welte | 023b61b | 2020-09-12 20:41:05 +0200 | [diff] [blame] | 127 | |
| 128 | } |