int main(int argc, char **argv) { struct log_target *stderr_target; log_init(&log_info, NULL); stderr_target = log_target_create_stderr(); log_add_target(stderr_target); log_set_all_filter(stderr_target, 1); log_set_print_filename(stderr_target, 0); log_parse_category_mask(stderr_target, "DRLL:DCC"); log_parse_category_mask(stderr_target, "DRLL"); DEBUGP(DCC, "You should not see this\n"); log_parse_category_mask(stderr_target, "DRLL:DCC"); DEBUGP(DRLL, "You should see this\n"); DEBUGP(DCC, "You should see this\n"); DEBUGP(DMM, "You should not see this\n"); OSMO_ASSERT(filter_called == 0); log_set_all_filter(stderr_target, 0); DEBUGP(DRLL, "You should not see this and filter is called\n"); OSMO_ASSERT(filter_called == 1); return 0; }
int main() { printf("Testing subscriber database code.\n"); osmo_init_logging(&log_info); log_set_print_filename(osmo_stderr_target, 0); dummy_net.subscr_group = &dummy_sgrp; dummy_sgrp.net = &dummy_net; if (db_init("hlr.sqlite3")) { printf("DB: Failed to init database. Please check the option settings.\n"); return 1; } printf("DB: Database initialized.\n"); if (db_prepare()) { printf("DB: Failed to prepare database.\n"); return 1; } printf("DB: Database prepared.\n"); struct gsm_subscriber *alice = NULL; struct gsm_subscriber *alice_db; char *alice_imsi = "3243245432345"; alice = db_create_subscriber(alice_imsi, GSM_MIN_EXTEN, GSM_MAX_EXTEN, true); db_sync_subscriber(alice); alice_db = db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice->imsi); COMPARE(alice, alice_db); SUBSCR_PUT(alice_db); SUBSCR_PUT(alice); test_subs("3693245423445", "1234567890", NULL, true); test_subs("9993245423445", "1234567890", "6543560920", true); test_subs("3123122223445", "1234567890", NULL, false); test_subs("9123121223445", "1234567890", "6543560920", false); /* create it again and see it fails */ alice = db_create_subscriber(alice_imsi, GSM_MIN_EXTEN, GSM_MAX_EXTEN, true); OSMO_ASSERT(!alice); test_sms(); test_sms_migrate(); db_fini(); printf("Done\n"); return 0; }
int main(int argc, char **argv) { struct log_target *stderr_target; log_init(&log_info, NULL); stderr_target = log_target_create_stderr(); log_add_target(stderr_target); log_set_print_filename(stderr_target, 0); test_wqueue_limit(); printf("Done\n"); return 0; }
int main(int argc, char **argv) { void *ctx = talloc_named_const(NULL, 0, "oap_client_test"); msgb_talloc_ctx_init(ctx, 0); osmo_init_logging2(ctx, &info); OSMO_ASSERT(osmo_stderr_target); log_set_use_color(osmo_stderr_target, 0); log_set_print_timestamp(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); log_set_print_category(osmo_stderr_target, 1); log_parse_category_mask(osmo_stderr_target, "DLOAP,1"); test_oap_api(); printf("Done\n"); return 0; }
/** * Initialize the logging system for the virtual physical layer. */ int ms_log_init(char *cat_mask) { struct log_target *stderr_target; log_init(&ms_log_info, NULL); stderr_target = log_target_create_stderr(); if (!stderr) return -1; log_add_target(stderr_target); log_set_all_filter(stderr_target, 1); //log_set_log_level(stderr_target, 1); log_set_print_filename(stderr_target, 1); log_set_use_color(stderr_target, 0); log_set_print_timestamp(stderr_target, 1); log_set_print_category(stderr_target, 1); if (cat_mask) log_parse_category_mask(stderr_target, cat_mask); return 0; }
int main(int argc, char **argv) { struct log_target *stderr_target; osmo_fsm_log_addr(false); log_init(&log_info, NULL); stderr_target = log_target_create_stderr(); log_add_target(stderr_target); log_set_print_filename(stderr_target, 0); g_ctx = NULL; osmo_fsm_register(&fsm); foo(); while (1) { osmo_select_main(0); } exit(0); }
int main(int argc, char **argv) { struct sockaddr_in bss_peer= {0}; osmo_init_logging(&info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); bssgp_nsi = gprs_ns_instantiate(gprs_ns_callback, NULL); bss_peer.sin_family = AF_INET; bss_peer.sin_port = htons(32000); bss_peer.sin_addr.s_addr = htonl(0x7f0000ff); gprs_ns_nsip_connect(bssgp_nsi, &bss_peer, BSS_NSEI, BSS_NSEI+1); printf("===== BSSGP test START\n"); test_bssgp_suspend_resume(); printf("===== BSSGP test END\n\n"); exit(EXIT_SUCCESS); }
int main(int argc, char **argv) { uint32_t bucket_size_max = 100; /* octets */ uint32_t bucket_leak_rate = 100; /* octets / second */ uint32_t max_queue_depth = 5; /* messages */ uint32_t pdu_length = 10; /* octets */ uint32_t pdu_count = 20; /* messages */ int c; static const struct option long_options[] = { { "bucket-size-max", 1, 0, 's' }, { "bucket-leak-rate", 1, 0, 'r' }, { "max-queue-depth", 1, 0, 'd' }, { "pdu-length", 1, 0, 'l' }, { "pdu-count", 1, 0, 'c' }, { "help", 0, 0, 'h' }, { 0, 0, 0, 0 } }; osmo_init_logging(&info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); while ((c = getopt_long(argc, argv, "s:r:d:l:c:", long_options, NULL)) != -1) { switch (c) { case 's': bucket_size_max = atoi(optarg); break; case 'r': bucket_leak_rate = atoi(optarg); break; case 'd': max_queue_depth = atoi(optarg); break; case 'l': pdu_length = atoi(optarg); break; case 'c': pdu_count = atoi(optarg); break; case 'h': help(); exit(EXIT_SUCCESS); break; default: exit(EXIT_FAILURE); } } /* bucket leak rate less than 100 not supported! */ if (bucket_leak_rate < 100) { fprintf(stderr, "Bucket leak rate < 100 not supported!\n"); exit(EXIT_FAILURE); } printf("===== BSSGP flow-control test START\n"); printf("size-max=%u oct, leak-rate=%u oct/s, " "queue-len=%u msgs, pdu_len=%u oct, pdu_cnt=%u\n\n", bucket_size_max, bucket_leak_rate, max_queue_depth, pdu_length, pdu_count); test_fc(bucket_size_max, bucket_leak_rate, max_queue_depth, pdu_length, pdu_count); printf("===== BSSGP flow-control test END\n\n"); exit(EXIT_SUCCESS); }
int main(int argc, char **argv) { struct log_target *stderr_target; log_init(&log_info, NULL); stderr_target = log_target_create_stderr(); log_add_target(stderr_target); log_set_all_filter(stderr_target, 1); log_set_print_filename(stderr_target, 0); log_set_print_category(stderr_target, 1); log_set_use_color(stderr_target, 0); log_parse_category_mask(stderr_target, "DRLL:DCC"); log_parse_category_mask(stderr_target, "DRLL"); select_output = 0; DEBUGP(DCC, "You should not see this\n"); if (log_check_level(DMM, LOGL_DEBUG) != 0) fprintf(stderr, "log_check_level did not catch this case\n"); log_parse_category_mask(stderr_target, "DRLL:DCC"); DEBUGP(DRLL, "You should see this\n"); OSMO_ASSERT(log_check_level(DRLL, LOGL_DEBUG) != 0); DEBUGP(DCC, "You should see this\n"); OSMO_ASSERT(log_check_level(DCC, LOGL_DEBUG) != 0); DEBUGP(DMM, "You should not see this\n"); OSMO_ASSERT(log_check_level(DMM, LOGL_DEBUG) == 0); OSMO_ASSERT(filter_called == 0); log_set_all_filter(stderr_target, 0); DEBUGP(DRLL, "You should not see this and filter is called\n"); OSMO_ASSERT(filter_called == 1); OSMO_ASSERT(log_check_level(DRLL, LOGL_DEBUG) == 0); OSMO_ASSERT(filter_called == 2); DEBUGP(DRLL, "You should not see this\n"); OSMO_ASSERT(filter_called == 3); select_output = 1; DEBUGP(DRLL, "You should see this\n"); OSMO_ASSERT(filter_called == 5); /* called twice on output */ /* Make sure out-of-bounds category maps to DLGLOBAL */ log_parse_category_mask(stderr_target, "DLGLOBAL,1"); /* For IDs out of bounds of the overall osmo_log_info array */ DEBUGP(osmo_log_info->num_cat + 1, "You should see this on DLGLOBAL (a)\n"); DEBUGP(osmo_log_info->num_cat + 100, "You should see this on DLGLOBAL (b)\n"); DEBUGP(osmo_log_info->num_cat, "You should see this on DLGLOBAL (c)\n"); /* For IDs out of bounds of the user categories part */ DEBUGP(log_info.num_cat + 1, "You should see this on DLGLOBAL (d)\n"); DEBUGP(log_info.num_cat, "You should see this on DLGLOBAL (e)\n"); /* Check log_set_category_filter() with internal categories */ log_parse_category_mask(stderr_target, "DLGLOBAL,3"); DEBUGP(DLGLOBAL, "You should not see this (DLGLOBAL not on DEBUG)\n"); log_set_category_filter(stderr_target, DLGLOBAL, 1, LOGL_DEBUG); DEBUGP(DLGLOBAL, "You should see this (DLGLOBAL on DEBUG)\n"); return 0; }
static void test_bssgp_flow_control_bvc(void) { struct bssgp_bvc_ctx bctx = { .nsei = 0x1234, .bvci = 0x5678, }; const uint8_t tag = 42; const uint32_t bmax = 0x1022 * 100; const uint32_t rate = 0xc040 / 8 * 100; const uint32_t bmax_ms = bmax / 2; const uint32_t rate_ms = rate / 2; uint8_t ratio = 0x78; uint32_t qdelay = 0x1144 * 10; int rc; static uint8_t expected_simple_msg[] = { 0x26, 0x1e, 0x81, 0x2a, /* tag */ 0x05, 0x82, 0x10, 0x22, /* Bmax */ 0x03, 0x82, 0xc0, 0x40, /* R */ 0x01, 0x82, 0x08, 0x11, /* Bmax_MS */ 0x1c, 0x82, 0x60, 0x20, /* R_MS */ }; static uint8_t expected_ext_msg[] = { 0x26, 0x1e, 0x81, 0x2a, /* tag */ 0x05, 0x82, 0x10, 0x22, /* Bmax */ 0x03, 0x82, 0xc0, 0x40, /* R */ 0x01, 0x82, 0x08, 0x11, /* Bmax_MS */ 0x1c, 0x82, 0x60, 0x20, /* R_MS */ 0x3c, 0x81, 0x78, /* ratio */ 0x06, 0x82, 0x11, 0x44, /* Qdelay */ }; printf("----- %s START\n", __func__); rc = bssgp_tx_fc_bvc(&bctx, tag, bmax, rate, bmax_ms, rate_ms, NULL, NULL); OSMO_ASSERT(rc >= 0); OSMO_ASSERT(last_ns_tx_msg != NULL); printf("Got message: %s\n", msgb_hexdump(last_ns_tx_msg)); OSMO_ASSERT(msgb_length(last_ns_tx_msg) == sizeof(expected_simple_msg)); OSMO_ASSERT(0 == memcmp(msgb_data(last_ns_tx_msg), expected_simple_msg, sizeof(expected_simple_msg))); rc = bssgp_tx_fc_bvc(&bctx, tag, bmax, rate, bmax_ms, rate_ms, &ratio, &qdelay); OSMO_ASSERT(rc >= 0); OSMO_ASSERT(last_ns_tx_msg != NULL); printf("Got message: %s\n", msgb_hexdump(last_ns_tx_msg)); OSMO_ASSERT(msgb_length(last_ns_tx_msg) == sizeof(expected_ext_msg)); OSMO_ASSERT(0 == memcmp(msgb_data(last_ns_tx_msg), expected_ext_msg, sizeof(expected_ext_msg))); msgb_free(last_ns_tx_msg); last_ns_tx_msg = NULL; printf("----- %s END\n", __func__); } static struct log_info info = {}; int main(int argc, char **argv) { struct sockaddr_in bss_peer= {0}; osmo_init_logging(&info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); bssgp_nsi = gprs_ns_instantiate(gprs_ns_callback, NULL); bss_peer.sin_family = AF_INET; bss_peer.sin_port = htons(32000); bss_peer.sin_addr.s_addr = htonl(0x7f0000ff); gprs_ns_nsip_connect(bssgp_nsi, &bss_peer, BSS_NSEI, BSS_NSEI+1); printf("===== BSSGP test START\n"); test_bssgp_suspend_resume(); test_bssgp_status(); test_bssgp_bad_reset(); test_bssgp_flow_control_bvc(); printf("===== BSSGP test END\n\n"); exit(EXIT_SUCCESS); }