Neels Hofmeyr | 9d307ec | 2018-05-04 16:06:32 +0200 | [diff] [blame] | 1 | /* (C) 2018 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 2 | * |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 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 |
| 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 Affero General Public License for more details. |
| 14 | * |
| 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/>. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <string.h> |
| 21 | |
| 22 | #include <osmocom/core/logging.h> |
| 23 | #include <osmocom/core/utils.h> |
| 24 | #include <osmocom/core/application.h> |
| 25 | #include <osmocom/gsm/gsup.h> |
| 26 | |
| 27 | #include "logging.h" |
| 28 | #include "luop.h" |
| 29 | |
| 30 | struct osmo_gsup_server; |
| 31 | |
| 32 | /* override osmo_gsup_addr_send() to not actually send anything. */ |
| 33 | int osmo_gsup_addr_send(struct osmo_gsup_server *gs, |
| 34 | const uint8_t *addr, size_t addrlen, |
| 35 | struct msgb *msg) |
| 36 | { |
| 37 | LOGP(DMAIN, LOGL_DEBUG, "%s\n", msgb_hexdump(msg)); |
| 38 | msgb_free(msg); |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | int db_subscr_get_by_imsi(struct db_context *dbc, const char *imsi, |
| 43 | struct hlr_subscriber *subscr) |
| 44 | { |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | /* Verify that the internally allocated msgb is large enough */ |
| 49 | void test_gsup_tx_insert_subscr_data() |
| 50 | { |
| 51 | struct lu_operation luop = { |
| 52 | .state = LU_S_LU_RECEIVED, |
| 53 | .subscr = { |
| 54 | .imsi = "123456789012345", |
| 55 | .msisdn = "987654321098765", |
| 56 | .nam_cs = true, |
| 57 | .nam_ps = true, |
| 58 | }, |
| 59 | .is_ps = true, |
| 60 | }; |
| 61 | |
| 62 | lu_op_tx_insert_subscr_data(&luop); |
| 63 | } |
| 64 | |
| 65 | const struct log_info_cat default_categories[] = { |
| 66 | [DMAIN] = { |
| 67 | .name = "DMAIN", |
| 68 | .description = "Main Program", |
| 69 | .enabled = 1, .loglevel = LOGL_DEBUG, |
| 70 | }, |
| 71 | }; |
| 72 | |
| 73 | static struct log_info info = { |
| 74 | .cat = default_categories, |
| 75 | .num_cat = ARRAY_SIZE(default_categories), |
| 76 | }; |
| 77 | |
| 78 | int main(int argc, char **argv) |
| 79 | { |
| 80 | void *ctx = talloc_named_const(NULL, 0, "gsup_test"); |
| 81 | osmo_init_logging2(ctx, &info); |
| 82 | log_set_print_filename(osmo_stderr_target, 0); |
| 83 | log_set_print_timestamp(osmo_stderr_target, 0); |
| 84 | log_set_use_color(osmo_stderr_target, 0); |
| 85 | log_set_print_category(osmo_stderr_target, 1); |
| 86 | |
| 87 | test_gsup_tx_insert_subscr_data(); |
| 88 | |
| 89 | printf("Done.\n"); |
| 90 | return EXIT_SUCCESS; |
| 91 | } |