File: 967

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (187 lines) | stat: -rwxr-xr-x 5,402 bytes parent folder | download
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/sh
# PCP QA Test No. 967
# zsh shell completion check (see 1100 for bash 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
echo "PCPQA_CLOSE_X_SERVER=$PCPQA_CLOSE_X_SERVER" >>$seq_full

[ $PCP_PLATFORM = linux ] || _notrun "Test needs to run only on Linux"

if which zsh >/dev/null 2>&1
then
    :
else
    _notrun "No zsh executable"
    # NOTREACHED
fi

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
echo "DISPLAY=$DISPLAY" >>$seq_full
echo "PCPQA_CLOSE_X_SERVER=$PCPQA_CLOSE_X_SERVER" >>$seq_full
if [ -z "$DISPLAY" ]
then
    DISPLAY=$PCPQA_CLOSE_X_SERVER; export DISPLAY
    echo "DISPLAY=$DISPLAY" >>$seq_full
fi

# 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
skip_pmdumptext=false
which pmchart > /dev/null 2>&1
if [ $? -ne 0 ]
then
    skip_pmchart=true
fi
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`
zsh_comp=${share_dir}/zsh/site-functions/_pcp

# functions
_check_completion_zsh()
{
  for cmd in $(grep '#compdef' $zsh_comp | sed -e 's,#compdef ,,'); do
    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
    echo $cmd | grep = > /dev/null 2>&1 && continue
    common=$(awk "/common_most=/,/  \)/" $zsh_comp)
    pytool=$(awk "/common_python=/,/  \)/" $zsh_comp)
    pmda=$(awk "/common_pmda=/,/  \)/" $zsh_comp)
    version=V
    # Handle aliases
    str="  $cmd"
    [ "$cmd" = "pmlogdump" -o "$cmd" = "pmdumplog" ] && str="  pmlogdump|pmdumplog"
    comps=$(awk "/$str\)/,/;;/" $zsh_comp | sed -e 's,equivalent to .*,,')
    # Need $tmp.err and PCP_STDERR for pmchart ...
    #
    rm -f $tmp.err
    touch $tmp.err
    echo "=== zsh $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 | sed -e 's,equivalent to .*,,' | grep -Eo -- ' -[^-].' | tr -d - | tr -d '?' | tr -d , | sort | uniq)
    echo "opts=$opts" >>$seq_full

    for opt in $opts; do
      echo $comps | grep -E -- '({-'$opt'|"-'$opt')' > /dev/null 2>&1
      not_found=$?
      if [ $not_found -ne 0 ]; then
        if [ "$opt" = "V" ]; then
          echo $comps | grep common_help > /dev/null 2>&1
          not_found=$?
        fi
      fi
      if [ $not_found -ne 0 ]; then
        echo $comps | grep common_most > /dev/null 2>&1
        if [ $? -eq 0 ]; then
          echo $common | grep -E -- '({-'$opt'|"-'$opt')' > /dev/null 2>&1
          not_found=$?
        fi
      fi
      if [ $not_found -ne 0 ]; then
        echo $comps | grep common_pmda > /dev/null 2>&1
        if [ $? -eq 0 ]; then
          echo $pmda | grep -E -- '({-'$opt'|"-'$opt')' > /dev/null 2>&1
          not_found=$?
        fi
      fi
      if [ $not_found -ne 0 ]; then
        echo $comps | grep common_python > /dev/null 2>&1
        if [ $? -eq 0 ]; then
          echo $pytool | grep -E -- '({-'$opt'|"-'$opt')' > /dev/null 2>&1
          not_found=$?
        fi
      fi
      if [ $not_found -ne 0 ]; then
        echo "$opt missing for $cmd zsh completions"
      fi
    done

    for comp in $(echo $comps | grep -o \"\(-. | tr -d '"' | tr -d '(' | tr -d '-'); do
      echo $opts | grep $comp > /dev/null 2>&1
      if [ $? -ne 0 ]; then
        echo "$comp looks extraneous for $cmd zsh completions"
      fi
    done

  done
}

# real QA test starts here
echo "== only V+u for pmlogger should be missing"
_check_completion_zsh

# success, all done
echo "== done"
status=0
exit