]>
git.proxmox.com Git - mirror_frr.git/blob - tests/lib/cli/common_cli.c
2 * generic CLI test helper functions
4 * Copyright (C) 2015 by David Lamparter,
5 * for Open Source Routing / NetDEF, Inc.
7 * Quagga is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * Quagga is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include "common_cli.h"
33 struct thread_master
*master
;
35 int dump_args(struct vty
*vty
, const char *descr
, int argc
,
36 struct cmd_token
*argv
[])
39 vty_out(vty
, "%s with %d args.\n", descr
, argc
);
40 for (i
= 0; i
< argc
; i
++) {
41 vty_out(vty
, "[%02d] %s@%s: %s\n", i
, argv
[i
]->text
,
42 argv
[i
]->varname
, argv
[i
]->arg
);
48 static void vty_do_exit(int isexit
)
55 thread_master_free(master
);
57 log_memstats(stderr
, "testcli");
62 const struct frr_yang_module_info
*const *test_yang_modules
= NULL
;
63 int test_log_prio
= ZLOG_DISABLED
;
66 int main(int argc
, char **argv
)
71 /* Set umask before anything for security */
75 master
= thread_master_create(NULL
);
77 zlog_aux_init("NONE: ", test_log_prio
);
81 cmd_hostname_set("test");
82 cmd_domainname_set("test.domain");
84 vty_init(master
, false);
87 for (yangcount
= 0; test_yang_modules
&& test_yang_modules
[yangcount
];
90 nb_init(master
, test_yang_modules
, yangcount
, false);
92 test_init(argc
, argv
);
94 vty_stdio(vty_do_exit
);
96 /* Fetch next active thread. */
97 while (thread_fetch(master
, &thread
))