Imported Upstream version 1.2.4
[archive/platform/upstream/libvirt.git] / tests / virsh-synopsis
1 #!/bin/sh
2 # ensure that each command's help "SYNOPSIS" line starts with the command name
3
4 # Copyright (C) 2008 Red Hat, Inc.
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see
18 # <http://www.gnu.org/licenses/>.
19
20 test -z "$srcdir" && srcdir=$(pwd)
21 test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
22 test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
23
24 if test "$VERBOSE" = yes; then
25   set -x
26   $abs_top_builddir/tools/virsh --version
27 fi
28
29 . "$srcdir/test-lib.sh"
30
31 fail=0
32
33 test_url=test:///default
34
35 $abs_top_builddir/tools/virsh -c $test_url help > cmds || framework_failure
36 cmds=$(sed -n 's/^    \([^ ][^ ]*\) .*/\1/p' cmds) || framework_failure
37 test -n "$cmds" || framework_failure
38
39 for i in $cmds; do
40     $abs_top_builddir/tools/virsh -c $test_url help $i > help || fail=1
41     grep -A1 '^  SYNOPSIS$' help > synopsis \
42       || { echo 1>&2 missing or invalid help SYNOPSIS for $i; fail=1; }
43     sed -n 2p synopsis > s2 || framework_failure
44     grep -E "^    $i( |$)" s2 > /dev/null \
45       || { echo 1>&2 "invalid help SYNOPSIS for $i:"; cat s2 1>&2; fail=1; }
46 done
47
48 (exit $fail); exit $fail