提交 d920090c 编写于 作者: M Michal Privoznik

virsh: Move cmdSelfTest to vsh

This command should be exposed to other shells of ours.
They are gonna need it as soon as we want to test them too.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 64bc75f7
...@@ -346,44 +346,6 @@ virshConnectionHandler(vshControl *ctl) ...@@ -346,44 +346,6 @@ virshConnectionHandler(vshControl *ctl)
return NULL; return NULL;
} }
/* -----------------
* Command self-test
* ----------------- */
static const vshCmdInfo info_selftest[] = {
{.name = "help",
.data = N_("internal command for testing virsh")
},
{.name = "desc",
.data = N_("internal use only")
},
{.name = NULL}
};
/* Prints help for every command.
* That runs vshCmddefOptParse which validates
* the per-command options structure. */
static bool
cmdSelfTest(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
const vshCmdGrp *grp;
const vshCmdDef *def;
vshPrint(ctl, "Do not use the following output:\n\n");
for (grp = cmdGroups; grp->name; grp++) {
for (def = grp->commands; def->name; def++) {
if (def->flags & VSH_CMD_FLAG_ALIAS)
continue;
if (!vshCmddefHelp(ctl, def->name))
return false;
}
}
return true;
}
/* --------------- /* ---------------
* Misc utils * Misc utils
...@@ -894,18 +856,13 @@ static const vshCmdDef virshCmds[] = { ...@@ -894,18 +856,13 @@ static const vshCmdDef virshCmds[] = {
VSH_CMD_HELP, VSH_CMD_HELP,
VSH_CMD_PWD, VSH_CMD_PWD,
VSH_CMD_QUIT, VSH_CMD_QUIT,
VSH_CMD_SELF_TEST,
{.name = "connect", {.name = "connect",
.handler = cmdConnect, .handler = cmdConnect,
.opts = opts_connect, .opts = opts_connect,
.info = info_connect, .info = info_connect,
.flags = VSH_CMD_FLAG_NOCONNECT .flags = VSH_CMD_FLAG_NOCONNECT
}, },
{.name = "self-test",
.handler = cmdSelfTest,
.opts = NULL,
.info = info_selftest,
.flags = VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_ALIAS
},
{.name = NULL} {.name = NULL}
}; };
......
...@@ -3328,3 +3328,41 @@ cmdQuit(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ...@@ -3328,3 +3328,41 @@ cmdQuit(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
ctl->imode = false; ctl->imode = false;
return true; return true;
} }
/* -----------------
* Command self-test
* ----------------- */
const vshCmdInfo info_selftest[] = {
{.name = "help",
.data = N_("internal command for testing virt shells")
},
{.name = "desc",
.data = N_("internal use only")
},
{.name = NULL}
};
/* Prints help for every command.
* That runs vshCmddefOptParse which validates
* the per-command options structure. */
bool
cmdSelfTest(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
const vshCmdGrp *grp;
const vshCmdDef *def;
vshPrint(ctl, "Do not use the following output:\n\n");
for (grp = cmdGroups; grp->name; grp++) {
for (def = grp->commands; def->name; def++) {
if (def->flags & VSH_CMD_FLAG_ALIAS)
continue;
if (!vshCmddefHelp(ctl, def->name))
return false;
}
}
return true;
}
...@@ -376,12 +376,14 @@ extern const vshCmdOptDef opts_echo[]; ...@@ -376,12 +376,14 @@ extern const vshCmdOptDef opts_echo[];
extern const vshCmdInfo info_echo[]; extern const vshCmdInfo info_echo[];
extern const vshCmdInfo info_pwd[]; extern const vshCmdInfo info_pwd[];
extern const vshCmdInfo info_quit[]; extern const vshCmdInfo info_quit[];
extern const vshCmdInfo info_selftest[];
bool cmdHelp(vshControl *ctl, const vshCmd *cmd); bool cmdHelp(vshControl *ctl, const vshCmd *cmd);
bool cmdCd(vshControl *ctl, const vshCmd *cmd); bool cmdCd(vshControl *ctl, const vshCmd *cmd);
bool cmdEcho(vshControl *ctl, const vshCmd *cmd); bool cmdEcho(vshControl *ctl, const vshCmd *cmd);
bool cmdPwd(vshControl *ctl, const vshCmd *cmd); bool cmdPwd(vshControl *ctl, const vshCmd *cmd);
bool cmdQuit(vshControl *ctl, const vshCmd *cmd); bool cmdQuit(vshControl *ctl, const vshCmd *cmd);
bool cmdSelfTest(vshControl *ctl, const vshCmd *cmd);
# define VSH_CMD_CD \ # define VSH_CMD_CD \
{ \ { \
...@@ -437,6 +439,15 @@ bool cmdQuit(vshControl *ctl, const vshCmd *cmd); ...@@ -437,6 +439,15 @@ bool cmdQuit(vshControl *ctl, const vshCmd *cmd);
.flags = VSH_CMD_FLAG_NOCONNECT \ .flags = VSH_CMD_FLAG_NOCONNECT \
} }
# define VSH_CMD_SELF_TEST \
{ \
.name = "self-test", \
.handler = cmdSelfTest, \
.opts = NULL, \
.info = info_selftest, \
.flags = VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_ALIAS \
}
/* readline */ /* readline */
char * vshReadline(vshControl *ctl, const char *prompt); char * vshReadline(vshControl *ctl, const char *prompt);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册