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 | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 93 | int32_t next_id_a = 1; |
| 94 | int32_t next_id_b = 1; |
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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 132 | OSMO_ASSERT(rc == 1); |
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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 143 | OSMO_ASSERT(rc == 1); |
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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 147 | OSMO_ASSERT(rc == 1); |
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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 154 | OSMO_ASSERT(rc == 1); |
Alexander Couzens | cc72cc4 | 2019-04-27 23:19:55 +0200 | [diff] [blame] | 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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 159 | OSMO_ASSERT(rc == 1); |
Alexander Couzens | cc72cc4 | 2019-04-27 23:19:55 +0200 | [diff] [blame] | 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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 164 | OSMO_ASSERT(rc == 1); |
Alexander Couzens | cc72cc4 | 2019-04-27 23:19:55 +0200 | [diff] [blame] | 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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 176 | OSMO_ASSERT(rc == 1); |
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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 180 | OSMO_ASSERT(rc == 1); |
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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 185 | OSMO_ASSERT(rc == 1); |
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); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 189 | OSMO_ASSERT(rc == 1); |
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 | 2623fca | 2021-03-26 10:42:09 +0100 | [diff] [blame^] | 198 | fprintf(stderr, "Skipping %d values\n", 93 - 65); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame] | 199 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 200 | OSMO_ASSERT(rc == 93 - 65 + 1); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 201 | OSMO_ASSERT(value == 93); |
| 202 | |
| 203 | for (i = 94; i <= 96; i++) { |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame] | 204 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 205 | OSMO_ASSERT(rc == 1); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 206 | OSMO_ASSERT(value == i); |
| 207 | } |
| 208 | |
Oliver Smith | 2623fca | 2021-03-26 10:42:09 +0100 | [diff] [blame^] | 209 | fprintf(stderr, "Skipping %d values\n", 90 - 65); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame] | 210 | rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 211 | OSMO_ASSERT(rc == 90 - 65 + 1); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 212 | OSMO_ASSERT(value == 1000 + 90); |
| 213 | |
| 214 | for (i = 91; i <= 96; i++) { |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame] | 215 | rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 216 | OSMO_ASSERT(rc == 1); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 217 | OSMO_ASSERT(value == 1000 + i); |
| 218 | } |
| 219 | |
Jacob Erlbeck | b27b352 | 2015-10-12 18:47:09 +0200 | [diff] [blame] | 220 | /* Test Discard (single item) */ |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 221 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 97); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame] | 222 | rc = osmo_stat_item_discard(statg->items[TEST_A_ITEM], &next_id_a); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 223 | OSMO_ASSERT(rc == 1); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 224 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame] | 225 | 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] | 226 | OSMO_ASSERT(rc == 0); |
| 227 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame] | 228 | 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] | 229 | OSMO_ASSERT(rc == 0); |
| 230 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 231 | osmo_stat_item_set(statg->items[TEST_A_ITEM], 98); |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame] | 232 | rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value); |
Oliver Smith | c793058 | 2021-03-26 11:00:43 +0100 | [diff] [blame] | 233 | OSMO_ASSERT(rc == 1); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 234 | OSMO_ASSERT(value == 98); |
| 235 | |
Oliver Smith | d3490bc | 2021-03-26 11:34:34 +0100 | [diff] [blame] | 236 | 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] | 237 | OSMO_ASSERT(rc == 0); |
| 238 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 239 | osmo_stat_item_group_free(statg); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 240 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 241 | sgrp2 = osmo_stat_item_get_group_by_name_idx("test.one", 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 242 | OSMO_ASSERT(sgrp2 == NULL); |
| 243 | } |
| 244 | |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 245 | /*** stats reporter tests ***/ |
| 246 | |
| 247 | /* define a special stats reporter for testing */ |
| 248 | |
| 249 | static int send_count; |
| 250 | |
| 251 | enum { |
| 252 | OSMO_STATS_REPORTER_TEST = OSMO_STATS_REPORTER_LOG + 1, |
| 253 | }; |
| 254 | |
| 255 | static int stats_reporter_test_send_counter(struct osmo_stats_reporter *srep, |
| 256 | const struct rate_ctr_group *ctrg, |
| 257 | const struct rate_ctr_desc *desc, |
| 258 | int64_t value, int64_t delta) |
| 259 | { |
| 260 | const char *group_name = ctrg ? ctrg->desc->group_name_prefix : ""; |
| 261 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 262 | 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] | 263 | srep->name, |
| 264 | srep->name_prefix ? srep->name_prefix : "", |
| 265 | group_name, ctrg ? ctrg->idx : 0, |
| 266 | desc->name, (long long)value, (long long)delta); |
| 267 | |
| 268 | send_count += 1; |
| 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | static int stats_reporter_test_send_item(struct osmo_stats_reporter *srep, |
| 273 | const struct osmo_stat_item_group *statg, |
Neels Hofmeyr | b41b48e | 2017-01-13 00:11:34 +0100 | [diff] [blame] | 274 | const struct osmo_stat_item_desc *desc, int64_t value) |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 275 | { |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 276 | 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] | 277 | srep->name, |
| 278 | srep->name_prefix ? srep->name_prefix : "", |
| 279 | statg->desc->group_name_prefix, statg->idx, |
| 280 | desc->name, value, desc->unit ? desc->unit : ""); |
| 281 | |
| 282 | send_count += 1; |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | static int stats_reporter_test_open(struct osmo_stats_reporter *srep) |
| 287 | { |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 288 | fprintf(stderr, " %s: open\n", srep->name); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | static int stats_reporter_test_close(struct osmo_stats_reporter *srep) |
| 293 | { |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 294 | fprintf(stderr, " %s: close\n", srep->name); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | static struct osmo_stats_reporter *stats_reporter_create_test(const char *name) |
| 299 | { |
| 300 | struct osmo_stats_reporter *srep; |
| 301 | srep = osmo_stats_reporter_alloc(OSMO_STATS_REPORTER_TEST, name); |
| 302 | |
| 303 | srep->have_net_config = 0; |
| 304 | |
| 305 | srep->open = stats_reporter_test_open; |
| 306 | srep->close = stats_reporter_test_close; |
| 307 | srep->send_counter = stats_reporter_test_send_counter; |
| 308 | srep->send_item = stats_reporter_test_send_item; |
| 309 | |
| 310 | return srep; |
| 311 | } |
| 312 | |
| 313 | |
| 314 | static void test_reporting() |
| 315 | { |
| 316 | struct osmo_stats_reporter *srep1, *srep2, *srep; |
| 317 | struct osmo_stat_item_group *statg1, *statg2; |
Max | 3ef14a2 | 2017-12-15 20:19:10 +0100 | [diff] [blame] | 318 | struct rate_ctr_group *ctrg1, *ctrg2, *ctrg3, *ctrg_dup; |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 319 | void *stats_ctx = talloc_named_const(NULL, 1, "stats test context"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 320 | |
| 321 | int rc; |
| 322 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 323 | fprintf(stderr, "Start test: %s\n", __func__); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 324 | |
| 325 | /* Allocate counters and items */ |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 326 | statg1 = osmo_stat_item_group_alloc(stats_ctx, &statg_desc, 1); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 327 | OSMO_ASSERT(statg1 != NULL); |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 328 | statg2 = osmo_stat_item_group_alloc(stats_ctx, &statg_desc, 2); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 329 | OSMO_ASSERT(statg2 != NULL); |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 330 | ctrg1 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 1); |
Neels Hofmeyr | 554f7b8 | 2017-12-20 01:14:31 +0100 | [diff] [blame] | 331 | OSMO_ASSERT(ctrg1 && ctrg1->idx == 1); |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 332 | ctrg2 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 2); |
Neels Hofmeyr | 554f7b8 | 2017-12-20 01:14:31 +0100 | [diff] [blame] | 333 | OSMO_ASSERT(ctrg2 && ctrg2->idx == 2); |
Max | 3ef14a2 | 2017-12-15 20:19:10 +0100 | [diff] [blame] | 334 | |
| 335 | ctrg_dup = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 2); |
Neels Hofmeyr | 554f7b8 | 2017-12-20 01:14:31 +0100 | [diff] [blame] | 336 | OSMO_ASSERT(ctrg_dup && ctrg_dup->idx == 3); |
| 337 | rate_ctr_group_free(ctrg_dup); |
Max | 3ef14a2 | 2017-12-15 20:19:10 +0100 | [diff] [blame] | 338 | |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 339 | ctrg3 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc_dot, 3); |
Neels Hofmeyr | 554f7b8 | 2017-12-20 01:14:31 +0100 | [diff] [blame] | 340 | OSMO_ASSERT(ctrg3 && ctrg3->idx == 3); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 341 | |
| 342 | srep1 = stats_reporter_create_test("test1"); |
| 343 | OSMO_ASSERT(srep1 != NULL); |
| 344 | |
| 345 | srep2 = stats_reporter_create_test("test2"); |
| 346 | OSMO_ASSERT(srep2 != NULL); |
| 347 | |
| 348 | srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_TEST, "test1"); |
| 349 | OSMO_ASSERT(srep == srep1); |
| 350 | srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_TEST, "test2"); |
| 351 | OSMO_ASSERT(srep == srep2); |
| 352 | |
| 353 | rc = osmo_stats_reporter_enable(srep1); |
| 354 | OSMO_ASSERT(rc >= 0); |
| 355 | OSMO_ASSERT(srep1->force_single_flush); |
| 356 | rc = osmo_stats_reporter_set_max_class(srep1, OSMO_STATS_CLASS_SUBSCRIBER); |
| 357 | OSMO_ASSERT(rc >= 0); |
| 358 | |
| 359 | rc = osmo_stats_reporter_enable(srep2); |
| 360 | OSMO_ASSERT(rc >= 0); |
| 361 | OSMO_ASSERT(srep2->force_single_flush); |
| 362 | rc = osmo_stats_reporter_set_max_class(srep2, OSMO_STATS_CLASS_SUBSCRIBER); |
| 363 | OSMO_ASSERT(rc >= 0); |
| 364 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 365 | fprintf(stderr, "report (initial):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 366 | send_count = 0; |
| 367 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 368 | OSMO_ASSERT(send_count == 20); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 369 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 370 | fprintf(stderr, "report (srep1 global):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 371 | /* force single flush */ |
| 372 | osmo_stats_reporter_set_max_class(srep1, OSMO_STATS_CLASS_GLOBAL); |
| 373 | srep1->force_single_flush = 1; |
| 374 | srep2->force_single_flush = 1; |
| 375 | send_count = 0; |
| 376 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 377 | OSMO_ASSERT(send_count == 10); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 378 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 379 | fprintf(stderr, "report (srep1 peer):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 380 | /* force single flush */ |
| 381 | osmo_stats_reporter_set_max_class(srep1, OSMO_STATS_CLASS_PEER); |
| 382 | srep1->force_single_flush = 1; |
| 383 | srep2->force_single_flush = 1; |
| 384 | send_count = 0; |
| 385 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 386 | OSMO_ASSERT(send_count == 14); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 387 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 388 | fprintf(stderr, "report (srep1 subscriber):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 389 | /* force single flush */ |
| 390 | osmo_stats_reporter_set_max_class(srep1, OSMO_STATS_CLASS_SUBSCRIBER); |
| 391 | srep1->force_single_flush = 1; |
| 392 | srep2->force_single_flush = 1; |
| 393 | send_count = 0; |
| 394 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 395 | OSMO_ASSERT(send_count == 20); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 396 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 397 | fprintf(stderr, "report (srep2 disabled):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 398 | /* force single flush */ |
| 399 | srep1->force_single_flush = 1; |
| 400 | srep2->force_single_flush = 1; |
| 401 | rc = osmo_stats_reporter_disable(srep2); |
| 402 | OSMO_ASSERT(rc >= 0); |
| 403 | send_count = 0; |
| 404 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 405 | OSMO_ASSERT(send_count == 10); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 406 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 407 | fprintf(stderr, "report (srep2 enabled, no flush forced):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 408 | rc = osmo_stats_reporter_enable(srep2); |
| 409 | OSMO_ASSERT(rc >= 0); |
| 410 | send_count = 0; |
| 411 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 412 | OSMO_ASSERT(send_count == 10); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 413 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 414 | fprintf(stderr, "report (should be empty):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 415 | send_count = 0; |
| 416 | osmo_stats_report(); |
| 417 | OSMO_ASSERT(send_count == 0); |
| 418 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 419 | fprintf(stderr, "report (group 1, counter 1 update):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 420 | rate_ctr_inc(&ctrg1->ctr[TEST_A_CTR]); |
| 421 | send_count = 0; |
| 422 | osmo_stats_report(); |
| 423 | OSMO_ASSERT(send_count == 2); |
| 424 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 425 | fprintf(stderr, "report (group 1, item 1 update):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 426 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); |
| 427 | send_count = 0; |
| 428 | osmo_stats_report(); |
| 429 | OSMO_ASSERT(send_count == 2); |
| 430 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 431 | fprintf(stderr, "report (group 1, item 1 update twice):\n"); |
Daniel Willmann | 2aa527b | 2021-03-01 21:53:46 +0100 | [diff] [blame] | 432 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); |
| 433 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); |
| 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 twice, check max):\n"); |
Daniel Willmann | 2aa527b | 2021-03-01 21:53:46 +0100 | [diff] [blame] | 439 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 20); |
| 440 | osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); |
| 441 | send_count = 0; |
| 442 | osmo_stats_report(); |
| 443 | OSMO_ASSERT(send_count == 2); |
| 444 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 445 | fprintf(stderr, "report (remove statg1, ctrg1):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 446 | /* force single flush */ |
| 447 | srep1->force_single_flush = 1; |
| 448 | srep2->force_single_flush = 1; |
| 449 | osmo_stat_item_group_free(statg1); |
| 450 | rate_ctr_group_free(ctrg1); |
| 451 | send_count = 0; |
| 452 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 453 | OSMO_ASSERT(send_count == 12); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 454 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 455 | fprintf(stderr, "report (remove srep1):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 456 | /* force single flush */ |
| 457 | srep1->force_single_flush = 1; |
| 458 | srep2->force_single_flush = 1; |
| 459 | osmo_stats_reporter_free(srep1); |
| 460 | send_count = 0; |
| 461 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 462 | OSMO_ASSERT(send_count == 6); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 463 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 464 | fprintf(stderr, "report (remove statg2):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 465 | /* force single flush */ |
| 466 | srep2->force_single_flush = 1; |
| 467 | osmo_stat_item_group_free(statg2); |
| 468 | send_count = 0; |
| 469 | osmo_stats_report(); |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 470 | OSMO_ASSERT(send_count == 4); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 471 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 472 | fprintf(stderr, "report (remove srep2):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 473 | /* force single flush */ |
| 474 | srep2->force_single_flush = 1; |
| 475 | osmo_stats_reporter_free(srep2); |
| 476 | send_count = 0; |
| 477 | osmo_stats_report(); |
| 478 | OSMO_ASSERT(send_count == 0); |
| 479 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 480 | fprintf(stderr, "report (remove ctrg2, should be empty):\n"); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 481 | rate_ctr_group_free(ctrg2); |
| 482 | send_count = 0; |
| 483 | osmo_stats_report(); |
| 484 | OSMO_ASSERT(send_count == 0); |
| 485 | |
Harald Welte | 04c8812 | 2017-10-03 18:34:48 +0800 | [diff] [blame] | 486 | rate_ctr_group_free(ctrg3); |
| 487 | |
Jacob Erlbeck | f13de86 | 2015-11-10 11:36:58 +0100 | [diff] [blame] | 488 | /* Leak check */ |
| 489 | OSMO_ASSERT(talloc_total_blocks(stats_ctx) == 1); |
| 490 | talloc_free(stats_ctx); |
| 491 | |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 492 | fprintf(stderr, "End test: %s\n", __func__); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 493 | } |
| 494 | |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 495 | int main(int argc, char **argv) |
| 496 | { |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 497 | void *ctx = talloc_named_const(NULL, 0, "main"); |
| 498 | osmo_init_logging2(ctx, NULL); |
| 499 | |
| 500 | log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); |
| 501 | log_set_print_level(osmo_stderr_target, 1); |
| 502 | log_set_print_category(osmo_stderr_target, 1); |
| 503 | log_set_print_category_hex(osmo_stderr_target, 0); |
| 504 | log_set_use_color(osmo_stderr_target, 0); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 505 | |
Jacob Erlbeck | fc9533d | 2015-10-29 00:55:58 +0100 | [diff] [blame] | 506 | osmo_stat_item_init(NULL); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 507 | |
| 508 | stat_test(); |
Jacob Erlbeck | 46b703d | 2015-11-09 17:25:27 +0100 | [diff] [blame] | 509 | test_reporting(); |
Oliver Smith | d89d35e | 2021-03-17 15:29:55 +0100 | [diff] [blame] | 510 | talloc_free(ctx); |
Jacob Erlbeck | 9732cb4 | 2015-10-01 20:43:53 +0200 | [diff] [blame] | 511 | return 0; |
| 512 | } |