23#include "gdbsupport/selftest.h"
31namespace help_doc_tests {
40 gdb_printf (
"help doc broken invariant: command '%s%s' help doc %s\n",
59 for (c = commandlist; c; c = c->
next)
62 const char *p = c->
doc;
65 while (*p && *p !=
'\n')
70 "is missing the first line terminated with a '.' character");
71 else if (*(p-1) !=
'.')
74 "first line is not terminated with a '.' character");
77 if (c->
doc[strlen (c->
doc) - 1] ==
'\n')
80 "has a superfluous trailing end of line");
106namespace command_structure_tests {
115static std::map<cmd_list_element **, const char *>
lists;
129 auto dupl =
lists.find (list);
130 if (dupl !=
lists.end ())
133 " reachable via prefix '%s' and '%s'."
134 " Duplicated list first command is '%s'\n",
146 if (*list ==
nullptr)
149 prefixcmd = (*list)->
prefix;
152 for (c = *list; c; c = c->
next)
162 if (prefixcmd != c->
prefix
163 || (prefixcmd ==
nullptr && *list !=
cmdlist))
166 gdb_printf (
"list %p reachable via prefix '%s'."
167 " command '%s' has null prefixcmd\n",
171 gdb_printf (
"list %p reachable via prefix '%s'."
172 " command '%s' has a different prefixcmd\n",
205 selftests::register_test
206 (
"help_doc_invariants",
209 selftests::register_test
210 (
"command_structure_invariants",
struct cmd_list_element * cmdlist
void _initialize_command_def_selftests()
static void traverse_command_structure(struct cmd_list_element **list, const char *prefix)
static std::map< cmd_list_element **, const char * > lists
static unsigned int nr_invalid_prefixcmd
static void command_structure_invariants_tests()
static unsigned int nr_duplicates
static void help_doc_invariants_tests()
static void broken_doc_invariant(const char *prefix, const char *name, const char *msg)
static void check_doc(struct cmd_list_element *commandlist, const char *prefix)
static unsigned int nr_failed_invariants
#define prefix(a, b, R, do)
std::string prefixname() const
struct cmd_list_element ** subcommands
struct cmd_list_element * prefix
struct cmd_list_element * next
void gdb_printf(struct ui_file *stream, const char *format,...)