Re: [PATCH 3/6] Introduce virsh self-test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 17, 2016 at 20:04:38 +0200, Ján Tomko wrote:
> A new hidden command for virsh that will iterate over
> all command groups and commands and print help for every single one.
> 
> This involves running vshCmddefOptParse so we can get an error if
> one of the command's option structure is invalid.
> ---
>  .gitignore            |  1 +
>  tests/Makefile.am     |  1 +
>  tests/virsh-self-test | 37 +++++++++++++++++++++++++++++++++++++
>  tools/virsh.c         | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 89 insertions(+)
>  create mode 100755 tests/virsh-self-test
> 
> diff --git a/tests/virsh-self-test b/tests/virsh-self-test
> new file mode 100755
> index 0000000..42e8605
> --- /dev/null
> +++ b/tests/virsh-self-test
> @@ -0,0 +1,37 @@
> +#!/bin/sh
> +# run virsh self-test to make sure command option structures are valid
> +
> +# Copyright (C) 2008, 2009 Red Hat, Inc.

This year doesn't look correct

> +
> +# This program is free software: you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, either version 2 of the License, or
> +# (at your option) any later version.
> +
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see
> +# <http://www.gnu.org/licenses/>.
> +
> +. "$(dirname $0)/test-lib.sh"
> +
> +fail=0
> +
> +test_url=test:///default
> +
> +test_intro "virsh-self-test"
> +$abs_top_builddir/tools/virsh -c $test_url self-test > /dev/null
> +status=$?
> +test_result 1 "virsh-self-test" $status
> +
> +if test "$status" = "1" ; then
> +   fail=1
> +fi
> +
> +test_final $counter $fail
> +
> +(exit $fail); exit $fail
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 2a807d9..8eb05d3 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -341,6 +341,50 @@ virshConnectionHandler(vshControl *ctl)
>      return NULL;
>  }
>  
> +/* -----------------
> + * Command self-test
> + * ----------------- */
> +
> +static const vshCmdInfo info_selftest[] = {
> +    {.name = "help",
> +     .data = N_("internal command for testing virsh")
> +    },
> +    {.name = "desc",
> +     .data = N_("This message should not be output.")

$ tools/virsh self-test --help
  NAME
    self-test - internal command for testing virsh

  SYNOPSIS
    self-test

  DESCRIPTION
    This message should not be output.

I'd go with "DO NOT USE THIS COMMAND", or "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;
> +    /*
> +    const char *blacklist [] = {
> +        "self-test",
> +        "connect"
> +    }; */

You probably forgot to delete this.

> +
> +    vshPrint(ctl, "%s", _("Grouped commands:\n\n"));

This doesn't look necessary. Perhaps you could change it to a warning
that this output shouldn't be used.

> +
> +    for (grp = cmdGroups; grp->name; grp++) {
> +        for (def = grp->commands; def->name; def++) {
> +            if (def->flags & VSH_CMD_FLAG_ALIAS)
> +                continue;

ACK

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]