File: 1640

package info (click to toggle)
pcp 7.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 253,896 kB
  • sloc: ansic: 1,488,097; sh: 185,322; xml: 160,462; cpp: 83,813; python: 25,576; perl: 18,365; yacc: 6,877; lex: 2,864; makefile: 2,759; exp: 250; awk: 165; fortran: 60; java: 22
file content (118 lines) | stat: -rwxr-xr-x 3,111 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
#!/bin/sh
# PCP QA Test No. 1640
# pmUnregisterDerived() workout
#
# non-valgrind variant, see qa/1641 for the valgrind variant
#
# Copyright (c) 2025 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
elif which valgrind >/dev/null 2>&1
then
    [ "$PCPQA_VALGRIND" = both ] || \
        _notrun "valgrind variant qa/1641 will be run"
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()
{
    sed \
	-e "s@$tmp@TMP@g" \
	-e '/pmResult/s/ .* numpmid/ ... numpmid/' \
	-e '/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/s/[^ ]*/TIMESTAMP/' \
	-e "s/`hostname`/HOSTNAME/g" \
    # end
}

_doit()
{
    if $do_valgrind
    then
	_run_valgrind src/unregister "$@"
    else
	src/unregister "$@" 2>&1
    fi \
    | _filter
}

cat <<End-of-File >$tmp.cases
-- unregister unknown metric
-u foobar foobar
--- definition and unregister, but no context
-r foo=sample.bin -u foo foo
--- value 42 for global derived metric
-r foo.bar=(8*sample.long.ten+4*sample.long.one)/2 -h local: foo.bar
--- global derived metric unregistered
-r foobar=(8*sample.long.ten+4*sample.long.one)/2 -h local: -u foobar foobar
--- value 42 for per-context derived metric in 2nd context only
-h `hostname` -h local: -q foo.bar=(8*sample.long.ten+4*sample.long.one)/2 -h local: foo.bar
--- per-context drived metric unregistered
-h `hostname` -h local: -q foo.bar=(8*sample.long.ten+4*sample.long.one)/2 -h local: -u foo.bar foo.bar
--- value 42 in 2 contexts
-r foo.bar=(8*sample.long.ten+4*sample.long.one)/2 -h local: -h `hostname` foo.bar
--- name undefined in all contexts
-r foo.bar=(8*sample.long.ten+4*sample.long.one)/2 -h local: -h `hostname` -u foo.bar foo.bar
--- value 42 in the 1st context, name undefined in the 2nd context
-h local: -q foo.bar=(8*sample.long.ten+4*sample.long.one)/2 -h `hostname` foo.bar
-- global and per-context derived metrics unregistered
-r foo.bar=(8*sample.long.ten+4*sample.long.one)/2 -h local: -h `hostname` -q bar.foo=(8*sample.long.ten+4*sample.long.one)/2 -u foo.bar -u bar.foo foo.bar bar.foo
--- load
-h local: -c $tmp.config foo.load
--- load and unregister
-c $tmp.config -h local: -u foo.load foo.load
--- masking
-c $tmp.config -h local: -q foo.load=sample.long.million foo.load
--- masking and unregister
-c $tmp.config -h local: -q foo.load=sample.long.million -u foo.load foo.load
End-of-File

cat <<End-of-File >$tmp.config
foo.load=(8*sample.long.ten+4*sample.long.one)/2
End-of-File

# real QA test starts here
cat $tmp.cases | while read args
do
    case "$args"
    in
	---*)
		echo "$args ---"
		;;
	*)
		echo "+ $args" | _filter
		_doit $args
		echo
		;;
    esac
done

# success, all done
exit