1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
#!/bin/sh
# PCP QA Test No. 1370
# Check long-options in manual pages.
#
# Copyright (c) 2021 Red Hat.
#
# check-group-exclude: pmrep pmpost
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
which man > /dev/null 2>&1 || _notrun "No man(1) command?"
man pmrep | grep -q 'performance metrics reporter' || _notrun "No man pages installed?"
status=1 # failure is the default!
hostname=`hostname`
trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
# need to check dpkg first, because if it is there, it is likely the
# one, as opposed to rpm which may be present, even on Debian machines
#
rm -f $tmp.cmds.txt
if which dpkg >/dev/null 2>&1
then
dpkg -l 2>>$seq_full | $PCP_AWK_PROG '$1 = "ii" && $2 ~ /pcp/ { print $2 }' | xargs dpkg -L | grep bin/ | sort | uniq > $tmp.cmds.txt
elif which rpm >/dev/null 2>&1
then
rpm -qa 2>>$seq_full | grep pcp | xargs rpm -ql | grep bin/ | grep -v 'debug$' | sort > $tmp.cmds.txt
fi
if [ ! -s $tmp.cmds.txt ]
then
_notrun "neither rpm nor dpkg seem to be your packaging command"
fi
# real QA test starts here
echo "collecting commands"
LC_COLLATE=POSIX; export LC_COLLATE
# don't bother for some commands, either they don't support --help
# (e.g. no options to describe) and/or are not intended for general
# use by a human end user and/or are aliases for other commands
#
for cmd in pcp-htop pcp-python pcp2csv pcp2xlsx pmafm pmgenmap \
pmie_dump_stats pmiestatus pmlock pmpause pmpython \
pmsleep pmwtf telnet-probe pmpost pcp-kube-pods \
pmie_farm pmlogger_farm pmlogger_janitor \
pcp-geolocate pcp-reboot-init pmcheck pmlogbasename \
pmdbg
do
sed -i "/$cmd/d" $tmp.cmds.txt
done
ncmd=`wc -l <$tmp.cmds.txt | sed -e 's/ *//'`
if [ "$ncmd" -lt 100 ]
then
echo "Warning: only found $ncmd candidate installed commands, expecting at least 100"
fi
# borrowed from _check_display()
# if we can't talk to an X server, there is no point running
# --help for the GUI apps
#
X11=true
if [ -z "$PCPQA_CLOSE_X_SERVER" ]
then
X11=false
fi
DISPLAY=$PCPQA_CLOSE_X_SERVER; export DISPLAY
if which xdpyinfo >/dev/null 2>&1
then
xdpyinfo >/dev/null 2>&1 || \
X11=false
fi
PCP_STDERR=$tmp.popup; export PCP_STDERR
echo "run checks"
for cmd in $(cat $tmp.cmds.txt); do
rm -f $tmp.test
bn=$(basename $cmd)
rm -f $tmp.popup
if ! $X11
then
case $cmd
in
*/pmchart|*/pmtime|*/pmconfirm|*/pmquery|*/pmclient_fg|*/pmmessage)
# for these ones --help will try to open a GUI popup or
# at least start an X11 client setup and without an X11
# server that ain't going to work
#
continue
;;
esac
fi
$cmd --help >$tmp.out 2>$tmp.err
[ -f $tmp.popup ] && cat $tmp.popup >>$tmp.err
# if --help is not understood, usually get the "unrecognized
# option" message, followed by the usage message
#
cat $tmp.out $tmp.err | grep 'unrecognized option'
cat $tmp.out $tmp.err \
| grep -Eo -- '--.*( | |$)' \
| sed \
-e '/unrecognized option/d' \
-e 's/=.*//g' \
-e 's/[ ].*//g' \
-e 's/]//g' \
-e 's/)//g' \
| LC_COLLATE=POSIX sort \
| uniq \
| grep -e '-[A-Za-z]' > $tmp.test
if ! grep -q -- -- $tmp.test; then
continue
fi
echo "=== $cmd ===" >>$seq_full
cat $tmp.test >>$seq_full
# run man(1) once, then grep away
man $bn >$tmp.man 2>$tmp.err
if [ -s $tmp.err ]
then
echo " == $cmd ... error output from man(1) ==="
cat $tmp.err
fi
for opt in $(cat $tmp.test); do
# some --help text is misleading, not really options following
# -- ... skip 'em
case "$bn"
in
pcp-atop)
[ X"$opt" = X--pcp-flags ] && continue
;;
pcp-xsos)
[ X"$opt" = X--start ] && continue
;;
pcp)
# all these long options are documented in PCPIntro(1)
# and pcp(1) points there, rather than repeating them
#
[ X"$opt" = X--align ] && continue
[ X"$opt" = X--finish ] && continue
[ X"$opt" = X--guimode ] && continue
[ X"$opt" = X--guiport ] && continue
[ X"$opt" = X--hostzone ] && continue
[ X"$opt" = X--interval ] && continue
[ X"$opt" = X--samples ] && continue
[ X"$opt" = X--start ] && continue
[ X"$opt" = X--timezone ] && continue
;;
pmproxy)
[ X"$opt" = X--redishost ] && continue
[ X"$opt" = X--redisport ] && continue
;;
esac
grep -q -- "$opt" <$tmp.man || echo "$bn.1 missing $opt"
done
rm -f $tmp.test
done
echo "checks done"
# success, all done
status=0
exit
|