2009-08-13 17:23:42 +02:00
|
|
|
#!/usr/bin/ksh
|
|
|
|
|
|
|
|
PATH=/bin:/usr/bin:/usr/sbin:/sbin
|
|
|
|
|
|
|
|
getSampleInterval() { return 0; }
|
2012-02-06 13:36:57 +01:00
|
|
|
typeset -lui count=${1:-4000}
|
2009-08-13 17:23:42 +02:00
|
|
|
typeset -ilu leak=0
|
|
|
|
|
2012-02-02 13:07:46 +01:00
|
|
|
typeset -a curstate=(0 0 0)
|
|
|
|
typeset -a oldstate=(0 0 0)
|
|
|
|
|
2009-08-13 17:23:42 +02:00
|
|
|
vm()
|
|
|
|
{
|
|
|
|
typeset size
|
|
|
|
typeset key unit result=""
|
|
|
|
while read key size unit; do
|
|
|
|
case "$key" in
|
2012-02-02 13:07:46 +01:00
|
|
|
VmSize*) result=${result:+"$result "}$size ;;
|
|
|
|
VmRSS*) result=${result:+"$result "}$size ;;
|
|
|
|
VmData*) result=${result:+"$result "}$size ;;
|
2009-08-13 17:23:42 +02:00
|
|
|
esac
|
|
|
|
done < /proc/$$/status
|
|
|
|
echo $result
|
|
|
|
}
|
|
|
|
|
2012-02-02 13:07:46 +01:00
|
|
|
lessequal()
|
|
|
|
{
|
|
|
|
typeset -i ret=0
|
|
|
|
((${curstate[0]} > ${oldstate[0]})) && let ret=1
|
|
|
|
((${curstate[1]} > ${oldstate[1]})) && let ret=1
|
|
|
|
((${curstate[2]} > ${oldstate[2]})) && let ret=1
|
|
|
|
return $ret
|
|
|
|
}
|
2009-08-13 17:23:42 +02:00
|
|
|
|
2012-02-02 13:07:46 +01:00
|
|
|
oldstate=($(vm))
|
2012-02-06 13:36:57 +01:00
|
|
|
while ((count-- > 0))
|
2009-08-13 17:23:42 +02:00
|
|
|
do
|
|
|
|
interval=$(getSampleInterval)
|
|
|
|
|
2012-02-02 13:07:46 +01:00
|
|
|
curstate=($(vm))
|
|
|
|
lessequal || let leak++
|
|
|
|
oldstate=(${curstate[@]})
|
2009-08-13 17:23:42 +02:00
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "[${0##*/}: leak count at $leak]"
|
2012-01-23 15:16:26 +01:00
|
|
|
((leak < 20)) || exit 1
|