File: 1642

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (188 lines) | stat: -rwxr-xr-x 4,040 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
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
#!/bin/sh
# PCP QA Test No. 1642
# pmlogcheck -r -R [repair]
#
# non-valgrind variant, see qa/1643 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/1643 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

# produce a summary of an archive
#
_arch_info()
{
    rm -f $tmp.index $tmp.meta $tmp.data
    for file in $1*
    do
	case $file
	in
	    *.index)
		$here/src/scanindex "$1".index 2>&1 \
		| sed -e 's/^/index/' >$tmp.index
		;;

	    *.meta.*)
		t=$tmp.meta.`echo $file | sed -e 's/.*\.\([^.]*\)$/\1/'`
		cp "$file" "$t"
		pmlogdecompress "$t"
		$here/src/scanmeta -a "$t" 2>&1 \
		| sed -e 's/^/meta/' >$tmp.meta
		;;

	    *.meta)
		$here/src/scanmeta -a "$file" 2>&1 \
		| sed -e 's/^/meta/' >$tmp.meta
		;;

	    *)
		$here/src/scandata "$file" 2>&1 \
		| sed -e "s/^/$file /" \
		| _filter >$tmp.data
	esac 
    done
    [ -f $tmp.index ] && cat $tmp.index
    [ -f $tmp.meta ] && cat $tmp.meta
    [ -f $tmp.data ] && cat $tmp.data
}

_filter()
{
    sed \
	-e "s@$tmp@TMP@g" \
	-e 's/TMP\.before[ 	].*/_arch_info before .../' \
	-e 's/TMP\.after[ 	].*/_arch_info after .../' \
    # end
}
cat <<End-of-File >$tmp.cases
# test		# archive			# pmlogcheck args
-r_needs_tty	archives/foo+			-r
do_nothing_v3	archives/sample-proc_v3		-wR
trunc_data_v3	archives/sample-proc_v3		-wR
trunc_data_v2	archives/sample-proc_v2		-wR
extra_index	archives/foo+			-wR
dup_index	archives/foo+			-wR
dup_meta	archives/foo+			-wR
End-of-File

mkdir $tmp || _exit 1

# cannot afford timezone differences for timestamps
#
TZ=UTC; export TZ

# real QA test starts here

sed -e '/^#/d' -e '/^$/d' <$tmp.cases \
| while read testcase archive args
do
    echo
    echo "=== $testcase ==="

    rm -f $tmp/*
    if ! pmlogcp $archive $tmp/`basename $archive`
    then
	echo "Botch: pmlogcp failed"
	continue
    fi
    cd $tmp || _exit 1
    archive=`basename $archive`

    case "$testcase"
    in
	trunc_data_v3|trunc_data_v2)
		truncate -s 8192 $archive.0
		;;
	extra_index)
		echo foo >>$archive.index
		;;
	dup_index)
		# this is archives/foo+.0 which is a V2 archive and
		# hence skip 132 bytes for the archive label record
		#
		dd ibs=1 iseek=132 if=$archive.index >$tmp.extra 2>/dev/null
		if [ ! -s $tmp.extra ]
		then
		    # some bozo decided that after 50 years, making iseek=
		    # go away for dd(1) was a good idea
		    #
		    dd ibs=1 skip=132 if=$archive.index >$tmp.extra 2>/dev/null
		fi
		cat $tmp.extra >>$archive.index
		;;
	dup_meta)
		# from src/scanmeta -ao archives/foo+.0
		# ...
		# [6] +414 @ 20:13:16.587195000 indom 29.2 numinst 9
		# [7] +586 metric 29.0.109 (sample.longlong.bin)
		dd ibs=1 iseek=414 count=172 if=$archive.meta >$tmp.extra 2>/dev/null
		if [ ! -s $tmp.extra ]
		then
		    # see bozo comment above
		    #
		    dd ibs=1 skip=414 count=172 if=$archive.meta >$tmp.extra 2>/dev/null
		fi
		cat $tmp.extra >>$archive.meta
		;;
	*)
		# do nothing by default
		;;
    esac
    _arch_info $archive >$tmp.before

    if $do_valgrind
    then
	_run_valgrind --save-output pmlogcheck $args $archive
    else
	pmlogcheck $args $archive >$tmp.out 2>$tmp.err
    fi
    cat $tmp.err $tmp.out | _filter

    _arch_info $archive >$tmp.after
    if diff $tmp.before $tmp.after >/dev/null
    then
	echo "No diffs"
    else
	echo "Diffs ..."
	diff -u $tmp.before $tmp.after | _filter
    fi

    cd $here || _exit 1
done

# success, all done
exit