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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
|
#!/bin/sh
# PCP QA Test No. 1649
# pmrep -5|--ignore-unknown workout
#
# Copyright (c) 2026 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
do_valgrind=false
if [ "$1" = "--valgrind" ]
then
_check_valgrind
do_valgrind=true
fi
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
}
status=0 # success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_filter()
{
tee -a $seq_full \
| sed \
-e '/^pmRegisterDerived: /d' \
-e '/^Derived metric initialization /d' \
-e '/^pmLoadDerivedConfig(/d' \
-e '/^pmGetChildren(/d' \
-e '/^__dmtraverse(/d' \
-e '/^__dmtraverse: /d' \
-e '/^__dmchildren(/d' \
-e '/^__dmchildren: /d' \
-e '/^__dmbind(/d' \
-e '/^__dmbind: /d' \
-e '/^__dmgetpmid: /d' \
-e "s@$tmp@TMP@g" \
# end
}
# pmrep args are $1 ...
# loop live pmcd and then archive
# loop without --ignore-unknown then with --ignore-unknown
#
_doit()
{
for src in "-h local:" "-a $archive $start"
do
for opt in "" $ignore
do
echo "-- $opt $src $*" | _filter
if $do_valgrind
then
_run_valgrind pmrep $debug -s 1 -w 12 $opt $src $*
else
pmrep $debug -s 1 -w 12 $opt $src $* 2>&1
fi \
| _filter
done
done
}
PCP_DERIVED_CONFIG=$tmp.derived
export PCP_DERIVED_CONFIG
touch $PCP_DERIVED_CONFIG
ignore='--ignore-unknown'
archive='archives/omnibus-nomark_v3'
start='-S +1sec'
debug=''
# real QA test starts here
echo "=== metrics on command line ==="
echo "++ one bad"
_doit foo.bar
echo
echo "++ one bad and one good"
_doit foo.bar sample.long.million
echo
echo "++ one good, one bad and one good"
_doit sample.long.million foo.bar sample.string.hullo
echo
echo "++ one bad, one good, one bad and one good"
_doit fumble.mumble sample.long.million foo.bar sample.string.hullo
echo
echo "=== metrics in a metrics set ==="
echo "++ one bad"
cat <<End-of-File >$tmp.metricset
[qa]
foo.bar = badboy,,,,12
End-of-File
_doit -c $tmp.metricset :qa
echo
echo "++ one bad and one good"
cat <<End-of-File >$tmp.metricset
[qa]
foo.bar = badboy,,,,12
sample.long.million = goodie,,,,12
End-of-File
_doit -c $tmp.metricset :qa
echo
echo "++ one good, one bad and one good"
cat <<End-of-File >$tmp.metricset
[qa]
sample.long.million = goodie,,,,12
foo.bar = badboy,,,,12
sample.string.hullo = g'day,,,,12
End-of-File
_doit -c $tmp.metricset :qa
echo
echo "++ one bad, one good, one bad and one good"
cat <<End-of-File >$tmp.metricset
[qa]
fumble.mumble = badgirl,,,,12
sample.long.million = goodie,,,,12
foo.bar = badboy,,,,12
sample.string.hullo = g'day,,,,12
End-of-File
_doit -c $tmp.metricset :qa
echo
echo "=== derived metrics on command line (syntax errors) ==="
echo "++ one bad"
cat <<End-of-File >$tmp.derived
foo.bar = a +
End-of-File
_doit foo.bar
echo
echo "++ one bad and one good"
cat <<End-of-File >$tmp.derived
foo.bar = a +
goodboy = sample.long.million
End-of-File
_doit foo.bar goodboy
echo
echo "++ one good, one bad and one good"
cat <<End-of-File >$tmp.derived
goodboy = sample.long.million
foo.bar = a +
goodgirl = sample.string.hullo
End-of-File
_doit goodboy foo.bar goodgirl
echo
echo "++ one bad, one good, one bad and one good"
cat <<End-of-File >$tmp.derived
fumble.mumble =
goodboy = sample.long.million
foo.bar = a +
goodgirl = sample.string.hullo
End-of-File
_doit fumble.mumble goodboy foo.bar goodgirl
echo
echo "=== derived metrics on command line (semantic errors) ==="
echo "... using a non-terminal PMNS name, so --ignore-unknown makes no difference"
echo "... as soon as there is at least one good metric"
#debug='-Dderive'
echo "++ one bad"
cat <<End-of-File >$tmp.derived
foo.bar = hinv.ndisk + disk.all.total
End-of-File
_doit foo.bar
echo
echo "++ one bad and one good"
cat <<End-of-File >$tmp.derived
foo.bar = hinv.ndisk + disk.all.total
goodboy = sample.long.million
End-of-File
_doit foo.bar goodboy
echo
echo "++ one good, one bad and one good"
cat <<End-of-File >$tmp.derived
goodboy = sample.long.million
foo.bar = hinv.ndisk + disk.all.total
goodgirl = sample.string.hullo
End-of-File
_doit goodboy foo.bar goodgirl
echo
echo "++ one bad, one good, one bad and one good (non-leaf in PMNS)"
archive='archives/reduce-1'
start='-S +10sec'
cat <<End-of-File >$tmp.derived
foo.mumble = sample.pmid + sample.string.hullo
foo.goodboy = sample.float.million
foo.fumble = sample.lights + sample.colour
foo.goodgirl = sample.string.hullo
End-of-File
_doit foo
archive='archives/omnibus-nomark_v3'
start='-S +1sec'
PCP_DERIVED_CONFIG=
echo
echo "=== formula in metrics set (syntax errors) ==="
echo "++ one bad"
cat <<End-of-File >$tmp.metricset
[qa]
badboy = badboy,,,,12
badboy.formula = a +
End-of-File
_doit -c $tmp.metricset :qa
echo
echo "++ one bad and one good"
cat <<End-of-File >$tmp.metricset
[qa]
badboy = badboy,,,,12
badboy.formula = a +
goodboy = goodboy,,,,12
goodboy.formula = sample.long.million
End-of-File
_doit -c $tmp.metricset :qa
echo
echo "++ one good, one bad and one good"
cat <<End-of-File >$tmp.metricset
[qa]
goodboy = goodboy,,,,12
goodboy.formula = sample.long.million
badboy = badboy,,,,12
badboy.formula = a +
goodgirl = goodgirl,,,,12
goodgirl.formula = sample.string.hullo
End-of-File
_doit -c $tmp.metricset :qa
echo
echo "++ one bad, one good, one bad and one good"
archive='archives/reduce-1'
start='-S +10sec'
cat <<End-of-File >$tmp.metricset
[qa]
badgirl = badgirl,,,,12
badgirl.formula = sample.pmid + sample.string.hullo
goodboy = goodboy,,,,12
goodboy.formula = sample.float.million
badboy = badboy,,,,12
badboy.formula = sample.lights + sample.colour
goodgirl = goodgirl,,,,12
goodgirl.formula = sample.string.hullo
End-of-File
_doit -c $tmp.metricset :qa
archive='archives/omnibus-nomark_v3'
start='-S +1sec'
# and Marko's test cases from email to kenj 23 Jan 2026
#
cat <<End-of-File >$tmp.metricset
[qa]
foo = foo,,,,12
foo.formula = mem.util.free + no.such.thing
End-of-File
echo
echo "Marko's examples ..."
echo '++ Invalid metric mem.util.free + no.such.thing (PM_ERR_NAME Unknown metric name)'
pmrep -c $tmp.metricset :qa
echo '++ Invalid metric mem.util.free + no.such.thing (PM_ERR_NAME Unknown metric name)'
pmrep -c $tmp.metricset -a archives/20180102 :qa
echo '++ Invalid metric d_bad (PM_ERR_NAME Unknown metric name)'
pmrep -e 'd_bad = mem.util.free + no.such.thing' mem.util.free d_bad
echo '++ Invalid metric d_bad (PM_ERR_BADDERIVE Derived metric definition failed)'
pmrep -e 'd_bad = mem.util.free + no.such.thing' -a archives/20180102 mem.util.free d_bad
# success, all done
exit
|