]>
git.proxmox.com Git - mirror_frr.git/blob - tests/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
18 * along with Quagga; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
29 #include "memory_vty.h"
32 #include "common-cli.h"
34 struct thread_master
*master
;
36 int dump_args(struct vty
*vty
, const char *descr
,
37 int argc
, struct cmd_token
*argv
[])
40 vty_out (vty
, "%s with %d args.%s", descr
, argc
, VTY_NEWLINE
);
41 for (i
= 0; i
< argc
; i
++)
43 vty_out (vty
, "[%02d]: %s%s", i
, argv
[i
]->arg
, VTY_NEWLINE
);
49 static void vty_do_exit(void)
54 thread_master_free (master
);
55 closezlog (zlog_default
);
57 log_memstats_stderr ("testcli");
63 main (int argc
, char **argv
)
67 /* Set umask before anything for security */
71 master
= thread_master_create ();
73 zlog_default
= openzlog ("common-cli", ZLOG_NONE
, 0,
74 LOG_CONS
|LOG_NDELAY
|LOG_PID
, LOG_DAEMON
);
75 zlog_set_level (NULL
, ZLOG_DEST_SYSLOG
, ZLOG_DISABLED
);
76 zlog_set_level (NULL
, ZLOG_DEST_STDOUT
, ZLOG_DISABLED
);
77 zlog_set_level (NULL
, ZLOG_DEST_MONITOR
, LOG_DEBUG
);
81 cmd_hostname_set ("test");
88 vty_stdio (vty_do_exit
);
90 /* Fetch next active thread. */
91 while (thread_fetch (master
, &thread
))
92 thread_call (&thread
);