#! /bin/bash
# $Id$
set -o errexit

AGENT=../src/servers_non_y2/ag_yp_conf
CASE=test-ypconf
AGPROG='YpConf ("'$CASE'-i.in")
Read (.)'
# kludge: break up the output into lines
S3='s/\([:,]\)/\1\
/g'
NORMALIZE="ycpc -E -"

echo "$AGPROG" | $AGENT | sed -e 1d | $NORMALIZE >$CASE.ycp.tmp
sed -e "$S3" $CASE.ycp.tmp > $CASE-i.out.tmp
diff -u $CASE-i.out $CASE-i.out.tmp

# do it twice: once without the file, then with it.
rm -f $CASE-o.out.tmp
for i in 1 2; do
echo 'YpConf ("'$CASE'-o.out.tmp")
Write (.,' `cat $CASE.ycp.tmp` ')' \
    | $AGENT >/dev/null
diff -u $CASE-o.out $CASE-o.out.tmp
done
