e1d-prbs-test: Initialize libosmocore logging

Fixes the following crash when libosmo-e1d wants to log something:

ERROR: osmo_log_info == NULL! You must call log_init() before using logging in log_check_level()!
Assert failed osmo_log_info logging.c:299
backtrace() returned 13 addresses
/usr/local/lib/libosmocore.so.17(osmo_generate_backtrace+0x1c) [0x7ff4ed29d6cf]
/usr/local/lib/libosmocore.so.17(+0x263c7) [0x7ff4ed29d3c7]
/usr/local/lib/libosmocore.so.17(osmo_panic+0xe0) [0x7ff4ed29d4ac]
/usr/local/lib/libosmocore.so.17(assert_loginfo+0x74) [0x7ff4ed298f57]
/usr/local/lib/libosmocore.so.17(log_check_level+0x1e) [0x7ff4ed29b091]
/usr/local/lib/libosmo-e1d.so.1(osmo_e1dp_send+0xf2) [0x7ff4ed2727a2]
/usr/local/lib/libosmo-e1d.so.1(+0x19d4) [0x7ff4ed2729d4]
/usr/local/lib/libosmo-e1d.so.1(+0x1c37) [0x7ff4ed272c37]
/usr/local/lib/libosmo-e1d.so.1(osmo_e1dp_client_ts_open+0x1d) [0x7ff4ed2730ed]
./e1-prbs-test(+0x1841) [0x55e00daeb841]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7ff4ed0a60b3]
./e1-prbs-test(+0x192e) [0x55e00daeb92e]
Aborted

Change-Id: Ia305b008711c15383c84f7cf2acedd20b568ef8a
This commit is contained in:
Harald Welte 2021-04-04 11:16:58 +02:00
parent 949c237963
commit a82fe56aea
1 changed files with 6 additions and 0 deletions

View File

@ -39,6 +39,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/bits.h>
#include <osmocom/core/prbs.h>
#include <osmocom/core/application.h>
#include <osmocom/e1d/proto_clnt.h>
@ -238,6 +239,7 @@ int main(int argc, char **argv)
{
char *basedir;
int rc;
void *g_ctx;
handle_options(argc, argv);
@ -248,6 +250,10 @@ int main(int argc, char **argv)
}
basedir = argv[optind];
g_ctx = talloc_named_const(NULL, 0, "g_ctx");
OSMO_ASSERT(g_ctx);
osmo_init_logging2(g_ctx, NULL);
set_realtime(10);
rc = open_slots(&g_tst, basedir);
if (rc < 0)