#! /bin/sh
# PCP QA Test No. 198
# pv:934332 __pmdaMainPDU leaks __pmProfile objects
#
# Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

status=0	# success is the default!
$sudo rm -rf $tmp.*
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

rm -f $seq.full

# real QA test starts here

for pmda in sample sampledso
do
    echo "=== $pmda pmda ==="
    echo "=== $pmda pmda ===" >>$seq.full
    then=`pmprobe -v $pmda.datasize`
    echo "then=$then" >>$seq.full

    for i in 1 2 3 4
    do
	pmval -t 20msec -s 250 -i "${i}10,${i}11,${i}12,${i}13,${i}14,${i}15,${i}16,${i}17,${i}18,${i}19,${i}20,${i}21,${i}22,${i}23,${i}24,${i}25,${i}26,${i}27,${i}28,${i}29,${i}30,${i}31,${i}32,${i}33,${i}34,${i}35,${i}36,${i}37,${i}38,${i}39,${i}40,${i}41,${i}42,${i}43,${i}44,${i}45,${i}46,${i}47,${i}48,${i}49,${i}50,${i}51,${i}52,${i}53,${i}54,${i}55,${i}56,${i}57,${i}58,${i}59" $pmda.hordes.one >$tmp.$i &
    done

    wait

    for i in 1 2 3 4
    do
	echo "thread $i: lines of output: `wc -l <$tmp.$i | sed -e 's/  *//g'`"
    done

    now=`pmprobe -v $pmda.datasize`
    echo "now=$now" >>$seq.full

    if [ "$then" != "$now" ]
    then
	echo "Arrgh ... memory leak"
	echo "before: $then"
	echo "after: $now"
	status=1
    fi

    cat $tmp.1 >>$seq.full
done

exit

# all done
exit
