#!/bin/sh
# $Id: t-evthr.sh,v 1.10 2004/12/29 23:47:33 ca Exp $
# Copyright (c) 2003, 2004 Sendmail, Inc. and its suppliers.
#	All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#
test -s stop && exit 1
# 
L=o
C=0
# programs used in these tests
EV0=./t-evthr
EV1=./t-evthr-1
USCL=../misc/t-unixcl
echo xyz | ${EV0} >${L} 2>&1 &
P=$!
while test ${C} -le 4
do
	if kill -0 ${P} 2>/dev/null
	then
		sleep 1
		C=`expr ${C} + 1 `
	else
		break
	fi
done
if grep ' tests ' ${L}
then
  :
else
  kill -9 ${P}
  sleep 1
fi
wait
rm -f ${L}

# now connect via a Unix socket to the server
S=evsock
REPS=5
rm -f ${S}
echo xyz | ${EV1} -r ${REPS} -a ${S} >${L} 2>&1 &
P=$!
sleep 1
i=1
while test ${i} -le ${REPS}
do
  if test ${i} = ${REPS}
  then
    I="abcQ"
  else
    I="123"
  fi
  echo ${I} | ${USCL} ${S}
  i=`expr ${i} + 1 `
done
while test ${C} -le 4
do
	if kill -0 ${P} 2>/dev/null
	then
		sleep 1
		C=`expr ${C} + 1 `
	else
		break
	fi
done
if grep ' tests ' ${L}
then
  :
else
  kill -9 ${P}
  sleep 1
fi
wait
rm -f ${L}

exit 0


syntax highlighted by Code2HTML, v. 0.9.1