#!/bin/csh

# COPYRIGHT NOTICE
# Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
# ALL RIGHTS RESERVED (MOTIF).  See the file named COPYRIGHT.MOTIF
# for the full copyright text.
# 
# 
# HISTORY
# @OSF_COPYRIGHT@
#

# This script runs all the automated QATS tests, as defined in the file
# ./tests/General/dirsAuto

unalias cd
unalias pushd
unalias popd

set dirs_file = ../tests/General/dirsAuto
set DIR_LIST = (`cat $dirs_file`)
set TESTS_HOME = $cwd
set HOSTNAME = `hostname`

echo  $#DIR_LIST " directories of automated tests to be run..."

# Go to the lib dir and build the Motif libraries local

cd $TESTS_HOME/../lib
echo "I am in " $cwd

set DIR = $cwd:t
if (-e make.$DIR) then
	mv  make.$DIR make.$DIR.bak
endif
make -i >& make.$DIR

# Go to each automated test directory

foreach dir ($DIR_LIST)
        cd $TESTS_HOME/../$dir
	set DIR = $cwd:t
        echo "I am in " $cwd

# Make all the automated tests and supporting files in this directory

        if (-e make.$DIR) then
                mv  make.$DIR make.$DIR.bak
        endif
        make IMAKE_DEFINES=-DAUTOMATION Makefile
        make -i >& make.$DIR
        echo "make -i >& make.$DIR"

# Use the generated RUN script to run all of the tests

        if (-e RUN.$DIR) then
            if (-e RUN.$DIR.bak) then
                rm -f RUN.$DIR.bak
            endif
            mv RUN.$DIR RUN.$DIR.bak
        endif
	 switch ("$HOSTNAME")
            case devildog: 
			   $cwd/RUN -T -D 1 -genrep -Dir -d hoho:0 >& RUN.$DIR
			   breaksw
            case suzyq:    
			   $cwd/RUN -T -D 1 -genrep -Dir -d hoho:0 >& RUN.$DIR
			   breaksw
            case whoopi:   
			   $cwd/RUN -T -D 1 -genrep -Dir -d hoho:0 >& RUN.$DIR
			   breaksw
            case twinkie:  
			   $cwd/RUN -T -D 1 -genrep -Dir -d yala:0 >& RUN.$DIR
            		   echo "$cwd/RUN -T -D 1 -genrep -Dir -d yala:0 >& RUN.$DIR"
			   breaksw
	    default: 
		           $cwd/RUN -T -D 1 -genrep -Dir -d :0.0 >& RUN.$DIR
	                   echo "After RUN: $cwd/RUN -T -D 1 -genrep -Dir -d ${HOSTNAME}:0.0 >& RUN.$DIR"
		     breaksw
	endsw

# Clean up the directory before leaving

        #make clean

end
