Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 1 | /* tests for statistics */ |
| 2 | /* |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 3 | * (C) 2015 sysmocom - s.m.f.c. GmbH |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
| 8 | * |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 22 | * |
| 23 | */ |
| 24 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 25 | #include <osmocom/core/application.h> |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 26 | #include <osmocom/core/logging.h> |
| 27 | #include <osmocom/core/utils.h> |
| 28 | #include <osmocom/core/stat_item.h> |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 29 | #include <osmocom/core/rate_ctr.h> |
| 30 | #include <osmocom/core/stats.h> |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 31 | |
| 32 | #include <stdio.h> |
Neels Hofmeyr | b41b48e | 2017-01-13 00:11:34 +0100 | [diff] [blame] | 33 | #include <inttypes.h> |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 34 | |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 35 | enum test_ctr { |
| 36 | TEST_A_CTR, |
| 37 | TEST_B_CTR, |
| 38 | }; |
| 39 | |
| 40 | static const struct rate_ctr_desc ctr_description[] = { |
Harald Welte | a7a5065 | 2017-10-03 17:49:21 +0800 | [diff] [blame] | 41 | [TEST_A_CTR] = { "ctr:a", "The A counter value"}, |
| 42 | [TEST_B_CTR] = { "ctr:b", "The B counter value"}, |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | static const struct rate_ctr_group_desc ctrg_desc = { |
Harald Welte | a7a5065 | 2017-10-03 17:49:21 +0800 | [diff] [blame] | 46 | .group_name_prefix = "ctr-test:one", |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 47 | .group_description = "Counter test number 1", |
| 48 | .num_ctr = ARRAY_SIZE(ctr_description), |
| 49 | .ctr_desc = ctr_description, |
| 50 | .class_id = OSMO_STATS_CLASS_SUBSCRIBER, |
| 51 | }; |
| 52 | |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 53 | static const struct rate_ctr_desc ctr_description_dot[] = { |
| 54 | [TEST_A_CTR] = { "ctr.a", "The A counter value with ."}, |
| 55 | [TEST_B_CTR] = { "ctr.b", "The B counter value with ."}, |
| 56 | }; |
| 57 | |
| 58 | static const struct rate_ctr_group_desc ctrg_desc_dot = { |
| 59 | .group_name_prefix = "ctr-test.one_dot", |
| 60 | .group_description = "Counter test number 1dot", |
| 61 | .num_ctr = ARRAY_SIZE(ctr_description_dot), |
| 62 | .ctr_desc = ctr_description_dot, |
| 63 | .class_id = OSMO_STATS_CLASS_SUBSCRIBER, |
| 64 | }; |
| 65 | |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 66 | enum test_items { |
| 67 | TEST_A_ITEM, |
| 68 | TEST_B_ITEM, |
| 69 | }; |
| 70 | |
| 71 | static const struct osmo_stat_item_desc item_description[] = { |
| 72 | [TEST_A_ITEM] = { "item.a", "The A value", "ma", 4, -1 }, |
| 73 | [TEST_B_ITEM] = { "item.b", "The B value", "kb", 7, -1 }, |
| 74 | }; |
| 75 | |
| 76 | static const struct osmo_stat_item_group_desc statg_desc = { |
| 77 | .group_name_prefix = "test.one", |
| 78 | .group_description = "Test number 1", |
| 79 | .num_items = ARRAY_SIZE(item_description), |
| 80 | .item_desc = item_description, |
| 81 | .class_id = OSMO_STATS_CLASS_PEER, |
| 82 | }; |
| 83 | |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 84 | static void stat_test(void) |
| 85 | { |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 86 | struct osmo_stat_item_group *statg = |
| 87 | osmo_stat_item_group_alloc(NULL, &statg_desc, 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 88 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 89 | struct osmo_stat_item_group *sgrp2; |
| 90 | const struct osmo_stat_item *sitem1, *sitem2; |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 91 | int rc; |
| 92 | int32_t value; |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 93 | int32_t next_id_a = 0; |
| 94 | int32_t next_id_b = 0; |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 95 | int i; |
| 96 | |
| 97 | OSMO_ASSERT(statg != NULL); |
| 98 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 99 | sgrp2 = osmo_stat_item_get_group_by_name_idx("test.one", 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 100 | OSMO_ASSERT(sgrp2 == statg); |
| 101 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 102 | sgrp2 = osmo_stat_item_get_group_by_name_idx("test.one", 1); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 103 | OSMO_ASSERT(sgrp2 == NULL); |
| 104 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 105 | sgrp2 = osmo_stat_item_get_group_by_name_idx("test.two", 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 106 | OSMO_ASSERT(sgrp2 == NULL); |
| 107 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 108 | sitem1 = osmo_stat_item_get_by_name(statg, "item.c"); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 109 | OSMO_ASSERT(sitem1 == NULL); |
| 110 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 111 | sitem1 = osmo_stat_item_get_by_name(statg, "item.a"); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 112 | OSMO_ASSERT(sitem1 != NULL); |
| 113 | OSMO_ASSERT(sitem1 == statg->items[TEST_A_ITEM]); |
| 114 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 115 | sitem2 = osmo_stat_item_get_by_name(statg, "item.b"); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 116 | OSMO_ASSERT(sitem2 != NULL); |
| 117 | OSMO_ASSERT(sitem2 != sitem1); |
| 118 | OSMO_ASSERT(sitem2 == statg->items[TEST_B_ITEM]); |
| 119 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 120 | value = osmo_stat_item_get_last(statg->items[TEST_A_ITEM]); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 121 | OSMO_ASSERT(value == -1); |
| 122 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 123 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 124 | OSMO_ASSERT(rc == 0); |
| 125 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 126 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 1); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 127 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 128 | value = osmo_stat_item_get_last(statg->items[TEST_A_ITEM]); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 129 | OSMO_ASSERT(value == 1); |
| 130 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 131 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 132 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 133 | OSMO_ASSERT(value == 1); |
| 134 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 135 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 136 | OSMO_ASSERT(rc == 0); |
| 137 | |
| 138 | for (i = 2; i <= 32; i++) { |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 139 | osmo_stat_item_set(statg->items[TEST_A_ITEM], i); |
| 140 | osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + i); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 141 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 142 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 143 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 144 | OSMO_ASSERT(value == i); |
| 145 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 146 | rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 147 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 148 | OSMO_ASSERT(value == 1000 + i); |
| 149 | } |
| 150 | |
Alexander Couzens | cc72cc4 | 2019-04-27 23:19:55 +0200 | [diff] [blame] | 151 | /* check if dec & inc is working */ |
| 152 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 42); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 153 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Alexander Couzens | cc72cc4 | 2019-04-27 23:19:55 +0200 | [diff] [blame] | 154 | OSMO_ASSERT(rc > 0); |
| 155 | OSMO_ASSERT(value == 42); |
| 156 | |
| 157 | osmo_stat_item_dec(statg->items[TEST_A_ITEM], 21); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 158 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Alexander Couzens | cc72cc4 | 2019-04-27 23:19:55 +0200 | [diff] [blame] | 159 | OSMO_ASSERT(rc > 0); |
| 160 | OSMO_ASSERT(value == 21); |
| 161 | |
| 162 | osmo_stat_item_inc(statg->items[TEST_A_ITEM], 21); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 163 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Alexander Couzens | cc72cc4 | 2019-04-27 23:19:55 +0200 | [diff] [blame] | 164 | OSMO_ASSERT(rc > 0); |
| 165 | OSMO_ASSERT(value == 42); |
| 166 | |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 167 | /* Keep 2 in FIFO */ |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 168 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 33); |
| 169 | osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + 33); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 170 | |
| 171 | for (i = 34; i <= 64; i++) { |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 172 | osmo_stat_item_set(statg->items[TEST_A_ITEM], i); |
| 173 | osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + i); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 174 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 175 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 176 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 177 | OSMO_ASSERT(value == i-1); |
| 178 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 179 | rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 180 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 181 | OSMO_ASSERT(value == 1000 + i-1); |
| 182 | } |
| 183 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 184 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 185 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 186 | OSMO_ASSERT(value == 64); |
| 187 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 188 | rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 189 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 190 | OSMO_ASSERT(value == 1000 + 64); |
| 191 | |
| 192 | /* Overrun FIFOs */ |
| 193 | for (i = 65; i <= 96; i++) { |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 194 | osmo_stat_item_set(statg->items[TEST_A_ITEM], i); |
| 195 | osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + i); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 196 | } |
| 197 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 198 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 199 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 200 | OSMO_ASSERT(value == 93); |
| 201 | |
| 202 | for (i = 94; i <= 96; i++) { |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 203 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 204 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 205 | OSMO_ASSERT(value == i); |
| 206 | } |
| 207 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 208 | rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 209 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 210 | OSMO_ASSERT(value == 1000 + 90); |
| 211 | |
| 212 | for (i = 91; i <= 96; i++) { |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 213 | rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 214 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 215 | OSMO_ASSERT(value == 1000 + i); |
| 216 | } |
| 217 | |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 218 | /* Test Discard (single item) */ |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 219 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 97); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 220 | rc = osmo_stat_item_discard(statg->items[TEST_A_ITEM], &next_id_a); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 221 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 222 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 223 | rc = osmo_stat_item_discard(statg->items[TEST_A_ITEM], &next_id_a); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 224 | OSMO_ASSERT(rc == 0); |
| 225 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 226 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 227 | OSMO_ASSERT(rc == 0); |
| 228 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 229 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 98); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 230 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 231 | OSMO_ASSERT(rc > 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 232 | OSMO_ASSERT(value == 98); |
| 233 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 234 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 235 | OSMO_ASSERT(rc == 0); |
| 236 | |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 237 | /* Test Discard (all items) */ |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 238 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 99); |
| 239 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 100); |
| 240 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 101); |
| 241 | osmo_stat_item_set(statg->items[TEST_B_ITEM], 99); |
| 242 | osmo_stat_item_set(statg->items[TEST_B_ITEM], 100); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 243 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 244 | rc = osmo_stat_item_discard_all(&next_id_a); |
| 245 | rc = osmo_stat_item_discard_all(&next_id_b); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 246 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 247 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 248 | OSMO_ASSERT(rc == 0); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame^] | 249 | rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value); |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 250 | OSMO_ASSERT(rc == 0); |
| 251 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 252 | osmo_stat_item_group_free(statg); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 253 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 254 | sgrp2 = osmo_stat_item_get_group_by_name_idx("test.one", 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 255 | OSMO_ASSERT(sgrp2 == NULL); |
| 256 | } |
| 257 | |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 258 | /*** stats reporter tests ***/ |
| 259 | |
| 260 | /* define a special stats reporter for testing */ |
| 261 | |
| 262 | static int send_count; |
| 263 | |
| 264 | enum { |
| 265 | OSMO_STATS_REPORTER_TEST = OSMO_STATS_REPORTER_LOG + 1, |
| 266 | }; |
| 267 | |
| 268 | static int stats_reporter_test_send_counter(struct osmo_stats_reporter *srep, |
| 269 | const struct rate_ctr_group *ctrg, |
| 270 | const struct rate_ctr_desc *desc, |
| 271 | int64_t value, int64_t delta) |
| 272 | { |
| 273 | const char *group_name = ctrg ? ctrg->desc->group_name_prefix : ""; |
| 274 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 275 | fprintf(stderr, " %s: counter p=%s g=%s i=%u n=%s v=%lld d=%lld\n", |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 276 | srep->name, |
| 277 | srep->name_prefix ? srep->name_prefix : "", |
| 278 | group_name, ctrg ? ctrg->idx : 0, |
| 279 | desc->name, (long long)value, (long long)delta); |
| 280 | |
| 281 | send_count += 1; |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | static int stats_reporter_test_send_item(struct osmo_stats_reporter *srep, |
| 286 | const struct osmo_stat_item_group *statg, |
Neels Hofmeyr | b41b48e | 2017-01-13 00:11:34 +0100 | [diff] [blame] | 287 | const struct osmo_stat_item_desc *desc, int64_t value) |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 288 | { |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 289 | fprintf(stderr, " %s: item p=%s g=%s i=%u n=%s v=%"PRId64" u=%s\n", |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 290 | srep->name, |
| 291 | srep->name_prefix ? srep->name_prefix : "", |
| 292 | statg->desc->group_name_prefix, statg->idx, |
| 293 | desc->name, value, desc->unit ? desc->unit : ""); |
| 294 | |
| 295 | send_count += 1; |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | static int stats_reporter_test_open(struct osmo_stats_reporter *srep) |
| 300 | { |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 301 | fprintf(stderr, " %s: open\n", srep->name); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 302 | return 0; |
| 303 | } |
| 304 | |
| 305 | static int stats_reporter_test_close(struct osmo_stats_reporter *srep) |
| 306 | { |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 307 | fprintf(stderr, " %s: close\n", srep->name); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 308 | return 0; |
| 309 | } |
| 310 | |
| 311 | static struct osmo_stats_reporter *stats_reporter_create_test(const char *name) |
| 312 | { |
| 313 | struct osmo_stats_reporter *srep; |
| 314 | srep = osmo_stats_reporter_alloc(OSMO_STATS_REPORTER_TEST, name); |
| 315 | |
| 316 | srep->have_net_config = 0; |
| 317 | |
| 318 | srep->open = stats_reporter_test_open; |
| 319 | srep->close = stats_reporter_test_close; |
| 320 | srep->send_counter = stats_reporter_test_send_counter; |
| 321 | srep->send_item = stats_reporter_test_send_item; |
| 322 | |
| 323 | return srep; |
| 324 | } |
| 325 | |
| 326 | |
| 327 | static void test_reporting() |
| 328 | { |
| 329 | struct osmo_stats_reporter *srep1, *srep2, *srep; |
| 330 | struct osmo_stat_item_group *statg1, *statg2; |
Max | 3ef14a2 | 2017-12-15 20:19:10 +0100 | [diff] [blame] | 331 | struct rate_ctr_group *ctrg1, *ctrg2, *ctrg3, *ctrg_dup; |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 332 | void *stats_ctx = talloc_named_const(NULL, 1, "stats test context"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 333 | |
| 334 | int rc; |
| 335 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 336 | fprintf(stderr, "Start test: %s\n", __func__); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 337 | |
| 338 | /* Allocate counters and items */ |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 339 | statg1 = osmo_stat_item_group_alloc(stats_ctx, &statg_desc, 1); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 340 | OSMO_ASSERT(statg1 != NULL); |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 341 | statg2 = osmo_stat_item_group_alloc(stats_ctx, &statg_desc, 2); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 342 | OSMO_ASSERT(statg2 != NULL); |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 343 | ctrg1 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 1); |
Neels Hofmeyr | 554f7b8 | 2017-12-20 01:14:31 +0100 | [diff] [blame] | 344 | OSMO_ASSERT(ctrg1 && ctrg1->idx == 1); |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 345 | ctrg2 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 2); |
Neels Hofmeyr | 554f7b8 | 2017-12-20 01:14:31 +0100 | [diff] [blame] | 346 | OSMO_ASSERT(ctrg2 && ctrg2->idx == 2); |
Max | 3ef14a2 | 2017-12-15 20:19:10 +0100 | [diff] [blame] | 347 | |
| 348 | ctrg_dup = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 2); |
Neels Hofmeyr | 554f7b8 | 2017-12-20 01:14:31 +0100 | [diff] [blame] | 349 | OSMO_ASSERT(ctrg_dup && ctrg_dup->idx == 3); |
| 350 | rate_ctr_group_free(ctrg_dup); |
Max | 3ef14a2 | 2017-12-15 20:19:10 +0100 | [diff] [blame] | 351 | |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 352 | ctrg3 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc_dot, 3); |
Neels Hofmeyr | 554f7b8 | 2017-12-20 01:14:31 +0100 | [diff] [blame] | 353 | OSMO_ASSERT(ctrg3 && ctrg3->idx == 3); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 354 | |
| 355 | srep1 = stats_reporter_create_test("test1"); |
| 356 | OSMO_ASSERT(srep1 != NULL); |
| 357 | |
| 358 | srep2 = stats_reporter_create_test("test2"); |
| 359 | OSMO_ASSERT(srep2 != NULL); |
| 360 | |
| 361 | srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_TEST, "test1"); |
| 362 | OSMO_ASSERT(srep == srep1); |
| 363 | srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_TEST, "test2"); |
| 364 | OSMO_ASSERT(srep == srep2); |
| 365 | |
| 366 | rc = osmo_stats_reporter_enable(srep1); |
| 367 | OSMO_ASSERT(rc >= 0); |
| 368 | OSMO_ASSERT(srep1->force_single_flush); |
| 369 | rc = osmo_stats_reporter_set_max_class(srep1, OSMO_STATS_CLASS_SUBSCRIBER); |
| 370 | OSMO_ASSERT(rc >= 0); |
| 371 | |
| 372 | rc = osmo_stats_reporter_enable(srep2); |
| 373 | OSMO_ASSERT(rc >= 0); |
| 374 | OSMO_ASSERT(srep2->force_single_flush); |
| 375 | rc = osmo_stats_reporter_set_max_class(srep2, OSMO_STATS_CLASS_SUBSCRIBER); |
| 376 | OSMO_ASSERT(rc >= 0); |
| 377 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 378 | fprintf(stderr, "report (initial):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 379 | send_count = 0; |
| 380 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 381 | OSMO_ASSERT(send_count == 20); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 382 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 383 | fprintf(stderr, "report (srep1 global):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 384 | /* force single flush */ |
| 385 | osmo_stats_reporter_set_max_class(srep1, OSMO_STATS_CLASS_GLOBAL); |
| 386 | srep1->force_single_flush = 1; |
| 387 | srep2->force_single_flush = 1; |
| 388 | send_count = 0; |
| 389 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 390 | OSMO_ASSERT(send_count == 10); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 391 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 392 | fprintf(stderr, "report (srep1 peer):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 393 | /* force single flush */ |
| 394 | osmo_stats_reporter_set_max_class(srep1, OSMO_STATS_CLASS_PEER); |
| 395 | srep1->force_single_flush = 1; |
| 396 | srep2->force_single_flush = 1; |
| 397 | send_count = 0; |
| 398 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 399 | OSMO_ASSERT(send_count == 14); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 400 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 401 | fprintf(stderr, "report (srep1 subscriber):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 402 | /* force single flush */ |
| 403 | osmo_stats_reporter_set_max_class(srep1, OSMO_STATS_CLASS_SUBSCRIBER); |
| 404 | srep1->force_single_flush = 1; |
| 405 | srep2->force_single_flush = 1; |
| 406 | send_count = 0; |
| 407 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 408 | OSMO_ASSERT(send_count == 20); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 409 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 410 | fprintf(stderr, "report (srep2 disabled):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 411 | /* force single flush */ |
| 412 | srep1->force_single_flush = 1; |
| 413 | srep2->force_single_flush = 1; |
| 414 | rc = osmo_stats_reporter_disable(srep2); |
| 415 | OSMO_ASSERT(rc >= 0); |
| 416 | send_count = 0; |
| 417 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 418 | OSMO_ASSERT(send_count == 10); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 419 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 420 | fprintf(stderr, "report (srep2 enabled, no flush forced):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 421 | rc = osmo_stats_reporter_enable(srep2); |
| 422 | OSMO_ASSERT(rc >= 0); |
| 423 | send_count = 0; |
| 424 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 425 | OSMO_ASSERT(send_count == 10); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 426 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 427 | fprintf(stderr, "report (should be empty):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 428 | send_count = 0; |
| 429 | osmo_stats_report(); |
| 430 | OSMO_ASSERT(send_count == 0); |
| 431 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 432 | fprintf(stderr, "report (group 1, counter 1 update):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 433 | rate_ctr_inc(&ctrg1->ctr[TEST_A_CTR]); |
| 434 | send_count = 0; |
| 435 | osmo_stats_report(); |
| 436 | OSMO_ASSERT(send_count == 2); |
| 437 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 438 | fprintf(stderr, "report (group 1, item 1 update):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 439 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); |
| 440 | send_count = 0; |
| 441 | osmo_stats_report(); |
| 442 | OSMO_ASSERT(send_count == 2); |
| 443 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 444 | fprintf(stderr, "report (group 1, item 1 update twice):\n"); |
Daniel Willmann | 2aa527b | 2021-03-01 21:53:46 +0100 | [diff] [blame] | 445 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); |
| 446 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); |
| 447 | send_count = 0; |
| 448 | osmo_stats_report(); |
| 449 | OSMO_ASSERT(send_count == 2); |
| 450 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 451 | fprintf(stderr, "report (group 1, item 1 update twice, check max):\n"); |
Daniel Willmann | 2aa527b | 2021-03-01 21:53:46 +0100 | [diff] [blame] | 452 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 20); |
| 453 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); |
| 454 | send_count = 0; |
| 455 | osmo_stats_report(); |
| 456 | OSMO_ASSERT(send_count == 2); |
| 457 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 458 | fprintf(stderr, "report (remove statg1, ctrg1):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 459 | /* force single flush */ |
| 460 | srep1->force_single_flush = 1; |
| 461 | srep2->force_single_flush = 1; |
| 462 | osmo_stat_item_group_free(statg1); |
| 463 | rate_ctr_group_free(ctrg1); |
| 464 | send_count = 0; |
| 465 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 466 | OSMO_ASSERT(send_count == 12); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 467 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 468 | fprintf(stderr, "report (remove srep1):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 469 | /* force single flush */ |
| 470 | srep1->force_single_flush = 1; |
| 471 | srep2->force_single_flush = 1; |
| 472 | osmo_stats_reporter_free(srep1); |
| 473 | send_count = 0; |
| 474 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 475 | OSMO_ASSERT(send_count == 6); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 476 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 477 | fprintf(stderr, "report (remove statg2):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 478 | /* force single flush */ |
| 479 | srep2->force_single_flush = 1; |
| 480 | osmo_stat_item_group_free(statg2); |
| 481 | send_count = 0; |
| 482 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 483 | OSMO_ASSERT(send_count == 4); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 484 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 485 | fprintf(stderr, "report (remove srep2):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 486 | /* force single flush */ |
| 487 | srep2->force_single_flush = 1; |
| 488 | osmo_stats_reporter_free(srep2); |
| 489 | send_count = 0; |
| 490 | osmo_stats_report(); |
| 491 | OSMO_ASSERT(send_count == 0); |
| 492 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 493 | fprintf(stderr, "report (remove ctrg2, should be empty):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 494 | rate_ctr_group_free(ctrg2); |
| 495 | send_count = 0; |
| 496 | osmo_stats_report(); |
| 497 | OSMO_ASSERT(send_count == 0); |
| 498 | |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 499 | rate_ctr_group_free(ctrg3); |
| 500 | |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 501 | /* Leak check */ |
| 502 | OSMO_ASSERT(talloc_total_blocks(stats_ctx) == 1); |
| 503 | talloc_free(stats_ctx); |
| 504 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 505 | fprintf(stderr, "End test: %s\n", __func__); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 506 | } |
| 507 | |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 508 | int main(int argc, char **argv) |
| 509 | { |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 510 | void *ctx = talloc_named_const(NULL, 0, "main"); |
| 511 | osmo_init_logging2(ctx, NULL); |
| 512 | |
| 513 | log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); |
| 514 | log_set_print_level(osmo_stderr_target, 1); |
| 515 | log_set_print_category(osmo_stderr_target, 1); |
| 516 | log_set_print_category_hex(osmo_stderr_target, 0); |
| 517 | log_set_use_color(osmo_stderr_target, 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 518 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 519 | osmo_stat_item_init(NULL); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 520 | |
| 521 | stat_test(); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 522 | test_reporting(); |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 523 | talloc_free(ctx); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 524 | return 0; |
| 525 | } |