Cleaned up script generation and got rid of the atrocious write.sh

This commit is contained in:
Tom Hacohen 2013-04-19 17:12:00 +01:00
parent 7b1df1a40f
commit 802baf489f
2 changed files with 176 additions and 183 deletions

View File

@ -1,8 +1,10 @@
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in
uninstall-local: exactness: exactness.in
rm $(bindir)/exactness $(AM_V_GEN) $(SED) -e "s|\@libdir\@|$(libdir)|" $(srcdir)/exactness.in > $(builddir)/exactness
install-exec-local: bin_SCRIPTS = exactness
$(srcdir)/write.sh $(libdir)/exactness/
$(INSTALL) exactness $(bindir) CLEAN_FILES = exactness
EXTRA_DIST = exactness.in

View File

@ -1,10 +1,4 @@
#!/bin/sh #!/bin/bash
# This script creates exactness script that later is copied to $(bindir)
# by Makefile.
# The reason to do it this was is that we would like to get $OUR_LIBPATH as
# a parameter from Makefile.
cat <<-ENDOFMESSAGE>exactness
#!/usr/bin/env bash
# tsuite_script.sh -i this makes new 'orig' folder # tsuite_script.sh -i this makes new 'orig' folder
# tsuite_script.sh -i -b [BaseDir] TestName1 [TestName2 ...] rewrite files for selcted tests in 'orig' folder # tsuite_script.sh -i -b [BaseDir] TestName1 [TestName2 ...] rewrite files for selcted tests in 'orig' folder
# tsuite_script.sh -r -b [BaseDir] [TestName1 TestName2 ...] ; this means record [all tests or TestName additional arg] # tsuite_script.sh -r -b [BaseDir] [TestName1 TestName2 ...] ; this means record [all tests or TestName additional arg]
@ -15,11 +9,11 @@ cat <<-ENDOFMESSAGE>exactness
#_DEBUG="on" #_DEBUG="on"
function DEBUG() function DEBUG()
{ {
[ "\$_DEBUG" == "on" ] && \$@ [ "$_DEBUG" == "on" ] && $@
} }
do_help () { do_help () {
echo "Use \$0 to test application screen-layout." echo "Use $0 to test application screen-layout."
echo "First, you need to compose a tests file as follows:" echo "First, you need to compose a tests file as follows:"
echo "Each line begins with test name" echo "Each line begins with test name"
echo "second field is test-command and [optional] params." echo "second field is test-command and [optional] params."
@ -28,25 +22,25 @@ echo
echo "# This is a comment line" echo "# This is a comment line"
echo "TestName TestCmd [param1] [param2]" echo "TestName TestCmd [param1] [param2]"
echo echo
echo "Later, you run \$0 with the tests file as parameter." echo "Later, you run $0 with the tests file as parameter."
echo echo
echo "By default, exactness runs through test file running all tests specified." echo "By default, exactness runs through test file running all tests specified."
echo "You may run selected tests by adding test name as param to exactness." echo "You may run selected tests by adding test name as param to exactness."
echo "Usage:" echo "Usage:"
echo "\$0 -s TestsFile TestName1 [TestName2] [...]" echo "$0 -s TestsFile TestName1 [TestName2] [...]"
echo "Use this option to run selected tests without modifying your test file." echo "Use this option to run selected tests without modifying your test file."
echo "TestName param has to match test name given in tests file (1st field)" echo "TestName param has to match test name given in tests file (1st field)"
echo echo
echo echo
echo "Two additional parameters that \$0 accepts:" echo "Two additional parameters that $0 accepts:"
echo "BaseDir - This is where '.rec' files reside (gets pwd by default)" echo "BaseDir - This is where '.rec' files reside (gets pwd by default)"
echo "DestDir - Where \$0 creates test screen shots." echo "DestDir - Where $0 creates test screen shots."
echo " Gets 'current' under 'pwd' by default ('orig' on init)" echo " Gets 'current' under 'pwd' by default ('orig' on init)"
echo echo
echo echo
echo "Use the following options:" echo "Use the following options:"
echo "To record tests:" echo "To record tests:"
echo "\$0 -r [-b BaseDir] TestsFile" echo "$0 -r [-b BaseDir] TestsFile"
echo "Use BaseDir arg to create record files in specific folder." echo "Use BaseDir arg to create record files in specific folder."
echo "Otherwise pwd is used." echo "Otherwise pwd is used."
echo echo
@ -56,19 +50,19 @@ echo "'.rec' file is produced for each test in your TestsFile."
echo "File name is defined as 'TestName.rec' for each test." echo "File name is defined as 'TestName.rec' for each test."
echo echo
echo "You may test your record files with simulate option:" echo "You may test your record files with simulate option:"
echo "\$0 -s [-b BaseDir] TestsFile" echo "$0 -s [-b BaseDir] TestsFile"
echo echo
echo "You need to run \$0 with init option prior" echo "You need to run $0 with init option prior"
echo "to using play option." echo "to using play option."
echo "Later, when doing play, PNG files are compared with" echo "Later, when doing play, PNG files are compared with"
echo "PNG files reside in 'orig' folder create when init." echo "PNG files reside in 'orig' folder create when init."
echo echo
echo "To use init option:" echo "To use init option:"
echo "\$0 -i [-b BaseDir] TestsFile" echo "$0 -i [-b BaseDir] TestsFile"
echo "Do not use DestDir param with init, target always 'orig'." echo "Do not use DestDir param with init, target always 'orig'."
echo echo
echo "Use Play tests option to produce PNG files of screen shot:" echo "Use Play tests option to produce PNG files of screen shot:"
echo "\$0 -p [-b BaseDir] [-d DestDir] TestsFile" echo "$0 -p [-b BaseDir] [-d DestDir] TestsFile"
echo "Play option produces PNG files in DestDir." echo "Play option produces PNG files in DestDir."
echo "These are compares with PNGs in 'orig'." echo "These are compares with PNGs in 'orig'."
echo "(created in 'init' phase)" echo "(created in 'init' phase)"
@ -77,7 +71,7 @@ echo "Use -v option for detailed flow-report."
echo "Thus, when running many tests, the output format makes" echo "Thus, when running many tests, the output format makes"
echo "it easy to match output to a running test." echo "it easy to match output to a running test."
echo "Example:" echo "Example:"
echo "\$0 -v -p [-b BaseDir] [-d DestDir] TestsFile" echo "$0 -v -p [-b BaseDir] [-d DestDir] TestsFile"
} }
get_test_params () { get_test_params () {
@ -85,40 +79,40 @@ get_test_params () {
# reset globals # reset globals
_test_name= _test_name=
_test_cmd= _test_cmd=
local line="\$1" local line="$1"
local c=\${line:0:1} local c=${line:0:1}
if [ "\$c" = "#" ] if [ "$c" = "#" ]
then then
# This line is a comment # This line is a comment
return 1 return 1
fi fi
local p=\`expr index "\$line" \\ \` local p=\`expr index "$line" \\ \`
if [ \$p -ne 0 ] if [ $p -ne 0 ]
then then
(( p-- )) (( p-- ))
fi fi
_test_name=\${line:0:p} _test_name=${line:0:p}
(( p++ )) (( p++ ))
_test_cmd=\${line:p} _test_cmd=${line:p}
# Test that input is valid # Test that input is valid
if [ -z "\$_test_name" ] if [ -z "$_test_name" ]
then then
_test_name= _test_name=
_test_cmd= _test_cmd=
return 1 return 1
fi fi
if [ -z "\$_test_cmd" ] if [ -z "$_test_cmd" ]
then then
_test_name= _test_name=
_test_cmd= _test_cmd=
return 1 return 1
fi fi
DEBUG echo test name=\""\$_test_name"\" DEBUG echo test name=\""$_test_name"\"
DEBUG echo test cmd=\""\$_test_cmd"\" DEBUG echo test cmd=\""$_test_cmd"\"
return 0 return 0
} }
@ -127,152 +121,152 @@ DEBUG printf "do_record()\n"
# This will run record for all test if no specific test specified # This will run record for all test if no specific test specified
# or run recording of specified tests (names passed as parameter). # or run recording of specified tests (names passed as parameter).
# run ALL tests to record # run ALL tests to record
DEBUG echo do_record "\$*" DEBUG echo do_record "$*"
get_test_params "\$1" get_test_params "$1"
if [ \$? -ne 0 ] if [ $? -ne 0 ]
then then
return 0 return 0
fi fi
if [ "\$_verbose" -ne 0 ] if [ "$_verbose" -ne 0 ]
then then
echo "do_record: \$_test_name" echo "do_record: $_test_name"
fi fi
TSUITE_RECORDING='rec' TSUITE_BASE_DIR=\${_base_dir} TSUITE_DEST_DIR=\${_dest_dir} TSUITE_FILE_NAME=\${_base_dir}/\${_test_name}.rec TSUITE_TEST_NAME=\${_test_name} LD_PRELOAD=\${OUR_LIBPATH}/libexactness.so eval \${_test_cmd} TSUITE_RECORDING='rec' TSUITE_BASE_DIR=${_base_dir} TSUITE_DEST_DIR=${_dest_dir} TSUITE_FILE_NAME=${_base_dir}/${_test_name}.rec TSUITE_TEST_NAME=${_test_name} LD_PRELOAD=${OUR_LIBPATH}/libexactness.so eval ${_test_cmd}
} }
do_simulation () { do_simulation () {
# This will play simulation # This will play simulation
# this will NOT produce screenshots # this will NOT produce screenshots
DEBUG echo do_simulation "\$*" DEBUG echo do_simulation "$*"
get_test_params "\$1" get_test_params "$1"
if [ \$? -ne 0 ] if [ $? -ne 0 ]
then then
return 0 return 0
fi fi
local file_name=\${_base_dir}/\${_test_name}.rec local file_name=${_base_dir}/${_test_name}.rec
if [ ! -e "\$file_name" ] if [ ! -e "$file_name" ]
then then
echo Rec file "\$file_name" not found. echo Rec file "$file_name" not found.
return 1 return 1
fi fi
if [ "\$_verbose" -ne 0 ] if [ "$_verbose" -ne 0 ]
then then
echo "do_simulation: \$_test_name" echo "do_simulation: $_test_name"
fi fi
TSUITE_BASE_DIR=\${_base_dir} TSUITE_DEST_DIR=\${_dest_dir} TSUITE_FILE_NAME=\${file_name} TSUITE_TEST_NAME=\${_test_name} LD_PRELOAD=\${OUR_LIBPATH}/libexactness.so eval \${_test_cmd} TSUITE_BASE_DIR=${_base_dir} TSUITE_DEST_DIR=${_dest_dir} TSUITE_FILE_NAME=${file_name} TSUITE_TEST_NAME=${_test_name} LD_PRELOAD=${OUR_LIBPATH}/libexactness.so eval ${_test_cmd}
} }
do_play () { do_play () {
# This will play record for all test if '-a' specified. # This will play record for all test if '-a' specified.
# or play record of tests specified as parameter. # or play record of tests specified as parameter.
# run ALL tests to record # run ALL tests to record
DEBUG echo base dir: "\$_base_dir" DEBUG echo base dir: "$_base_dir"
DEBUG echo dest dir: "\$_dest_dir" DEBUG echo dest dir: "$_dest_dir"
DEBUG echo do_play "\$_dest_dir" "\$*" DEBUG echo do_play "$_dest_dir" "$*"
# Play recorded tests and produce PNG files. # Play recorded tests and produce PNG files.
# this will produce screenshots in "_dest_dir" folder # this will produce screenshots in "_dest_dir" folder
get_test_params "\$1" get_test_params "$1"
if [ \$? -ne 0 ] if [ $? -ne 0 ]
then then
return 0 return 0
fi fi
local file_name=\${_base_dir}/\${_test_name}.rec local file_name=${_base_dir}/${_test_name}.rec
if [ ! -e "\$file_name" ] if [ ! -e "$file_name" ]
then then
echo Rec file "\$file_name" not found. echo Rec file "$file_name" not found.
return 1 return 1
fi fi
if [ -e "\$_dest_dir" ] if [ -e "$_dest_dir" ]
then then
# Remove PNG files according to tests played # Remove PNG files according to tests played
rm "\$_dest_dir"/\${_test_name}_[0-9]*.png &> /dev/null rm "$_dest_dir"/${_test_name}_[0-9]*.png &> /dev/null
else else
# Create dest dir # Create dest dir
mkdir -p "\$_dest_dir" &> /dev/null mkdir -p "$_dest_dir" &> /dev/null
fi fi
if [ "\$_verbose" -ne 0 ] if [ "$_verbose" -ne 0 ]
then then
echo "do_play: \$_test_name" echo "do_play: $_test_name"
fi fi
ELM_ENGINE="buffer" TSUITE_BASE_DIR=\${_base_dir} TSUITE_DEST_DIR=\${_dest_dir} TSUITE_FILE_NAME=\${file_name} TSUITE_TEST_NAME=\${_test_name} LD_PRELOAD=\${OUR_LIBPATH}/libexactness.so eval \${_test_cmd} ELM_ENGINE="buffer" TSUITE_BASE_DIR=${_base_dir} TSUITE_DEST_DIR=${_dest_dir} TSUITE_FILE_NAME=${file_name} TSUITE_TEST_NAME=${_test_name} LD_PRELOAD=${OUR_LIBPATH}/libexactness.so eval ${_test_cmd}
} }
compare_files () { compare_files () {
if [ "\$_verbose" -ne 0 ] if [ "$_verbose" -ne 0 ]
then then
echo "compare_files: <\$1> and <\$2>" echo "compare_files: <$1> and <$2>"
fi fi
if [ -e "\$1" ] if [ -e "$1" ]
# First file exists # First file exists
then then
local md_file1=\`md5sum \$1\` local md_file1=\`md5sum $1\`
if [ -e "\$2" ] if [ -e "$2" ]
then then
# Second file exists # Second file exists
local md_file2=\`md5sum \$2\` local md_file2=\`md5sum $2\`
# Get md5 of both files # Get md5 of both files
local md1=\`echo "\$md_file1" | cut -d ' ' -f1\` local md1=\`echo "$md_file1" | cut -d ' ' -f1\`
local md2=\`echo "\$md_file2" | cut -d ' ' -f1\` local md2=\`echo "$md_file2" | cut -d ' ' -f1\`
# Increase counter of comparisons # Increase counter of comparisons
(( ncomp++ )) (( ncomp++ ))
# Compare md5 of both files # Compare md5 of both files
if [ "x\$md1" != "x\$md2" ] if [ "x$md1" != "x$md2" ]
then then
if [ \$comp_unavail -eq 0 ] if [ $comp_unavail -eq 0 ]
then then
# Create diff-file with 'comp_' prefix. # Create diff-file with 'comp_' prefix.
local name=\`basename "\$1"\` local name=\`basename "$1"\`
compare "\$1" "\$2" "\$_dest_dir"/comp_"\$name" compare "$1" "$2" "$_dest_dir"/comp_"$name"
else else
echo "\$name does not match." echo "$name does not match."
fi fi
# Increment counter of files not identical. # Increment counter of files not identical.
(( nfail++ )) (( nfail++ ))
fi fi
else else
# Failed to find second file # Failed to find second file
echo "Test file was not found \$2" echo "Test file was not found $2"
(( nerr++ )) (( nerr++ ))
fi fi
else else
# Failed to find first file # Failed to find first file
echo "Test file was not found \$1" echo "Test file was not found $1"
(( nerr++ )) (( nerr++ ))
fi fi
} }
process_compare () { process_compare () {
# Process all files listed in array (param) # Process all files listed in array (param)
local files_list=( "\$@" ) local files_list=( "$@" )
for line in "\${files_list[@]}" for line in "${files_list[@]}"
do do
local name=\`basename "\$line"\` local name=\`basename "$line"\`
DEBUG echo "comparing \$name" DEBUG echo "comparing $name"
compare_files "\$_orig_dir"/"\$name" "\$_dest_dir"/"\$name" compare_files "$_orig_dir"/"$name" "$_dest_dir"/"$name"
done done
} }
do_compare () { do_compare () {
DEBUG printf "do_compare()\n" DEBUG printf "do_compare()\n"
DEBUG echo orig dir: "\$_orig_dir" DEBUG echo orig dir: "$_orig_dir"
DEBUG echo dest dir: "\$_dest_dir" DEBUG echo dest dir: "$_dest_dir"
# This will compare files in 'orig' folder with files in _dest_dir # This will compare files in 'orig' folder with files in _dest_dir
if [ \$comp_unavail -ne 0 ] if [ $comp_unavail -ne 0 ]
then then
if [ \$# -eq 1 ] if [ $# -eq 1 ]
then then
echo "Compare software missing." echo "Compare software missing."
echo "Install \"ImageMagick\" if you like to procduce \"comp\" files." echo "Install \"ImageMagick\" if you like to procduce \"comp\" files."
@ -280,38 +274,38 @@ then
fi fi
fi fi
if [ -z "\$_dest_dir" ] if [ -z "$_dest_dir" ]
then then
printf "For comparing, Usage: %s -c -a -d DirName\nor\n%s -c -d DirName TestName1, TestName2,...\n" \$(basename \$0) \$(basename \$0) >&2 printf "For comparing, Usage: %s -c -a -d DirName\nor\n%s -c -d DirName TestName1, TestName2,...\n" $(basename $0) $(basename $0) >&2
fi fi
if [ "\$_dest_dir" = "\$_orig_dir" ] if [ "$_dest_dir" = "$_orig_dir" ]
then then
printf "Dest-Dir is \$_dest_dir, exiting.\n" printf "Dest-Dir is $_dest_dir, exiting.\n"
return 0 return 0
fi fi
local files_list= local files_list=
for test_name in \$* for test_name in $*
do do
rm "\$_dest_dir"/comp_"\$test_name"_[0-9]*.png &> /dev/null rm "$_dest_dir"/comp_"$test_name"_[0-9]*.png &> /dev/null
files_list=( \`ls "\$_dest_dir"/"\$test_name"_[0-9]*.png\` ) files_list=( \`ls "$_dest_dir"/"$test_name"_[0-9]*.png\` )
process_compare "\${files_list[@]}" process_compare "${files_list[@]}"
done done
if [ "\$ncomp" -ne 0 ] if [ "$ncomp" -ne 0 ]
then then
echo "Processed \$ncomp comparisons" echo "Processed $ncomp comparisons"
fi fi
if [ "\$nfail" -ne 0 ] if [ "$nfail" -ne 0 ]
then then
echo "with \$nfail diff errors" echo "with $nfail diff errors"
fi fi
if [ "\$nerr" -ne 0 ] if [ "$nerr" -ne 0 ]
then then
echo "\$nerr PNG-files were not found" echo "$nerr PNG-files were not found"
fi fi
return 0 return 0
@ -320,21 +314,21 @@ return 0
name_in_args () { name_in_args () {
# This function gets curline as first arg # This function gets curline as first arg
# Then list of args to find if test name is first field of curline # Then list of args to find if test name is first field of curline
get_test_params "\$1" get_test_params "$1"
if [ \$? -ne 0 ] if [ $? -ne 0 ]
then then
return 0 return 0
fi fi
if [ -z "\$_test_name" ] if [ -z "$_test_name" ]
then then
return 0 return 0
fi fi
shift shift
while (( "\$#" )); while (( "$#" ));
do do
if [ "\$_test_name" = "\$1" ] if [ "$_test_name" = "$1" ]
# found test name in list of args # found test name in list of args
then then
return 1 return 1
@ -348,7 +342,7 @@ return 0
} }
# Script Entry Point # Script Entry Point
OUR_LIBPATH="$1" OUR_LIBPATH="@libdir@/exactness"
_verbose=0 _verbose=0
_record= _record=
@ -372,16 +366,16 @@ _n_exe_err=0
# Test that compare is insatlled # Test that compare is insatlled
which compare &> /dev/null which compare &> /dev/null
comp_unavail=\$? comp_unavail=$?
while getopts 'ab:cd:hprisv?' OPTION while getopts 'ab:cd:hprisv?' OPTION
do do
case \$OPTION in case $OPTION in
b) _base_dir="\$OPTARG" b) _base_dir="$OPTARG"
;; ;;
c) _compare=1 c) _compare=1
;; ;;
d) _dest_dir="\$OPTARG" d) _dest_dir="$OPTARG"
;; ;;
p) _play=1 p) _play=1
_compare=1 _compare=1
@ -390,12 +384,12 @@ do
r) _record=1 r) _record=1
_remove_fail=1 _remove_fail=1
;; ;;
i) _dest_dir="\$_orig_dir" i) _dest_dir="$_orig_dir"
_init=1 _init=1
_play=1 _play=1
_remove_fail=1 _remove_fail=1
;; ;;
s) _dest_dir="\$_orig_dir" s) _dest_dir="$_orig_dir"
_simulation=1 _simulation=1
;; ;;
h) do_help h) do_help
@ -408,13 +402,13 @@ do
;; ;;
esac esac
done done
shift \$((\$OPTIND - 1)) shift $(($OPTIND - 1))
_test_file_name="\$1" _test_file_name="$1"
shift shift
# Test if user added test-names as arguments # Test if user added test-names as arguments
if [ ! -z "\$*" ] if [ ! -z "$*" ]
then then
_test_all=0 _test_all=0
fi fi
@ -422,12 +416,12 @@ fi
# when using -o option, we can loop now on tests names # when using -o option, we can loop now on tests names
# given as arguments to this script # given as arguments to this script
DEBUG echo _test_file_name="\$_test_file_name" DEBUG echo _test_file_name="$_test_file_name"
DEBUG echo _base_dir="\$_base_dir" DEBUG echo _base_dir="$_base_dir"
DEBUG echo _dest_dir="\$_dest_dir" DEBUG echo _dest_dir="$_dest_dir"
if [ "\$_simulation" ] if [ "$_simulation" ]
then then
# When in simulation mode, we will just commit play (ignore other options) # When in simulation mode, we will just commit play (ignore other options)
_init= _init=
@ -437,57 +431,57 @@ then
_play= _play=
while read curline; while read curline;
do do
name_in_args "\$curline" \$* name_in_args "$curline" $*
_run_test=\$(( \$? + \$_test_all )) _run_test=$(( $? + $_test_all ))
if [ \$_run_test -ne 0 ] if [ $_run_test -ne 0 ]
then then
do_simulation "\$curline" do_simulation "$curline"
if [ \$? -ne 0 ] if [ $? -ne 0 ]
then then
(( _n_exe_err++ )) (( _n_exe_err++ ))
fi fi
fi fi
done < "\$_test_file_name" done < "$_test_file_name"
# This will cause render simulation # This will cause render simulation
fi fi
if [ ! -e "\$_base_dir" ] if [ ! -e "$_base_dir" ]
then then
echo "Base dir <\$_base_dir> - not found." echo "Base dir <$_base_dir> - not found."
exit 1 exit 1
fi fi
# printf "Remaining arguments are: %s\n" "\$*" # printf "Remaining arguments are: %s\n" "$*"
if [ -z "\$_dest_dir" ] if [ -z "$_dest_dir" ]
then then
if [ ! -z "\$_play" ] if [ ! -z "$_play" ]
then then
_dest_dir="current" _dest_dir="current"
fi fi
if [ ! -z "\$_compare" ] if [ ! -z "$_compare" ]
then then
_dest_dir="current" _dest_dir="current"
fi fi
else else
if [ ! -z "\$_init" ] if [ ! -z "$_init" ]
then then
if [ "\$_dest_dir" != "\$_orig_dir" ] if [ "$_dest_dir" != "$_orig_dir" ]
then then
echo "Cannot use '-i' option with a DestDir that is not 'orig'" echo "Cannot use '-i' option with a DestDir that is not 'orig'"
echo "No need to specify DestDir when using '-i'" echo "No need to specify DestDir when using '-i'"
echo "For help: \$0 -h" echo "For help: $0 -h"
exit 2 exit 2
fi fi
fi fi
fi fi
if [ ! -z "\$_compare" ] if [ ! -z "$_compare" ]
then then
if [ "\$_dest_dir" = "\$_orig_dir" ] if [ "$_dest_dir" = "$_orig_dir" ]
then then
echo "Cannot use 'orig' dir with compare '-c' option" echo "Cannot use 'orig' dir with compare '-c' option"
echo "Please select different DestDir" echo "Please select different DestDir"
echo "For help: \$0 -h" echo "For help: $0 -h"
exit 3 exit 3
fi fi
fi fi
@ -495,113 +489,110 @@ fi
# Here we clear all fail_*.txt files before running test # Here we clear all fail_*.txt files before running test
# because those files are opened with append ("a") mode. # because those files are opened with append ("a") mode.
# We don't want to accumlate old tests fail text. # We don't want to accumlate old tests fail text.
if [ "\$_remove_fail" ] if [ "$_remove_fail" ]
then then
if [ -z "\$*" ] if [ -z "$*" ]
then then
# Remove all file_*.txt files before init/play/record # Remove all file_*.txt files before init/play/record
DEBUG echo "removing fail_*.txt" DEBUG echo "removing fail_*.txt"
rm fail_*.txt &> /dev/null rm fail_*.txt &> /dev/null
else else
# Remove file_*.txt files before init/play/record # Remove file_*.txt files before init/play/record
for i in \$* for i in $*
do do
DEBUG echo "removing fail_\$i.txt" DEBUG echo "removing fail_$i.txt"
rm fail_"\$i".txt &> /dev/null rm fail_"$i".txt &> /dev/null
done done
fi fi
fi fi
if [ "\$_record" ] if [ "$_record" ]
then then
while read curline; while read curline;
do do
name_in_args "\$curline" \$* name_in_args "$curline" $*
_run_test=\$(( \$? + \$_test_all )) _run_test=$(( $? + $_test_all ))
if [ \$_run_test -ne 0 ] if [ $_run_test -ne 0 ]
then then
do_record "\$curline" do_record "$curline"
if [ \$? -ne 0 ] if [ $? -ne 0 ]
then then
(( _n_exe_err++ )) (( _n_exe_err++ ))
fi fi
fi fi
done < "\$_test_file_name" done < "$_test_file_name"
fi fi
if [ "\$_play" ] if [ "$_play" ]
then then
while read curline; while read curline;
do do
name_in_args "\$curline" \$* name_in_args "$curline" $*
_run_test=\$(( \$? + \$_test_all )) _run_test=$(( $? + $_test_all ))
if [ \$_run_test -ne 0 ] if [ $_run_test -ne 0 ]
then then
do_play "\$curline" do_play "$curline"
if [ \$? -ne 0 ] if [ $? -ne 0 ]
then then
(( _n_exe_err++ )) (( _n_exe_err++ ))
fi fi
fi fi
done < "\$_test_file_name" done < "$_test_file_name"
fi fi
if [ "\$_compare" ] if [ "$_compare" ]
then then
while read curline; while read curline;
do do
name_in_args "\$curline" \$* name_in_args "$curline" $*
_run_test=\$(( \$? + \$_test_all )) _run_test=$(( $? + $_test_all ))
if [ \$_run_test -ne 0 ] if [ $_run_test -ne 0 ]
then then
get_test_params "\$curline" get_test_params "$curline"
if [ \$? -eq 0 ] if [ $? -eq 0 ]
then then
do_compare "\$_test_name" do_compare "$_test_name"
fi fi
fi fi
done < "\$_test_file_name" done < "$_test_file_name"
fi fi
_n_tests_failed=0 _n_tests_failed=0
if [ "\$_remove_fail" ] if [ "$_remove_fail" ]
then then
ls fail_*.txt &> /dev/null ls fail_*.txt &> /dev/null
if [ "\$?" -eq 0 ] if [ "$?" -eq 0 ]
then then
_n_tests_failed=\`ls fail_*.txt -1 | wc -l\` _n_tests_failed=\`ls fail_*.txt -1 | wc -l\`
if [ "\$_n_tests_failed" ] if [ "$_n_tests_failed" ]
then then
echo "\$_n_tests_failed tests had errors while running." echo "$_n_tests_failed tests had errors while running."
echo "Please examine fail_*.txt files in CWD" echo "Please examine fail_*.txt files in CWD"
fi fi
fi fi
fi fi
# Add up total-error and emit user message. # Add up total-error and emit user message.
total_errors=\$(( \$nfail + \$nerr + \$_n_tests_failed + \$_n_exe_err )) total_errors=$(( $nfail + $nerr + $_n_tests_failed + $_n_exe_err ))
echo "\$_n_exe_err tests returned exit-code <> 0" echo "$_n_exe_err tests returned exit-code <> 0"
echo "\$0 finished with \$total_errors errors." echo "$0 finished with $total_errors errors."
status=0 status=0
# Compute exit code # Compute exit code
if [ "\$nfail" -ne 0 ] if [ "$nfail" -ne 0 ]
then then
status=\$(( \$status | 1 )) status=$(( $status | 1 ))
fi fi
if [ "\$nerr" -ne 0 ] if [ "$nerr" -ne 0 ]
then then
status=\$(( \$status | 2 )) status=$(( $status | 2 ))
fi fi
if [ "\$_n_tests_failed" -ne 0 ] if [ "$_n_tests_failed" -ne 0 ]
then then
status=\$(( \$status | 4 )) status=$(( $status | 4 ))
fi fi
exit \$status exit $status
ENDOFMESSAGE
chmod +x exactness