Home | History | Annotate | Download | only in scripts
      1 #! /bin/bash
      2 
      3 #
      4 # This script is called from the directory where the test cases are.
      5 # Not all the test cases use this.
      6 #
      7 # Usage: $0 profile testname1 [ testname2 ... ]
      8 #
      9 # This script looks for *each* line in profile matching the
     10 # pattern "testid testname" and runs the corresponding test with the
     11 # args defined in the line.
     12 
     13 [ $# -lt 2 ] && { echo >&2 "$0: too few arguments (at least two)" ; exit 1 ; }
     14 profile=$1
     15 shift
     16 
     17 #source $SCRIPTS_DIR/setenv.sh
     18 
     19 profile_path=$PROFILES_DIR/$profile
     20 # Does profile exist?
     21 [ ! -f "$profile_path" ] && { echo >&2 "$0: Could not find profile ($profile_path)" ; exit 1 ; }
     22 
     23 # if INSTALL_DIR != top_srcdir assume the individual tests are built and installed.
     24 if [[ -f Makefile ]]; then
     25     # Compile the test cases to support stand alone runs.
     26     make
     27 fi
     28 
     29 
     30 # Run the test case
     31 for testname in $*
     32 do
     33 	# Strip off comments and feed it to trivial parser.
     34 	sed 's/#.*//' < $profile_path | while read line ; do
     35 		set $line ""
     36 		# Check if the line is elligible
     37 		if [ "$1" = "$TEST_REL_DIR" -a "$2" = "$testname" ] ; then
     38 			cmd=$2
     39 			shift 2
     40 			params="$*"
     41 
     42 			if [ "$LOG_FILE" = "" ]; then
     43 				LOG_FILE="$LOG_DIR/$LOG_FORMAT-${cmd}${params// /}.log"
     44 			fi
     45 			[ ! -d $LOG_DIR ] && mkdir -p $LOG_DIR
     46 
     47 			(
     48 				echo "--- Running testcase $cmd $params ---"
     49 				date
     50 				echo "Logging to $LOG_FILE"
     51 				eval ./$cmd 2>&1 $params
     52 				echo
     53 				date
     54 				echo "The $cmd test appears to have completed."
     55 			) | tee -a $LOG_FILE
     56 		fi
     57 	done
     58 done
     59