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
|
#!/bin/sh
# PCP QA Test No. 1486
# pmlogger -d and pmlogger_check changes ... restore pre-pcp-5.1.0
# semantics
#
# NOTE
# the pmlogger's this test starts are all expected to
# "fail" to start from pmlogger_check's perspective because
# they will exit immediately after logging a single pmResult.
#
# Copyright (c) 2023 Ken McDonell. All Rights Reserved.
#
if [ $# -eq 0 ]
then
seq=`basename $0`
echo "QA output created by $seq"
else
# use $seq from caller, unless not set
[ -n "$seq" ] || seq=`basename $0`
echo "QA output created by `basename $0` $*"
fi
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
}
status=0 # success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
# borrowed (in part) from _filter_pmlogger_log
#
_filter()
{
sed \
-e "s@$tmp@TMP@g" \
-e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/' \
-e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/DATE/' \
-e 's/pmlogger([1-9][0-9]*) Error:/pmlogger(PID) Error:/' \
-e 's/pmlogger([1-9][0-9]*) Info:/pmlogger(PID) Info:/' \
-e '/^preprocessor cmd: /d' \
-e '/^\(Log for pmlogger on\) [^ ][^ ]*/s//\1 HOST/' \
-e '/^Starting logger/s/host ".*/host "HOST"/' \
-e "s/$base/ARCHIVEBASE/g" \
# end
}
_filter_check()
{
sed \
-e '/^Start \[/s/ 2[0-9:. -]*/ DATESTAMP/' \
-e '/^End \[/s/ 2[0-9:. -]*/ DATESTAMP /' \
-e "s@$tmp@TMP@g" \
-e 's/\[process [0-9][0-9]*]/[PID]/' \
| $PCP_AWK_PROG '
$1 == "UID" { print "..."; skip = 1 }
$1 == "USER" { print "..."; skip = 1 }
skip == 1 && NF == 0 { skip = 0 }
skip == 1 { next }
{ print }'
}
mkdir $tmp
chmod 777 $tmp
cd $tmp
cat <<End-of-File >$tmp.config
log mandatory on once {
pmcd.pmlogger sample.seconds sample.daemon_pid
}
End-of-File
echo "#!/bin/sh" >$tmp.foo.sh
echo "echo foo" >>$tmp.foo.sh
chmod 755 $tmp.foo.sh
echo "foo.sh -> \"$($tmp.foo.sh)\"" >>$seq_full
# real QA test starts here
# first field (flags) below can be used to pass additional flags
# like -V
#
cat <<End-of-File | while read flags dir
# simple
- $tmp/foo
# simple in double quotes
- "$tmp/fool"
# simple in single quotes
- '$tmp/foolery'
# dollar(...) no spaces
- $tmp/\$($tmp.foo.sh)-bar
# backquote no spaces
- $tmp/\`$tmp.foo.sh\`lish
# with space in double quotes
- "$tmp/foo bar"
# with space in single quotes
- '$tmp/sn afu'
# dollar(...) with spaces in double quotes
- "$tmp/\$(echo mumble)-fumble"
# backquote with spaces and single quotes
- '$tmp/\`echo foo\`l-on-the-hill'
End-of-File
do
case "$flags"
in
\#*) # comment
continue
;;
esac
echo
echo "=== dir=$dir ===" | tee -a $seq_full | _filter
cat <<'End-of-File' >$tmp.control
$version=1.1
$PMLOGGER_CHECK_SKIP_JANITOR=yes
$PMCD_CONNECT_TIMEOUT=1
$PMCD_REQUREST_TIMEOUT=1
End-of-File
echo "LOCALHOSTNAME n n $dir -c $tmp.config -s 1" >>$tmp.control
if [ "$flags" != "-" ]
then
flag="$flags"
else
flag=''
fi
$sudo -u $PCP_USER -g $PCP_GROUP $PCP_BINADM_DIR/pmlogger_check -q -l $tmp.log -V $flag -c $tmp.control
# optionally map enclosing single quotes to enclosing double quotes
# so eval gets done
#
edir=`echo "$dir" | sed -e "s/^'/\"/" -e "s/'$/\"/"`
edir=`eval echo "$edir"`
if [ -z "$edir" ]
then
echo "Botch: edir=\"$edir\" ... empty from dir=\"$dir\""
cat $tmp.log
ls -lR $tmp
exit
fi
if [ ! -d "$edir" ]
then
echo "Botch: edir=\"$edir\" not created from dir=\"$dir\""
cat $tmp.log
ls -lR $tmp
exit
fi
if [ ! -f "$edir"/pmlogger.log ]
then
echo "Arrgh: no $edir/pmlogger.log!"
cat $tmp.log
ls -lR $tmp
base=99999999.99.99 # impossible datestamp
else
base=`sed -n <"$edir"/pmlogger.log -e '/^Archive basename: /{
s@.*/@@
p
}'`
echo "base=$base" >>$seq_full
fi
_filter <$tmp.log | _filter_check
echo "--- $edir contents ---" | _filter
ls "$edir" \
| sed \
-e "s/$base/ARCHIVEBASE/g" \
# end
$sudo rm -rf "$edir"
done
# success, all done
exit
|