pmrep: update TODO, man page
[pcp.git] / qa / 589
blob6a8ae7d76c64c9e3d3740a1557bf0b52aa6cba48
1 #!/bin/sh
2 # PCP QA Test No. 589
3 # make sure that telnet-probe does what its supposed to
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 host=`./getpmcdhosts -L -n 1 2>$seq.notrun`
17 if [ -z "$host" ]
18 then
19 cat $seq.notrun
20 exit
22 rm -f $seq.notrun
24 status=1 # failure is the default!
25 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
27 _filter()
29 sed -e 's;/[^ ]*/telnet-probe\([: ]\);.../telnet-probe\1;'
32 _filter2()
34 sed \
35 -e 's/__pmGetAddrInfo/gethostbyname/g' \
36 -e 's/__pmGetHostByName/gethostbyname/g' \
37 -e '/gethostbyname:/s/ Resolver Error 0 (no error)/ Unknown host/' \
38 -e 's/No route to host/Connection refused/'
41 # real QA test starts here
43 # simple error test
44 echo; echo === 1st test
45 echo quit | $PCP_BINADM_DIR/telnet-probe $host abc >$tmp.out 2>&1
46 sts=$?
47 cat $tmp.out | _filter
48 echo "exit status is $sts (should be 1 with error msg)"
49 echo quit | $PCP_BINADM_DIR/telnet-probe 1 2 3 >$tmp.out 2>&1
50 sts=$?
51 cat $tmp.out | _filter
52 echo "exit status is $sts (should be 1 with error msg)"
54 # should exit with good status
55 echo; echo === 2nd test
56 echo quit | $PCP_BINADM_DIR/telnet-probe localhost 22
57 echo "exit status is $? (should be 0)"
58 echo quit | $PCP_BINADM_DIR/telnet-probe $host 22
59 echo "exit status is $? (should be 0)"
61 # should fail to connect
63 # Note: [port] 26 below is unassigned by IANA although
64 # http://www.speedguide.net reports it may be used for RSFTP (simple
65 # FTP-like service) and perhaps an SMTP alternate ... for our
66 # purposes we're looking for a port that has no one listening
67 # on the remote end
68 # Another note: some firewalls will respond with "No route to host"
69 # rather than "Connection refused", so treat these as equivalent
71 echo; echo === 3rd test
72 echo quit | $PCP_BINADM_DIR/telnet-probe -v localhost 26 >$tmp.out 2>$tmp.err
73 sts=$?
74 cat $tmp.err $tmp.out | _filter2
75 echo "exit status is $sts (should be 1 with verbosity)"
76 echo quit | $PCP_BINADM_DIR/telnet-probe -v $host 26 >$tmp.out 2>$tmp.err
77 sts=$?
78 cat $tmp.err $tmp.out | _filter2
79 echo "exit status is $sts (should be 1 with verbosity)"
80 echo quit | $PCP_BINADM_DIR/telnet-probe -v no.such.host.pcp.io 26 >$tmp.out 2>$tmp.err
81 sts=$?
82 cat $tmp.err $tmp.out | _filter2
83 echo "exit status is $sts (should be 1 with verbosity)"
85 # success, all done
86 status=0
87 exit