blob: 42646eb48109d78cece5e743cb0ab4e0f096780f [file] [log] [blame]
Harald Weltee08da972017-11-13 01:00:26 +09001/* (C) 2013 by sysmocom - s.f.m.c. GmbH, Author: Jacob Erlbeck <jerlbeck@sysmocom.de>
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +02002 * All Rights Reserved
3 *
Harald Weltee08da972017-11-13 01:00:26 +09004 * SPDX-License-Identifier: GPL-2.0+
5 *
6 * This program is free software; you can redistribute it and/or modify
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +02007 * it under the terms of the GNU General Public License as published by
Harald Weltee08da972017-11-13 01:00:26 +09008 * the Free Software Foundation; either version 2 of the License, or
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +02009 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 */
21
22#include <stdio.h>
23#include <string.h>
Neels Hofmeyr4a31ffa2017-09-07 03:08:06 +020024#include <errno.h>
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +020025
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +020026#include <sys/types.h>
27#include <sys/socket.h>
28#include <sys/un.h>
29
Holger Hans Peter Freyther6ef71b02013-09-10 11:17:46 +020030#include <osmocom/core/application.h>
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +020031#include <osmocom/core/talloc.h>
32#include <osmocom/core/logging.h>
Jacob Erlbeckbe37fb72015-11-03 15:21:34 +010033#include <osmocom/core/stats.h>
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +020034#include <osmocom/core/utils.h>
Holger Hans Peter Freyther2c9168c2013-10-10 20:21:33 +020035#include <osmocom/core/signal.h>
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +020036#include <osmocom/vty/misc.h>
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +020037#include <osmocom/vty/vty.h>
38#include <osmocom/vty/command.h>
39#include <osmocom/vty/buffer.h>
Holger Hans Peter Freyther6ef71b02013-09-10 11:17:46 +020040#include <osmocom/vty/logging.h>
Jacob Erlbeckbe37fb72015-11-03 15:21:34 +010041#include <osmocom/vty/stats.h>
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +020042
43static enum event last_vty_connection_event = -1;
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +020044
45static void test_cmd_string_from_valstr(void)
46{
47 char *cmd;
48 const struct value_string printf_seq_vs[] = {
49 { .value = 42, .str = "[foo%s%s%s%s%s]"},
50 { .value = 43, .str = "[bar%s%s%s%s%s]"},
51 { .value = 0, .str = NULL}
52 };
53
54 printf("Going to test vty_cmd_string_from_valstr()\n");
55
56 /* check against character strings that could break printf */
57
58 cmd = vty_cmd_string_from_valstr (NULL, printf_seq_vs, "[prefix%s%s%s%s%s]", "[sep%s%s%s%s%s]", "[end%s%s%s%s%s]", 1);
59 printf ("Tested with %%s-strings, resulting cmd = '%s'\n", cmd);
60 talloc_free (cmd);
61}
62
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +020063static int do_vty_command(struct vty *vty, const char *cmd)
64{
65 vector vline;
66 int ret;
67
68 printf("Going to execute '%s'\n", cmd);
69 vline = cmd_make_strvec(cmd);
70 ret = cmd_execute_command(vline, vty, NULL, 0);
71 cmd_free_strvec(vline);
72 printf("Returned: %d, Current node: %d '%s'\n", ret, vty->node, cmd_prompt(vty->node));
73 return ret;
74}
75
Holger Hans Peter Freyther2c9168c2013-10-10 20:21:33 +020076/* Handle the events from telnet_interface.c */
77static int vty_event_cb(unsigned int subsys, unsigned int signal,
78 void *handler_data, void *_signal_data)
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +020079{
Holger Hans Peter Freyther2c9168c2013-10-10 20:21:33 +020080 struct vty_signal_data *signal_data;
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +020081
Holger Hans Peter Freyther2c9168c2013-10-10 20:21:33 +020082 if (subsys != SS_L_VTY)
83 return 0;
84 if (signal != S_VTY_EVENT)
85 return 0;
86
87 signal_data = _signal_data;
88 last_vty_connection_event = signal_data->event;
89
90 fprintf(stderr, "Got VTY event: %d\n", signal_data->event);
91 return 0;
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +020092}
93
Jacob Erlbeckca6602f2015-11-03 13:47:11 +010094struct vty_test {
95 int sock[2];
96};
97
98static struct vty* create_test_vty(struct vty_test *data)
99{
100 struct vty *vty;
101 /* Fake connection. */
102 socketpair(AF_UNIX, SOCK_STREAM, 0, data->sock);
103
104 vty = vty_create(data->sock[0], NULL);
105 OSMO_ASSERT(vty != NULL);
106 OSMO_ASSERT(vty->status != VTY_CLOSE);
107
108 return vty;
109}
110
111static void destroy_test_vty(struct vty_test *data, struct vty *vty)
112{
113 vty_close(vty);
114 OSMO_ASSERT(last_vty_connection_event == VTY_CLOSED);
115}
116
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +0200117static void test_node_tree_structure(void)
118{
Jacob Erlbeckca6602f2015-11-03 13:47:11 +0100119 struct vty_test test;
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +0200120 struct vty *vty;
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +0200121
122 printf("Going to test VTY node tree structure\n");
Jacob Erlbeckca6602f2015-11-03 13:47:11 +0100123 vty = create_test_vty(&test);
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +0200124
125 OSMO_ASSERT(do_vty_command(vty, "enable") == CMD_SUCCESS);
126 OSMO_ASSERT(vty->node == ENABLE_NODE);
127
128 OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS);
129 OSMO_ASSERT(vty->node == CONFIG_NODE);
130 OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS);
131 OSMO_ASSERT(vty->node == ENABLE_NODE);
132
133 OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS);
134 OSMO_ASSERT(vty->node == CONFIG_NODE);
135 OSMO_ASSERT(do_vty_command(vty, "end") == CMD_SUCCESS);
136 OSMO_ASSERT(vty->node == ENABLE_NODE);
137
138 OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS);
139 OSMO_ASSERT(vty->node == CONFIG_NODE);
140 OSMO_ASSERT(do_vty_command(vty, "log stderr") == CMD_SUCCESS);
141 OSMO_ASSERT(vty->node == CFG_LOG_NODE);
142 OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS);
143 OSMO_ASSERT(vty->node == CONFIG_NODE);
144 OSMO_ASSERT(do_vty_command(vty, "log stderr") == CMD_SUCCESS);
145 OSMO_ASSERT(vty->node == CFG_LOG_NODE);
146 OSMO_ASSERT(do_vty_command(vty, "end") == CMD_SUCCESS);
147 OSMO_ASSERT(vty->node == ENABLE_NODE);
148
149 OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS);
150 OSMO_ASSERT(vty->node == CONFIG_NODE);
151 OSMO_ASSERT(do_vty_command(vty, "line vty") == CMD_SUCCESS);
152 OSMO_ASSERT(vty->node == VTY_NODE);
153 OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS);
154 OSMO_ASSERT(vty->node == CONFIG_NODE);
155 OSMO_ASSERT(do_vty_command(vty, "line vty") == CMD_SUCCESS);
156 OSMO_ASSERT(vty->node == VTY_NODE);
157 OSMO_ASSERT(do_vty_command(vty, "end") == CMD_SUCCESS);
158 OSMO_ASSERT(vty->node == ENABLE_NODE);
159
160
Neels Hofmeyrd64b6ae2017-09-07 04:52:05 +0200161 /* Check for not searching the parent node for matching commands. */
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +0200162 OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS);
163 OSMO_ASSERT(vty->node == CONFIG_NODE);
164 OSMO_ASSERT(do_vty_command(vty, "log stderr") == CMD_SUCCESS);
165 OSMO_ASSERT(vty->node == CFG_LOG_NODE);
Neels Hofmeyrd64b6ae2017-09-07 04:52:05 +0200166 OSMO_ASSERT(do_vty_command(vty, "line vty") == CMD_ERR_NO_MATCH);
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +0200167 OSMO_ASSERT(vty->node == CFG_LOG_NODE);
168 OSMO_ASSERT(do_vty_command(vty, "end") == CMD_SUCCESS);
169 OSMO_ASSERT(vty->node == ENABLE_NODE);
170
171 /* Check for final 'exit' (connection close). */
172 OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS);
173 OSMO_ASSERT(vty->node == ENABLE_NODE);
174 OSMO_ASSERT(vty->status == VTY_CLOSE);
175
Jacob Erlbeckca6602f2015-11-03 13:47:11 +0100176 destroy_test_vty(&test, vty);
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +0200177}
178
Jacob Erlbeckbe37fb72015-11-03 15:21:34 +0100179static void check_srep_vty_config(struct vty* vty,
180 struct osmo_stats_reporter *srep)
181{
182 OSMO_ASSERT(srep->enabled == 0);
183
184 OSMO_ASSERT(do_vty_command(vty, "prefix myprefix") == CMD_SUCCESS);
185 OSMO_ASSERT(srep->name_prefix != NULL);
186 OSMO_ASSERT(strcmp(srep->name_prefix, "myprefix") == 0);
187 OSMO_ASSERT(do_vty_command(vty, "no prefix") == CMD_SUCCESS);
188 OSMO_ASSERT(srep->name_prefix == NULL || strlen(srep->name_prefix) == 0);
189
190 OSMO_ASSERT(srep->max_class == OSMO_STATS_CLASS_GLOBAL);
191 OSMO_ASSERT(do_vty_command(vty, "level peer") == CMD_SUCCESS);
192 OSMO_ASSERT(srep->max_class == OSMO_STATS_CLASS_PEER);
193 OSMO_ASSERT(do_vty_command(vty, "level subscriber") == CMD_SUCCESS);
194 OSMO_ASSERT(srep->max_class == OSMO_STATS_CLASS_SUBSCRIBER);
195 OSMO_ASSERT(do_vty_command(vty, "level global") == CMD_SUCCESS);
196 OSMO_ASSERT(srep->max_class == OSMO_STATS_CLASS_GLOBAL);
197 OSMO_ASSERT(do_vty_command(vty, "level foobar") == CMD_ERR_NO_MATCH);
198
199 if (srep->have_net_config) {
200 OSMO_ASSERT(do_vty_command(vty, "remote-ip 127.0.0.99") ==
201 CMD_SUCCESS);
202 OSMO_ASSERT(srep->dest_addr_str &&
203 strcmp(srep->dest_addr_str, "127.0.0.99") == 0);
204 OSMO_ASSERT(do_vty_command(vty, "remote-ip 678.0.0.99") ==
205 CMD_WARNING);
206 OSMO_ASSERT(srep->dest_addr_str &&
207 strcmp(srep->dest_addr_str, "127.0.0.99") == 0);
208
209 OSMO_ASSERT(do_vty_command(vty, "remote-port 12321") ==
210 CMD_SUCCESS);
211 OSMO_ASSERT(srep->dest_port == 12321);
212
213 OSMO_ASSERT(srep->bind_addr_str == NULL);
214 OSMO_ASSERT(do_vty_command(vty, "local-ip 127.0.0.98") ==
215 CMD_SUCCESS);
216 OSMO_ASSERT(srep->bind_addr_str &&
217 strcmp(srep->bind_addr_str, "127.0.0.98") == 0);
218 OSMO_ASSERT(do_vty_command(vty, "no local-ip") == CMD_SUCCESS);
219 OSMO_ASSERT(srep->bind_addr_str == NULL);
220
221 OSMO_ASSERT(srep->mtu == 0);
222 OSMO_ASSERT(do_vty_command(vty, "mtu 987") == CMD_SUCCESS);
223 OSMO_ASSERT(srep->mtu == 987);
224 OSMO_ASSERT(do_vty_command(vty, "no mtu") == CMD_SUCCESS);
225 OSMO_ASSERT(srep->mtu == 0);
226 };
227
228 OSMO_ASSERT(do_vty_command(vty, "enable") == CMD_SUCCESS);
229 OSMO_ASSERT(srep->enabled != 0);
230 OSMO_ASSERT(do_vty_command(vty, "disable") == CMD_SUCCESS);
231 OSMO_ASSERT(srep->enabled == 0);
232}
233
234static void test_stats_vty(void)
235{
236 struct osmo_stats_reporter *srep;
237 struct vty_test test;
238 struct vty *vty;
239
240 printf("Going to test VTY configuration of the stats subsystem\n");
241 vty = create_test_vty(&test);
242
243 /* Go to config node */
244 OSMO_ASSERT(do_vty_command(vty, "enable") == CMD_SUCCESS);
245 OSMO_ASSERT(vty->node == ENABLE_NODE);
246 OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS);
247 OSMO_ASSERT(vty->node == CONFIG_NODE);
248
249 /* Try to create invalid reporter */
250 OSMO_ASSERT(do_vty_command(vty, "stats reporter foobar") ==
251 CMD_ERR_NO_MATCH);
252
253 /* Set reporting interval */
254 OSMO_ASSERT(do_vty_command(vty, "stats interval 42") == CMD_SUCCESS);
255 OSMO_ASSERT(osmo_stats_config->interval == 42);
256
257 /* Create log reporter */
258 srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_LOG, NULL);
259 OSMO_ASSERT(srep == NULL);
260 OSMO_ASSERT(do_vty_command(vty, "stats reporter log") == CMD_SUCCESS);
261 OSMO_ASSERT(vty->node == CFG_STATS_NODE);
262 srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_LOG, NULL);
263 OSMO_ASSERT(srep != NULL);
264 OSMO_ASSERT(srep->type == OSMO_STATS_REPORTER_LOG);
265 check_srep_vty_config(vty, srep);
266 OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS);
267 OSMO_ASSERT(vty->node == CONFIG_NODE);
268
269 /* Create statsd reporter */
270 srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_STATSD, NULL);
271 OSMO_ASSERT(srep == NULL);
272 OSMO_ASSERT(do_vty_command(vty, "stats reporter statsd") == CMD_SUCCESS);
273 OSMO_ASSERT(vty->node == CFG_STATS_NODE);
274 srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_STATSD, NULL);
275 OSMO_ASSERT(srep != NULL);
276 OSMO_ASSERT(srep->type == OSMO_STATS_REPORTER_STATSD);
277 check_srep_vty_config(vty, srep);
278 OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS);
279 OSMO_ASSERT(vty->node == CONFIG_NODE);
280
281 /* Destroy log reporter */
282 OSMO_ASSERT(osmo_stats_reporter_find(OSMO_STATS_REPORTER_LOG, NULL));
283 OSMO_ASSERT(do_vty_command(vty, "no stats reporter log") == CMD_SUCCESS);
284 OSMO_ASSERT(!osmo_stats_reporter_find(OSMO_STATS_REPORTER_LOG, NULL));
285
286 /* Destroy statsd reporter */
287 OSMO_ASSERT(osmo_stats_reporter_find(OSMO_STATS_REPORTER_STATSD, NULL));
288 OSMO_ASSERT(do_vty_command(vty, "no stats reporter statsd") == CMD_SUCCESS);
289 OSMO_ASSERT(!osmo_stats_reporter_find(OSMO_STATS_REPORTER_STATSD, NULL));
290
291 destroy_test_vty(&test, vty);
292}
293
Neels Hofmeyr4a31ffa2017-09-07 03:08:06 +0200294void test_exit_by_indent(const char *fname, int expect_rc)
295{
296 int rc;
297 printf("reading file %s, expecting rc=%d\n", fname, expect_rc);
298 rc = vty_read_config_file(fname, NULL);
299 printf("got rc=%d\n", rc);
300 OSMO_ASSERT(rc == expect_rc);
301}
302
Neels Hofmeyrb022c862017-09-20 01:49:11 +0200303enum test_nodes {
304 LEVEL1_NODE = _LAST_OSMOVTY_NODE + 1,
305 LEVEL2_NODE,
306 LEVEL3_NODE,
307};
308
309struct cmd_node level1_node = {
310 LEVEL1_NODE,
311 "%s(config-level1)# ",
312 1
313};
314
315struct cmd_node level2_node = {
316 LEVEL2_NODE,
317 "%s(config-level1-level2)# ",
318 1
319};
320
321struct cmd_node level3_node = {
322 LEVEL3_NODE,
323 "%s(config-level1-level2-level3)# ",
324 1
325};
326
327DEFUN(cfg_level1, cfg_level1_cmd,
328 "level1 [MARKER]",
329 "Level 1 node for VTY testing purposes\n"
330 "optional string to mark the line for test debugging\n")
331{
332 vty->index = NULL;
333 vty->node = LEVEL1_NODE;
334 printf("called level1 node %s\n", argc? argv[0] : "");
335 return CMD_SUCCESS;
336}
337
338DEFUN(cfg_level1_child, cfg_level1_child_cmd,
339 "child1 [MARKER]",
340 "Level 1 child cmd for VTY testing purposes\n"
341 "optional string to mark the line for test debugging\n")
342{
343 printf("called level1 child cmd %s\n", argc? argv[0] : "");
344 return CMD_SUCCESS;
345}
346
347DEFUN(cfg_level2, cfg_level2_cmd,
348 "level2 [MARKER]",
349 "Level 2 node for VTY testing purposes\n"
350 "optional string to mark the line for test debugging\n")
351{
352 vty->index = NULL;
353 vty->node = LEVEL2_NODE;
354 printf("called level2 node %s\n", argc? argv[0] : "");
355 return CMD_SUCCESS;
356}
357
358DEFUN(cfg_level2_child, cfg_level2_child_cmd,
359 "child2 [MARKER]",
360 "Level 2 child cmd for VTY testing purposes\n"
361 "optional string to mark the line for test debugging\n")
362{
363 printf("called level2 child cmd %s\n", argc? argv[0] : "");
364 return CMD_SUCCESS;
365}
366
367DEFUN(cfg_level3, cfg_level3_cmd,
368 "level3 [MARKER]",
369 "Level 3 node for VTY testing purposes\n"
370 "optional string to mark the line for test debugging\n")
371{
372 vty->index = NULL;
373 vty->node = LEVEL3_NODE;
374 printf("called level3 node %s\n", argc? argv[0] : "");
375 return CMD_SUCCESS;
376}
377
378DEFUN(cfg_level3_child, cfg_level3_child_cmd,
379 "child3 [MARKER]",
380 "Level 3 child cmd for VTY testing purposes\n"
381 "optional string to mark the line for test debugging\n")
382{
383 printf("called level3 child cmd %s\n", argc? argv[0] : "");
384 return CMD_SUCCESS;
385}
386
387void test_vty_add_cmds()
388{
389 install_element(CONFIG_NODE, &cfg_level1_cmd);
390 install_node(&level1_node, NULL);
Neels Hofmeyrb022c862017-09-20 01:49:11 +0200391 install_element(LEVEL1_NODE, &cfg_level1_child_cmd);
392 install_element(LEVEL1_NODE, &cfg_level2_cmd);
393
394 install_node(&level2_node, NULL);
Neels Hofmeyrb022c862017-09-20 01:49:11 +0200395 install_element(LEVEL2_NODE, &cfg_level2_child_cmd);
396 install_element(LEVEL2_NODE, &cfg_level3_cmd);
397
398 install_node(&level3_node, NULL);
Neels Hofmeyrb022c862017-09-20 01:49:11 +0200399 install_element(LEVEL3_NODE, &cfg_level3_child_cmd);
400}
401
402static int go_parent_cb(struct vty *vty)
403{
404 /*
405 * - For the interactive VTY tests above, it is expected to bounce back to
406 * the CONFIG_NODE. Hence do so in go_parent_cb().
407 * - In the config file parsing tests, setting vty->node in go_parent_cb() has no
408 * effect, because we will subsequently pop a parent node from the parent stack
409 * and override to go to the node that was recorded as the actual parent.
410 */
411 vty->node = CONFIG_NODE;
412 vty->index = NULL;
413 return 0;
414}
415
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +0200416int main(int argc, char **argv)
417{
Jacob Erlbeckca6602f2015-11-03 13:47:11 +0100418 struct vty_app_info vty_info = {
419 .name = "VtyTest",
420 .version = 0,
Neels Hofmeyrb022c862017-09-20 01:49:11 +0200421 .go_parent_cb = go_parent_cb,
Jacob Erlbeckca6602f2015-11-03 13:47:11 +0100422 .is_config_node = NULL,
423 };
424
425 const struct log_info_cat default_categories[] = {};
426
427 const struct log_info log_info = {
428 .cat = default_categories,
429 .num_cat = ARRAY_SIZE(default_categories),
430 };
Jacob Erlbeckbe37fb72015-11-03 15:21:34 +0100431 void *stats_ctx = talloc_named_const(NULL, 1, "stats test context");
432
Holger Hans Peter Freyther2c9168c2013-10-10 20:21:33 +0200433 osmo_signal_register_handler(SS_L_VTY, vty_event_cb, NULL);
434
Jacob Erlbeckca6602f2015-11-03 13:47:11 +0100435 /* Fake logging. */
436 osmo_init_logging(&log_info);
437
Jacob Erlbeckbe37fb72015-11-03 15:21:34 +0100438 /* Init stats */
439 osmo_stats_init(stats_ctx);
440
Jacob Erlbeckca6602f2015-11-03 13:47:11 +0100441 vty_init(&vty_info);
442
443 /* Setup VTY commands */
Maxc65c5b42017-03-15 13:20:23 +0100444 logging_vty_add_cmds();
Jacob Erlbeckbe37fb72015-11-03 15:21:34 +0100445 osmo_stats_vty_add_cmds();
Jacob Erlbeckca6602f2015-11-03 13:47:11 +0100446
Neels Hofmeyrb022c862017-09-20 01:49:11 +0200447 test_vty_add_cmds();
448
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +0200449 test_cmd_string_from_valstr();
Jacob Erlbeck0c987bd2013-09-06 16:52:00 +0200450 test_node_tree_structure();
Jacob Erlbeckbe37fb72015-11-03 15:21:34 +0100451 test_stats_vty();
Neels Hofmeyr4a31ffa2017-09-07 03:08:06 +0200452 test_exit_by_indent("ok.cfg", 0);
453 test_exit_by_indent("ok_more_spaces.cfg", 0);
454 test_exit_by_indent("ok_tabs.cfg", 0);
455 test_exit_by_indent("ok_tabs_and_spaces.cfg", 0);
456 test_exit_by_indent("ok_ignore_comment.cfg", 0);
457 test_exit_by_indent("ok_ignore_blank.cfg", 0);
458 test_exit_by_indent("fail_not_de-indented.cfg", -EINVAL);
459 test_exit_by_indent("fail_too_much_indent.cfg", -EINVAL);
460 test_exit_by_indent("fail_tabs_and_spaces.cfg", -EINVAL);
461 test_exit_by_indent("ok_indented_root.cfg", 0);
Neels Hofmeyr43063632017-09-19 23:54:01 +0200462 test_exit_by_indent("ok_empty_parent.cfg", 0);
Jacob Erlbeckbe37fb72015-11-03 15:21:34 +0100463
464 /* Leak check */
465 OSMO_ASSERT(talloc_total_blocks(stats_ctx) == 1);
Jacob Erlbeckca6602f2015-11-03 13:47:11 +0100466
Jacob Erlbeckae15a2c2013-08-06 14:29:14 +0200467 printf("All tests passed\n");
468
469 return 0;
470}