Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 8 | * (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 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <stdio.h> |
Harald Welte | 6bfda78 | 2009-06-26 20:30:46 +0200 | [diff] [blame] | 21 | #include <stdlib.h> |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 22 | |
| 23 | #include <assert.h> |
| 24 | |
Holger Hans Peter Freyther | 08e324f | 2012-01-06 14:06:56 +0100 | [diff] [blame] | 25 | #include <osmocom/core/application.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 26 | #include <osmocom/core/select.h> |
Holger Hans Peter Freyther | 08e324f | 2012-01-06 14:06:56 +0100 | [diff] [blame] | 27 | |
Neels Hofmeyr | 2d521a0 | 2016-05-14 00:57:04 +0200 | [diff] [blame] | 28 | #include <openbsc/common_bsc.h> |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 29 | #include <openbsc/abis_rsl.h> |
Holger Hans Peter Freyther | 08e324f | 2012-01-06 14:06:56 +0100 | [diff] [blame] | 30 | #include <openbsc/debug.h> |
| 31 | #include <openbsc/gsm_subscriber.h> |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 32 | #include <openbsc/vlr.h> |
Neels Hofmeyr | 8d878e8 | 2016-09-25 15:47:36 +0200 | [diff] [blame] | 33 | |
Alexander Chemeris | 6e437b7 | 2017-07-11 01:42:41 +0630 | [diff] [blame] | 34 | void test_bts_debug_print(void) |
| 35 | { |
| 36 | struct gsm_network *network; |
| 37 | struct gsm_bts *bts; |
| 38 | struct gsm_bts_trx *trx; |
| 39 | |
| 40 | printf("Testing the lchan printing:"); |
| 41 | |
| 42 | /* Create a dummy network */ |
| 43 | network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL); |
| 44 | if (!network) |
| 45 | exit(1); |
| 46 | /* Add a BTS with some reasonanbly non-zero id */ |
| 47 | bts = gsm_bts_alloc(network, 45); |
| 48 | /* Add a second TRX to test on multiple TRXs */ |
| 49 | gsm_bts_trx_alloc(bts); |
| 50 | |
| 51 | llist_for_each_entry(trx, &bts->trx_list, list) { |
| 52 | char *name = gsm_lchan_name(&trx->ts[3].lchan[4]); |
| 53 | |
| 54 | if (name) |
| 55 | printf(" %s", name); |
| 56 | else |
| 57 | printf("NULL name"); |
| 58 | } |
| 59 | printf("\n"); |
| 60 | } |
| 61 | |
| 62 | |
Neels Hofmeyr | e289a2a | 2016-09-25 15:58:01 +0200 | [diff] [blame] | 63 | void test_dyn_ts_subslots(void) |
| 64 | { |
| 65 | struct gsm_bts_trx_ts ts; |
| 66 | |
| 67 | printf("Testing subslot numbers for pchan types\n"); |
| 68 | |
| 69 | ts.pchan = GSM_PCHAN_TCH_F; |
| 70 | OSMO_ASSERT(ts_subslots(&ts) == 1); |
| 71 | |
| 72 | ts.pchan = GSM_PCHAN_TCH_H; |
| 73 | OSMO_ASSERT(ts_subslots(&ts) == 2); |
| 74 | |
| 75 | ts.pchan = GSM_PCHAN_PDCH; |
| 76 | OSMO_ASSERT(ts_subslots(&ts) == 0); |
| 77 | |
| 78 | ts.pchan = GSM_PCHAN_TCH_F_PDCH; |
| 79 | ts.flags = 0; /* TCH_F mode */ |
| 80 | OSMO_ASSERT(ts_subslots(&ts) == 1); |
| 81 | ts.flags = TS_F_PDCH_ACTIVE; |
Neels Hofmeyr | c3f72f6 | 2016-09-25 15:33:02 +0200 | [diff] [blame] | 82 | OSMO_ASSERT(ts_subslots(&ts) == 0); |
Neels Hofmeyr | e289a2a | 2016-09-25 15:58:01 +0200 | [diff] [blame] | 83 | |
| 84 | ts.pchan = GSM_PCHAN_TCH_F_TCH_H_PDCH; |
| 85 | ts.dyn.pchan_is = GSM_PCHAN_TCH_F; |
| 86 | OSMO_ASSERT(ts_subslots(&ts) == 1); |
| 87 | ts.dyn.pchan_is = GSM_PCHAN_TCH_H; |
| 88 | OSMO_ASSERT(ts_subslots(&ts) == 2); |
| 89 | ts.dyn.pchan_is = GSM_PCHAN_PDCH; |
| 90 | OSMO_ASSERT(ts_subslots(&ts) == 0); |
| 91 | } |
| 92 | |
Neels Hofmeyr | 8d878e8 | 2016-09-25 15:47:36 +0200 | [diff] [blame] | 93 | int main(int argc, char **argv) |
| 94 | { |
| 95 | osmo_init_logging(&log_info); |
| 96 | |
Neels Hofmeyr | e289a2a | 2016-09-25 15:58:01 +0200 | [diff] [blame] | 97 | test_dyn_ts_subslots(); |
Alexander Chemeris | 6e437b7 | 2017-07-11 01:42:41 +0630 | [diff] [blame] | 98 | test_bts_debug_print(); |
Holger Hans Peter Freyther | 08e324f | 2012-01-06 14:06:56 +0100 | [diff] [blame] | 99 | |
| 100 | return EXIT_SUCCESS; |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 101 | } |
| 102 | |
Harald Welte | f338a03 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 103 | void _abis_nm_sendmsg() {} |
Holger Hans Peter Freyther | 7673ce4 | 2009-08-10 06:40:05 +0200 | [diff] [blame] | 104 | void sms_alloc() {} |
Holger Hans Peter Freyther | 900394a | 2013-12-27 20:10:24 +0100 | [diff] [blame] | 105 | void sms_free() {} |
Holger Hans Peter Freyther | 7889107 | 2010-09-06 09:36:02 +0800 | [diff] [blame] | 106 | void gsm_net_update_ctype(struct gsm_network *network) {} |
Holger Hans Peter Freyther | d9cdd05 | 2010-12-21 13:43:52 +0100 | [diff] [blame] | 107 | void gsm48_secure_channel() {} |
Holger Hans Peter Freyther | ffccb77 | 2010-12-28 17:47:43 +0100 | [diff] [blame] | 108 | void paging_request_stop() {} |
Holger Hans Peter Freyther | 763b42a | 2010-12-29 11:07:22 +0100 | [diff] [blame] | 109 | void vty_out() {} |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 110 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 111 | void ipa_client_conn_clear_queue() {} |
| 112 | void ipa_client_conn_close() {} |
| 113 | void ipa_client_conn_create() {} |
| 114 | void ipa_client_conn_destroy() {} |
| 115 | void ipa_client_conn_open() {} |
| 116 | void ipa_client_conn_send() {} |
| 117 | void ipa_msg_push_header() {} |
| 118 | void ipaccess_bts_handle_ccm() {} |
Holger Hans Peter Freyther | 98657d5 | 2010-01-11 16:42:07 +0100 | [diff] [blame] | 119 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 120 | struct tlv_definition nm_att_tlvdef; |