File: 1864

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 (197 lines) | stat: -rwxr-xr-x 3,959 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
189
190
191
192
193
194
195
196
197
#!/bin/sh
# PCP QA Test No. 1864
# -d and related bits for pmlogger_daily
#
# 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

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp $tmp.*
}

status=0	# success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

# some non-determinism in these lines due to du(1) and filesystem space
# allocation algorithms:
# ... archives for localhost (1056 Kbytes) ...
# ... localhost, archives (524 Kbytes) ...
#
_filter()
{
    sed \
	-e '/^Roll .*\/NOTICES/d' \
	-e '/^Start .*\/NOTICES/d' \
	-e '/^Start \[/s/ 2[0-9:. -]*/ DATESTAMP/' \
	-e '/^End \[/s/ 2[0-9:. -]*/ DATESTAMP /' \
	-e '/archives for localhost/{
s/localhost (10[12][0-9] /localhost ([1010+] /
s/localhost (10[56][0-9] /localhost ([1050+] /
}' \
	-e '/localhost, archives/{
s/archives (5[0-2][0-9] /archives ([500+] /
}' \
	-e '/Info: purge 20260202/{
s/reclaims 3[0-9] Kbyte/reclaims [30+] Kbyte/
}' \
	-e '/Info: purge 20260203/{
s/reclaims 49[0-9] Kbyte/reclaims [490+] Kbyte/
s/reclaims 5[01][0-9] Kbyte/reclaims [490+] Kbyte/
}' \
	-e "s@$tmp@TMP@g" \
    # end
}

_setup()
{
    cd $here
    $sudo rm -rf $tmp/*
    if ./mk.logfarm -c $tmp.farm $tmp >$tmp.out 2>&1
    then
	_filter <$tmp.out
    else
	cat $tmp.out
	echo "Arrgh ... mk.logfarm failed!"
	_exit
    fi
    cd $tmp
    find * \
    | while read f
    do
	case "$f"
	in
	    */..)	;;
	    *)		$sudo chown $PCP_USER:$PCP_GROUP "$f"
	    		;;
	esac
    done
    echo "setup() ..." >>$seq_full
    find $tmp/* -type d \
    | while read dir
    do
	du -sk $dir >>$seq_full
    done
}

_doit()
{
    ( cd $tmp; find * -type f ) | _filter | sort >$tmp.before
    $sudo rm -f $tmp.log
    $sudo -E -u $PCP_USER $PCP_BINADM_DIR/pmlogger_daily $@ -c $tmp.control -D -P -V -l $tmp.log >$tmp.err 2>&1
    if [ -s $tmp.err ]
    then
	_filter <$tmp.err
	[ -s $tmp.log ] && _filter <$tmp.log
	echo "... errors from pmlogger_daily!"
    else
	[ -s $tmp.err ] && _filter <$tmp.err
	[ -s $tmp.log ] && _filter <$tmp.log
	echo
	( cd $tmp; find * -type f ) | _filter | sort >$tmp.after
	echo "Changes ..."
	diff $tmp.before $tmp.after
    fi
}

# archive	Kbytes
# cgroups-units	 36
# 20041125	340
# ok-bigbin	492
# ok-mv-bigbin	520
#
cat <<End-of-File >$tmp.farm
# expect 1048 Kbytes in total
foo	archives/ok-mv-bigbin	20260204
foo	archives/ok-bigbin	20260203
foo	archives/cgroups-units	20260202
End-of-File

mkdir $tmp
_setup

# real QA test starts here

echo "=== errors in control file ==="

# bad control file
#
cat <<End-of-File >$tmp.control
\$version=1.1
\$PCP_CULLAFTER=never
\$PCP_SPACELIMIT
\$PCP_SPACELIMIT=
\$PCP_SPACELIMIT=foo
\$PCP_SPACELIMIT=123
#Host           P?  S?  directory       args
localhost       n   n   $tmp/foo    -c /no/such/config
End-of-File
_doit

# good control file
#
cat <<End-of-File >$tmp.control
\$version=1.1
\$PCP_CULLAFTER=never
#Host           P?  S?  directory       args
localhost       n   n   $tmp/foo    -c /no/such/config
End-of-File

echo
echo "=== command line errors ==="
_doit "-d foo"
_doit "-d"
_doit "-d 1234"

echo
echo "=== expect no purging ==="
_doit

echo
echo "=== -d 1020k ==="
_doit "-d 1020k" 

echo
echo "=== PCP_SPACELIMIT=1000k"
PCP_SPACELIMIT=1000k
export PCP_SPACELIMIT
_doit

echo
echo "=== ignore -d use value from env ==="
_doit "-d 500K"

unset PCP_SPACELIMIT

# another good control file
#
cat <<End-of-File >$tmp.control
\$version=1.1
\$PCP_CULLAFTER=never
\$PCP_SPACELIMIT=1000K
#Host           P?  S?  directory       args
localhost       n   n   $tmp/foo    -c /no/such/config
End-of-File

echo
echo "=== ignore -d use value from control file ==="
_doit "-d 500K"

# success, all done
exit