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
|
#!/bin/sh
# PCP QA Test No. 1100
# bash shell completion check (see 967 for zsh version)
#
# Copyright (c) 2017 Red Hat.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.python
. ./common.config
_check_display
echo "DISPLAY=$DISPLAY" >>$seq_full
echo "PCPQA_CLOSE_X_SERVER=$PCPQA_CLOSE_X_SERVER" >>$seq_full
[ $PCP_PLATFORM = linux ] || _notrun "Test needs to run only on Linux"
status=1 # failure is the default!
trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
PCP_STDERR=$tmp.err; export PCP_STDERR
# these may not be available if needed modules missing
#
skip_pcp2elasticsearch=false
$python -c "import requests" >/dev/null 2>&1
[ $? -eq 0 ] || skip_pcp2elasticsearch=true
skip_pcp2xlsx=false
$python -c "import openpyxl" >/dev/null 2>&1
[ $? -eq 0 ] || skip_pcp2xlsx=true
skip_pmrep=false
$python -c "from collections import OrderedDict" >/dev/null 2>&1
if [ $? -ne 0 ]; then
skip_pcp2elasticsearch=true
skip_pcp2graphite=true
skip_pcp2influxdb=true
skip_pcp2json=true
skip_pcp2spark=true
skip_pcp2xlsx=true
skip_pcp2xml=true
skip_pcp2zabbix=true
skip_pmrep=true
fi
# these may not be available if X11 display is missing
#
skip_pmchart=false
which xdpyinfo >/dev/null 2>&1
if [ $? -eq 0 ]
then
xdpyinfo >/dev/null 2>&1
[ $? -eq 0 ] || skip_pmchart=true
else
skip_pmchart=true
fi
# these may not be installed on all platforms
which pmchart > /dev/null 2>&1
if [ $? -ne 0 ]
then
skip_pmchart=true
fi
skip_pmdumptext=false
which pmdumptext > /dev/null 2>&1
if [ $? -ne 0 ]
then
skip_pmdumptext=true
fi
skip_pmseries=false
which pmseries > /dev/null 2>&1
if [ $? -ne 0 ]
then
skip_pmseries=true
fi
# sources
share_dir=`dirname $PCP_SHARE_DIR`
bash_comp=${share_dir}/bash-completion/completions/pcp
# functions
_check_completion_bash()
{
cmds="$(grep ' pcp2.*)' $bash_comp | tr -d ')')"
cmds="$cmds $(grep ' pm.*)' $bash_comp | tr -d ')')"
for cmd in $cmds; do
# Handle aliases
str=" $cmd"
[ "$cmd" = "pmlogdump|pmdumplog" ] && cmd=pmdumplog && str=" pmlogdump|pmdumplog"
which $cmd > /dev/null 2>&1 || continue
$skip_pcp2elasticsearch && [ "$cmd" = pcp2elasticsearch ] && continue
$skip_pcp2graphite && [ "$cmd" = pcp2graphite ] && continue
$skip_pcp2influxdb && [ "$cmd" = pcp2influxdb ] && continue
$skip_pcp2json && [ "$cmd" = pcp2json ] && continue
$skip_pcp2spark && [ "$cmd" = pcp2spark ] && continue
$skip_pcp2xlsx && [ "$cmd" = pcp2xlsx ] && continue
$skip_pcp2xml && [ "$cmd" = pcp2xml ] && continue
$skip_pcp2zabbix && [ "$cmd" = pcp2zabbix ] && continue
$skip_pmchart && [ "$cmd" = pmchart ] && continue
$skip_pmdumptext && [ "$cmd" = pmdumptext ] && continue
$skip_pmrep && [ "$cmd" = pmrep ] && continue
$skip_pmseries && [ "$cmd" = pmseries ] && continue
comps=$(grep -A 1 "$str)" $bash_comp | tail -n 1 | sed -e 's,all_args=",,' -e 's,",,')
# Need $tmp.err and PCP_STDERR for pmchart ...
#
rm -f $tmp.err
touch $tmp.err
echo "=== bash $cmd ===" >>$seq_full
echo "comps=$comps" >>$seq_full
$cmd --help >$tmp.out 2>&1
echo "--- stdout ---" >>$seq_full
cat $tmp.out >>$seq_full
echo "--- stderr ---" >>$seq_full
cat $tmp.err >>$seq_full
opts=$(cat $tmp.out $tmp.err | grep -Eo -- ' -.' | tr -d '-' | tr -d '?' | sort | uniq)
echo "opts=$opts" >>$seq_full
for opt in $opts; do
echo $comps | grep $opt > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$opt missing for $cmd bash completions"
fi
done
for comp in $(echo $comps | grep -o .); do
echo $opts | grep $comp > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$comp looks extraneous for $cmd bash completions"
fi
done
done
}
# real QA test starts here
_check_completion_bash
# success, all done
echo "== done"
status=0
exit
|