#!/bin/sh

for dir in Xm/*
do
   if test -d $dir
   then
      here=`pwd`
      cd $dir
      echo =========== Making tests in $dir =============

      if test ! -d LessTif
      then
        mkdir LessTif
      fi
      for each in *.c
      do
	 if grep main $each > /dev/null
	 then
	    filbase=`basename $each .c`
	    fname=`dirname $each`/$filbase.exp
	    echo "Making test:" $fname
#
# instructions for basic testing
#
	    cat <<EOF >LessTif/$fname
spawn ./`basename $each .c`
set timeout 2
lt_basic_test
close
EOF

#
# instructions for xlab-based testing
#
	    if test -d xlab && 
	       test -f xlab/$filbase.xcalls &&
	       test -f xlab/$filbase.rxlog
	    then
               fname=`dirname $each`/$filbase.xlab.exp
   	       echo "Making test:" $fname
	       cat <<EOF >LessTif/$fname
spawn ../Xlab/PlaySession -T 2 `basename $each .c`
set timeout 20
lt_xlab_test
EOF
	    fi

	 fi
      done
      cd $here
   fi
done





