summaryrefslogtreecommitdiff
path: root/qa/154
blob: f0f800122ffc4b0efd1324a7e862de5e4c5a6b23 (plain)
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
#! /bin/sh
# PCP QA Test No. 154
# what the hell is chkhelp supposed to do?
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

# New cisco metrics in pcp2.2 
if [ $PCP_VER -ge 2200 ]
then
    rm -f $seq.out && ln $seq.out.2 $seq.out
else
    rm -f $seq.out && ln $seq.out.1 $seq.out
fi

_filter_illegal()
{
    sed \
	-e '/illegal key/s/(-*[0-9][0-9]*)/(SIZE)/' \
	-e "s;$tmp;TMP;g"
}

_filter_chk()
{
    sed \
	-e '/-v version/d' \
	-e "s;$PCP_PMDAS_DIR;\$PCP_PMDAS_DIR;"
}

trap "rm -f $tmp.*; exit" 0 1 2 3 15

# real QA test starts here

cleanup=false
if [ ! -f $PCP_PMDAS_DIR/cisco/help.pag ]
then
    # no compiled help text, so the cisco PMDA has never been installed
    # here ... the only way to make this file appear is Install and Remove
    # the PMDA ... this should be a no-op, but may take a while
    #
    cd $PCP_PMDAS_DIR/cisco
    unset ROOT MAKEFLAGS
    $sudo ./Install </dev/null >/dev/null 2>&1
    cd $here
    if [ ! -f $PCP_PMDAS_DIR/cisco/help.pag ]
    then
	echo "Arrggh, need $PCP_PMDAS_DIR/cisco/help.pag and cannot remake it!"
	exit 1
    fi
    cleanup=true
fi
$sudo chmod 644 $PCP_PMDAS_DIR/cisco/help.*

echo
echo bad dbf
dd if=/dev/zero ibs=1024 count=4 of=$tmp.pag >/dev/null 2>&1
cp $tmp.pag $tmp.dir
echo "chkhelp bad-helpfile"
chkhelp $tmp >$tmp.out 2>&1
status=$?
_filter_illegal <$tmp.out
echo status=$status
echo "chkhelp -p bad-helpfile"
chkhelp -p $tmp >$tmp.out 2>&1
status=$?
_filter_illegal <$tmp.out
echo status=$status
echo "chkhelp bad-helpfile cisco.rate_in"
chkhelp $tmp cisco.rate_in 2>&1 | _filter_illegal
echo status=$?

echo
echo "some usage failures ..."
echo 'chkhelp -i $PCP_PMDAS_DIR/cisco/help cisco.rate_in'
chkhelp -i $PCP_PMDAS_DIR/cisco/help cisco.rate_in 2>&1 \
| _filter_chk
echo 'chkhelp -p $PCP_PMDAS_DIR/cisco/help cisco.rate_in'
chkhelp -p $PCP_PMDAS_DIR/cisco/help cisco.rate_in 2>&1 \
| _filter_chk
echo 'chkhelp -ip $PCP_PMDAS_DIR/cisco/help cisco.rate_in'
chkhelp -ip $PCP_PMDAS_DIR/cisco/help cisco.rate_in 2>&1 \
| _filter_chk

echo
echo "debug trace ..."
echo 'chkhelp -D 2048 $PCP_PMDAS_DIR/cisco/help'
chkhelp -D 2048 $PCP_PMDAS_DIR/cisco/help 2>&1 \
| _filter_chk

echo
echo "exercise options ..."

for h in "" -H
do
    for o in "" -O
    do
	for i in "" -i
	do
	    for p in "" -p
	    do
		for metric in "" cisco.rate_in "cisco.rate_in cisco.rate_out"
		do
		    if [ "X$p" = "X-p" -o "X$i" = "X-i" ]
		    then
			[ "X$metric" != X ] && continue
		    fi
		    echo
		    echo "args: $h $o $i $p $metric"
		    chkhelp $h $o $i $p \
			  -n $PCP_PMDAS_DIR/cisco/root \
                          $PCP_PMDAS_DIR/cisco/help $metric >$tmp.out 2>&1
                    status=$?
                    _filter_chk <$tmp.out
		    echo status=$status
		done
	    done
	done
    done
done

if $cleanup
then
    # see comments above when help.pag created for cisco PMDA
    #
    cd $PCP_PMDAS_DIR/cisco
    unset ROOT MAKEFLAGS
    $sudo ./Remove </dev/null >/dev/null 2>&1
    cd $here
fi

exit 0