diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2019-12-26 23:41:23 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2019-12-26 23:41:39 +0100 |
commit | 51053ebb9ea7068b7a4e6bff11a470d4c4dedb37 (patch) | |
tree | bd51d761496ab8d5024a8618a0d0f0db58ca4318 | |
parent | c6a8697800376a02b868cdea8fc1bf55f12798f1 (diff) |
fake_statsneels/fake_stats
Change-Id: Ib7c9b2065dc70dc83eab6c184f65d5c23e98b08b
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/stats/fake_stats.c | 58 |
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index bf7017b1..506edc5d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -63,6 +63,7 @@ endif if !EMBEDDED check_PROGRAMS += \ stats/stats_test \ + stats/fake_stats \ exec/exec_test endif @@ -76,6 +77,9 @@ utils_utils_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la stats_stats_test_SOURCES = stats/stats_test.c stats_stats_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la +stats_fake_stats_SOURCES = stats/fake_stats.c +stats_fake_stats_LDADD = $(LDADD) $(top_builddir)/src/vty/libosmovty.la + a5_a5_test_SOURCES = a5/a5_test.c a5_a5_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libgsmint.la diff --git a/tests/stats/fake_stats.c b/tests/stats/fake_stats.c new file mode 100644 index 00000000..66482bbb --- /dev/null +++ b/tests/stats/fake_stats.c @@ -0,0 +1,58 @@ +#include <talloc.h> +#include <osmocom/core/application.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/utils.h> +#include <osmocom/core/stats.h> +#include <osmocom/vty/vty.h> +#include <osmocom/vty/misc.h> +#include <osmocom/vty/logging.h> +#include <osmocom/vty/telnet_interface.h> +#include <osmocom/vty/stats.h> + +static struct vty_app_info vty_info = { + .name = "fake_stats", + .version = "1", +}; + +static const struct log_info_cat categories[] = { +}; + +const struct log_info log_info = { + .cat = categories, + .num_cat = ARRAY_SIZE(categories), +}; + +int main(int argc, char **argv) +{ + int rc; + void *ctx = talloc_named_const(NULL, 1, "fake_stats"); + vty_info.tall_ctx = ctx; + + osmo_init_logging2(ctx, &log_info); + + osmo_stats_init(ctx); +//int osmo_stat_item_init(void *tall_ctx); + + vty_init(&vty_info); + osmo_stats_vty_add_cmds(); + + logging_vty_add_cmds(); + osmo_talloc_vty_add_cmds(); + +//void rate_ctr_add(struct rate_ctr *ctr, int inc); +// osmo_stat_item + + /* start telnet after reading config for vty_get_bind_addr() */ + rc = telnet_init_dynif(ctx, NULL, + vty_get_bind_addr(), 12345); + if (rc < 0) + return 2; + + while (1) { + log_reset_context(); + osmo_select_main_ctx(0); + } + return 0; +} + +// telnet localhost 12345 |