#! /bin/sh
# PCP QA Test No. 285
#
# Plan:
# 1. to show that the indom result for instance requests for
#    pmLookupInDom and pmNameInDom calls should NOT be different 
#    for DSOs versus daemon agents. 
# 2. to verify that opening a dso and then connecting to a daemon
#    is viable.
#    Note: qa/147 tests out doing a daemon and then a dso
#
# Method:
# 1. use dbpmda with the sampledso and sample daemon with appropriate
#    instance requests
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

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

# get standard filters
. ./common.product
. ./common.filter
. ./common.check

sampledso=$PCP_PMDAS_DIR/sample/pmda_sample.$DSO_SUFFIX

status=1	# failure is the default!
username=`id -u -n`
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

_filter()
{
    sed \
	-e '/^dbpmda> $/d' \
	-e "s/ -U $username//g" \
        -e "s;$sampledso;SAMPLEDSO;g" \
	-e "s;$PCP_PMDAS_DIR;\$PCP_PMDAS_DIR;g"
}

pipeargs=""
id pcp >/dev/null 2>&1 && pipeargs="-U $username"

# real QA test starts here

# part 1.
#
echo "=== dso and daemon handle indom ops the same way? ==="
echo
dbpmda -ie <<EOF 2>&1 | _filter | tee $tmp.dso
open dso $sampledso sample_init 30
instance 30.1
instance 30.1 0
instance 30.1 "red"
EOF

echo
dbpmda -ie <<EOF 2>&1 | _filter | tee $tmp.daemon
open pipe $PCP_PMDAS_DIR/sample/pmdasample $pipeargs -d 30
instance 30.1
instance 30.1 0
instance 30.1 "red"
EOF

echo
echo "Differences ... expect none after the \"open\" processing"
diff $tmp.dso $tmp.daemon

# part 2.
#
echo
echo "=== IPC-PDU version botch for second PMDA? ==="
dbpmda -ie <<EOF 2>&1 | _filter
open dso $sampledso sample_init 30
open pipe $PCP_PMDAS_DIR/sample/pmdasample $pipeargs -d 29
EOF

# success, all done
status=0
exit
