Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 1 | /* AllocTest.cpp |
| 2 | * |
| 3 | * Copyright (C) 2013 by Holger Hans Peter Freyther |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
| 20 | #include "gprs_rlcmac.h" |
| 21 | #include "gprs_debug.h" |
| 22 | #include "tbf.h" |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 23 | #include "bts.h" |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 24 | |
| 25 | #include <string.h> |
| 26 | #include <stdio.h> |
| 27 | |
| 28 | extern "C" { |
| 29 | #include <osmocom/core/application.h> |
| 30 | #include <osmocom/core/msgb.h> |
| 31 | #include <osmocom/core/talloc.h> |
| 32 | #include <osmocom/core/utils.h> |
| 33 | } |
| 34 | |
| 35 | /* globals used by the code */ |
| 36 | void *tall_pcu_ctx; |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 37 | int16_t spoof_mnc = 0, spoof_mcc = 0; |
| 38 | |
| 39 | static void test_alloc_a(gprs_rlcmac_tbf_direction dir, const int count) |
| 40 | { |
| 41 | int tfi; |
| 42 | uint8_t used_trx; |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 43 | BTS the_bts; |
| 44 | struct gprs_rlcmac_bts *bts; |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 45 | struct gprs_rlcmac_tbf *tbfs[33] = { 0, }; |
| 46 | |
| 47 | printf("Testing alloc_a direction(%d)\n", dir); |
| 48 | |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 49 | bts = the_bts.bts_data(); |
| 50 | bts->alloc_algorithm = alloc_algorithm_a; |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 51 | |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 52 | struct gprs_rlcmac_trx *trx = &bts->trx[0]; |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 53 | trx->pdch[2].enable(); |
| 54 | trx->pdch[3].enable(); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * Currently alloc_a will only allocate from the first |
| 58 | * PDCH and all possible usf's. We run out of usf's before |
| 59 | * we are out of tfi's. Observe this and make sure that at |
| 60 | * least this part is working okay. |
| 61 | */ |
| 62 | for (int i = 0; i < count; ++i) { |
| 63 | struct gprs_rlcmac_tbf *tbf; |
| 64 | |
Holger Hans Peter Freyther | 70ddde6 | 2013-10-26 19:17:58 +0200 | [diff] [blame] | 65 | tfi = the_bts.tfi_find_free(dir, &used_trx, 0); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 66 | OSMO_ASSERT(tfi >= 0); |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 67 | tbfs[i] = tbf_alloc(bts, NULL, dir, tfi, used_trx, 0, 0); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | /* Now check that there are still some TFIs */ |
Holger Hans Peter Freyther | 70ddde6 | 2013-10-26 19:17:58 +0200 | [diff] [blame] | 71 | tfi = the_bts.tfi_find_free(dir, &used_trx, 0); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 72 | switch (dir) { |
| 73 | case GPRS_RLCMAC_UL_TBF: |
| 74 | OSMO_ASSERT(tfi >= 0); |
| 75 | break; |
| 76 | case GPRS_RLCMAC_DL_TBF: |
| 77 | OSMO_ASSERT(tfi < 0); |
| 78 | break; |
| 79 | } |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 80 | OSMO_ASSERT(!tbf_alloc(bts, NULL, dir, tfi, used_trx, 0, 0)); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 81 | |
| 82 | for (int i = 0; i < ARRAY_SIZE(tbfs); ++i) |
| 83 | if (tbfs[i]) |
| 84 | tbf_free(tbfs[i]); |
| 85 | |
Holger Hans Peter Freyther | 70ddde6 | 2013-10-26 19:17:58 +0200 | [diff] [blame] | 86 | tfi = the_bts.tfi_find_free(dir, &used_trx, 0); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 87 | OSMO_ASSERT(tfi >= 0); |
| 88 | |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 89 | tbfs[tfi] = tbf_alloc(bts, NULL, dir, tfi, used_trx, 0, 0); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 90 | OSMO_ASSERT(tbfs[tfi]); |
| 91 | tbf_free(tbfs[tfi]); |
| 92 | } |
| 93 | |
| 94 | static void test_alloc_a() |
| 95 | { |
| 96 | test_alloc_a(GPRS_RLCMAC_DL_TBF, 32); |
| 97 | test_alloc_a(GPRS_RLCMAC_UL_TBF, 7); |
| 98 | } |
| 99 | |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 100 | static void dump_assignment(struct gprs_rlcmac_tbf *tbf, const char *dir) |
| 101 | { |
| 102 | for (int i = 0; i < ARRAY_SIZE(tbf->pdch); ++i) |
| 103 | if (tbf->pdch[i]) |
| 104 | printf("PDCH[%d] is used for %s\n", i, dir); |
| 105 | printf("PDCH[%d] is control_ts for %s\n", tbf->control_ts, dir); |
| 106 | printf("PDCH[%d] is first common for %s\n", tbf->first_common_ts, dir); |
| 107 | } |
| 108 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 109 | static void test_alloc_b(int ms_class) |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 110 | { |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 111 | printf("Going to test multislot assignment MS_CLASS=%d\n", ms_class); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 112 | /* |
| 113 | * PDCH is on TS 6,7,8 and we start with a UL allocation and |
| 114 | * then follow two DL allocations (once single, once normal). |
| 115 | * |
| 116 | * Uplink assigned and still available.. |
| 117 | */ |
| 118 | { |
| 119 | BTS the_bts; |
| 120 | struct gprs_rlcmac_bts *bts; |
| 121 | struct gprs_rlcmac_trx *trx; |
| 122 | int tfi; |
| 123 | uint8_t ts_no, trx_no; |
| 124 | |
| 125 | gprs_rlcmac_tbf *ul_tbf, *dl_tbf; |
| 126 | |
| 127 | printf("Testing UL then DL assignment.\n"); |
| 128 | |
| 129 | bts = the_bts.bts_data(); |
| 130 | bts->alloc_algorithm = alloc_algorithm_b; |
| 131 | |
| 132 | trx = &bts->trx[0]; |
| 133 | trx->pdch[5].enable(); |
| 134 | trx->pdch[6].enable(); |
| 135 | trx->pdch[7].enable(); |
| 136 | |
| 137 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 138 | OSMO_ASSERT(tfi >= 0); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 139 | ul_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx_no, ms_class, 1); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 140 | OSMO_ASSERT(ul_tbf); |
| 141 | dump_assignment(ul_tbf, "UL"); |
| 142 | |
| 143 | /* assume final ack has not been sent */ |
| 144 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 145 | OSMO_ASSERT(tfi >= 0); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 146 | dl_tbf = tbf_alloc(bts, ul_tbf, GPRS_RLCMAC_DL_TBF, tfi, trx_no, ms_class, 0); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 147 | OSMO_ASSERT(dl_tbf); |
| 148 | dump_assignment(dl_tbf, "DL"); |
| 149 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 150 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 151 | |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 152 | tbf_free(dl_tbf); |
| 153 | tbf_free(ul_tbf); |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Test with the other order.. first DL and then UL |
| 158 | */ |
| 159 | { |
| 160 | BTS the_bts; |
| 161 | struct gprs_rlcmac_bts *bts; |
| 162 | struct gprs_rlcmac_trx *trx; |
| 163 | int tfi; |
| 164 | uint8_t ts_no, trx_no; |
| 165 | |
| 166 | gprs_rlcmac_tbf *ul_tbf, *dl_tbf; |
| 167 | |
| 168 | printf("Testing DL then UL assignment followed by update\n"); |
| 169 | |
| 170 | bts = the_bts.bts_data(); |
| 171 | bts->alloc_algorithm = alloc_algorithm_b; |
| 172 | |
| 173 | trx = &bts->trx[0]; |
| 174 | trx->pdch[5].enable(); |
| 175 | trx->pdch[6].enable(); |
| 176 | trx->pdch[7].enable(); |
| 177 | |
| 178 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 179 | OSMO_ASSERT(tfi >= 0); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 180 | dl_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_DL_TBF, tfi, trx_no, ms_class, 1); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 181 | dl_tbf->m_tlli = 0x23; |
| 182 | dl_tbf->m_tlli_valid = true; |
| 183 | OSMO_ASSERT(dl_tbf); |
| 184 | dump_assignment(dl_tbf, "DL"); |
| 185 | |
| 186 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 187 | OSMO_ASSERT(tfi >= 0); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 188 | ul_tbf = tbf_alloc(bts, dl_tbf, GPRS_RLCMAC_UL_TBF, tfi, trx_no, ms_class, 0); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 189 | ul_tbf->m_tlli = 0x23; |
| 190 | ul_tbf->m_tlli_valid = true; |
| 191 | ul_tbf->dir.ul.contention_resolution_done = 1; |
| 192 | OSMO_ASSERT(ul_tbf); |
| 193 | dump_assignment(ul_tbf, "UL"); |
| 194 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 195 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 196 | |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 197 | /* now update the dl_tbf */ |
| 198 | dl_tbf->update(); |
| 199 | dump_assignment(dl_tbf, "DL"); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 200 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 201 | |
| 202 | tbf_free(dl_tbf); |
| 203 | tbf_free(ul_tbf); |
| 204 | } |
| 205 | |
| 206 | /* Andreas osmocom-pcu example */ |
| 207 | { |
| 208 | BTS the_bts; |
| 209 | struct gprs_rlcmac_bts *bts; |
| 210 | struct gprs_rlcmac_trx *trx; |
| 211 | int tfi; |
| 212 | uint8_t ts_no, trx_no; |
| 213 | |
| 214 | gprs_rlcmac_tbf *ul_tbf, *dl_tbf; |
| 215 | |
| 216 | printf("Testing jolly example\n"); |
| 217 | |
| 218 | bts = the_bts.bts_data(); |
| 219 | bts->alloc_algorithm = alloc_algorithm_b; |
| 220 | |
| 221 | trx = &bts->trx[0]; |
| 222 | trx->pdch[1].enable(); |
| 223 | trx->pdch[2].enable(); |
| 224 | trx->pdch[3].enable(); |
| 225 | trx->pdch[4].enable(); |
| 226 | |
| 227 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 228 | OSMO_ASSERT(tfi >= 0); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 229 | ul_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx_no, ms_class, 0); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 230 | OSMO_ASSERT(ul_tbf); |
| 231 | dump_assignment(ul_tbf, "UL"); |
| 232 | |
| 233 | /* assume final ack has not been sent */ |
| 234 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 235 | OSMO_ASSERT(tfi >= 0); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 236 | dl_tbf = tbf_alloc(bts, ul_tbf, GPRS_RLCMAC_DL_TBF, tfi, trx_no, ms_class, 0); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 237 | OSMO_ASSERT(dl_tbf); |
| 238 | dump_assignment(dl_tbf, "DL"); |
| 239 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 240 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 241 | |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 242 | tbf_free(dl_tbf); |
| 243 | tbf_free(ul_tbf); |
| 244 | } |
| 245 | } |
| 246 | |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame^] | 247 | #define ENABLE_PDCH(ts_no, enable_flag, trx) \ |
| 248 | if (enable_flag) \ |
| 249 | trx->pdch[ts_no].enable(); |
| 250 | |
| 251 | static void test_alloc_b(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7, int ms_class) |
| 252 | { |
| 253 | /* we can test the allocation failures differently */ |
| 254 | if (!ts0 && !ts1 && !ts2 && !ts3 && !ts4 && !ts5 && !ts6 && !ts7) |
| 255 | return; |
| 256 | |
| 257 | printf("Mass test: TS0(%c%c%c%c%c%c%c%c)TS7 MS_Class=%d\n", |
| 258 | ts0 ? 'O' : 'x', |
| 259 | ts1 ? 'O' : 'x', |
| 260 | ts2 ? 'O' : 'x', |
| 261 | ts3 ? 'O' : 'x', |
| 262 | ts4 ? 'O' : 'x', |
| 263 | ts5 ? 'O' : 'x', |
| 264 | ts6 ? 'O' : 'x', |
| 265 | ts7 ? 'O' : 'x', ms_class); |
| 266 | fflush(stdout); |
| 267 | |
| 268 | { |
| 269 | BTS the_bts; |
| 270 | struct gprs_rlcmac_bts *bts; |
| 271 | struct gprs_rlcmac_trx *trx; |
| 272 | int tfi; |
| 273 | uint8_t ts_no, trx_no; |
| 274 | |
| 275 | gprs_rlcmac_tbf *ul_tbf, *dl_tbf; |
| 276 | |
| 277 | bts = the_bts.bts_data(); |
| 278 | bts->alloc_algorithm = alloc_algorithm_b; |
| 279 | |
| 280 | trx = &bts->trx[0]; |
| 281 | ENABLE_PDCH(0, ts0, trx); |
| 282 | ENABLE_PDCH(1, ts1, trx); |
| 283 | ENABLE_PDCH(2, ts2, trx); |
| 284 | ENABLE_PDCH(3, ts3, trx); |
| 285 | ENABLE_PDCH(4, ts4, trx); |
| 286 | ENABLE_PDCH(5, ts5, trx); |
| 287 | ENABLE_PDCH(6, ts6, trx); |
| 288 | ENABLE_PDCH(7, ts7, trx); |
| 289 | |
| 290 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 291 | |
| 292 | OSMO_ASSERT(tfi >= 0); |
| 293 | ul_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx_no, ms_class, 1); |
| 294 | OSMO_ASSERT(ul_tbf); |
| 295 | |
| 296 | /* assume final ack has not been sent */ |
| 297 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 298 | OSMO_ASSERT(tfi >= 0); |
| 299 | dl_tbf = tbf_alloc(bts, ul_tbf, GPRS_RLCMAC_DL_TBF, tfi, trx_no, ms_class, 0); |
| 300 | OSMO_ASSERT(dl_tbf); |
| 301 | |
| 302 | /* verify that both are on the same ts */ |
| 303 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 304 | |
| 305 | tbf_free(dl_tbf); |
| 306 | tbf_free(ul_tbf); |
| 307 | } |
| 308 | |
| 309 | /** |
| 310 | * Test with the other order.. first DL and then UL |
| 311 | */ |
| 312 | { |
| 313 | BTS the_bts; |
| 314 | struct gprs_rlcmac_bts *bts; |
| 315 | struct gprs_rlcmac_trx *trx; |
| 316 | int tfi; |
| 317 | uint8_t ts_no, trx_no; |
| 318 | |
| 319 | gprs_rlcmac_tbf *ul_tbf, *dl_tbf; |
| 320 | |
| 321 | bts = the_bts.bts_data(); |
| 322 | bts->alloc_algorithm = alloc_algorithm_b; |
| 323 | |
| 324 | trx = &bts->trx[0]; |
| 325 | ENABLE_PDCH(0, ts0, trx); |
| 326 | ENABLE_PDCH(1, ts1, trx); |
| 327 | ENABLE_PDCH(2, ts2, trx); |
| 328 | ENABLE_PDCH(3, ts3, trx); |
| 329 | ENABLE_PDCH(4, ts4, trx); |
| 330 | ENABLE_PDCH(5, ts5, trx); |
| 331 | ENABLE_PDCH(6, ts6, trx); |
| 332 | ENABLE_PDCH(7, ts7, trx); |
| 333 | |
| 334 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 335 | OSMO_ASSERT(tfi >= 0); |
| 336 | dl_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_DL_TBF, tfi, trx_no, ms_class, 1); |
| 337 | OSMO_ASSERT(dl_tbf); |
| 338 | dl_tbf->m_tlli = 0x23; |
| 339 | dl_tbf->m_tlli_valid = true; |
| 340 | |
| 341 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 342 | OSMO_ASSERT(tfi >= 0); |
| 343 | ul_tbf = tbf_alloc(bts, dl_tbf, GPRS_RLCMAC_UL_TBF, tfi, trx_no, ms_class, 0); |
| 344 | OSMO_ASSERT(ul_tbf); |
| 345 | ul_tbf->m_tlli = 0x23; |
| 346 | ul_tbf->m_tlli_valid = true; |
| 347 | ul_tbf->dir.ul.contention_resolution_done = 1; |
| 348 | |
| 349 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 350 | |
| 351 | /* now update the dl_tbf */ |
| 352 | dl_tbf->update(); |
| 353 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 354 | |
| 355 | tbf_free(dl_tbf); |
| 356 | tbf_free(ul_tbf); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | static void test_all_alloc_b() |
| 361 | { |
| 362 | /* it is a bit crazy... */ |
| 363 | for (uint8_t ts0 = 0; ts0 < 2; ++ts0) |
| 364 | for (uint8_t ts1 = 0; ts1 < 2; ++ts1) |
| 365 | for (uint8_t ts2 = 0; ts2 < 2; ++ts2) |
| 366 | for (uint8_t ts3 = 0; ts3 < 2; ++ts3) |
| 367 | for (uint8_t ts4 = 0; ts4 < 2; ++ts4) |
| 368 | for (uint8_t ts5 = 0; ts5 < 2; ++ts5) |
| 369 | for (uint8_t ts6 = 0; ts6 < 2; ++ts6) |
| 370 | for (uint8_t ts7 = 0; ts7 < 2; ++ts7) |
| 371 | for (int ms_class = 0; ms_class < 30; ++ms_class) |
| 372 | test_alloc_b(ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ms_class); |
| 373 | } |
| 374 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 375 | static void test_alloc_b() |
| 376 | { |
| 377 | for (int i = 0; i < 30; ++i) |
| 378 | test_alloc_b(i); |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame^] | 379 | |
| 380 | test_all_alloc_b(); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 381 | } |
| 382 | |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 383 | int main(int argc, char **argv) |
| 384 | { |
| 385 | tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile AllocTest context"); |
| 386 | if (!tall_pcu_ctx) |
| 387 | abort(); |
| 388 | |
| 389 | msgb_set_talloc_ctx(tall_pcu_ctx); |
| 390 | osmo_init_logging(&gprs_log_info); |
| 391 | log_set_use_color(osmo_stderr_target, 0); |
| 392 | log_set_print_filename(osmo_stderr_target, 0); |
| 393 | |
| 394 | test_alloc_a(); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 395 | test_alloc_b(); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 396 | return EXIT_SUCCESS; |
| 397 | } |
| 398 | |
| 399 | /* |
| 400 | * stubs that should not be reached |
| 401 | */ |
| 402 | extern "C" { |
| 403 | void l1if_pdch_req() { abort(); } |
| 404 | void l1if_connect_pdch() { abort(); } |
| 405 | void l1if_close_pdch() { abort(); } |
| 406 | void l1if_open_pdch() { abort(); } |
| 407 | } |