Fixed up indentation and some general style.
This commit is contained in:
parent
802baf489f
commit
bf5f589310
|
@ -75,151 +75,150 @@ echo "$0 -v -p [-b BaseDir] [-d DestDir] TestsFile"
|
|||
}
|
||||
|
||||
get_test_params () {
|
||||
# This function analyze input line and sets test-file-name, rec-file-name
|
||||
# reset globals
|
||||
_test_name=
|
||||
_test_cmd=
|
||||
local line="$1"
|
||||
local c=${line:0:1}
|
||||
if [ "$c" = "#" ]
|
||||
then
|
||||
# This line is a comment
|
||||
# This function analyze input line and sets test-file-name, rec-file-name
|
||||
# reset globals
|
||||
_test_name=
|
||||
_test_cmd=
|
||||
local line="$1"
|
||||
local c=${line:0:1}
|
||||
if [ "$c" = "#" ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local p=\`expr index "$line" \\ \`
|
||||
if [ $p -ne 0 ]
|
||||
then
|
||||
local p=\`expr index "$line" \\ \`
|
||||
if [ $p -ne 0 ]
|
||||
then
|
||||
(( p-- ))
|
||||
fi
|
||||
_test_name=${line:0:p}
|
||||
(( p++ ))
|
||||
_test_cmd=${line:p}
|
||||
fi
|
||||
_test_name=${line:0:p}
|
||||
(( p++ ))
|
||||
_test_cmd=${line:p}
|
||||
|
||||
# Test that input is valid
|
||||
if [ -z "$_test_name" ]
|
||||
then
|
||||
# Test that input is valid
|
||||
if [ -z "$_test_name" ]
|
||||
then
|
||||
_test_name=
|
||||
_test_cmd=
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$_test_cmd" ]
|
||||
then
|
||||
if [ -z "$_test_cmd" ]
|
||||
then
|
||||
_test_name=
|
||||
_test_cmd=
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
DEBUG echo test name=\""$_test_name"\"
|
||||
DEBUG echo test cmd=\""$_test_cmd"\"
|
||||
return 0
|
||||
DEBUG echo test name=\""$_test_name"\"
|
||||
DEBUG echo test cmd=\""$_test_cmd"\"
|
||||
return 0
|
||||
}
|
||||
|
||||
do_record () {
|
||||
DEBUG printf "do_record()\n"
|
||||
# This will run record for all test if no specific test specified
|
||||
# or run recording of specified tests (names passed as parameter).
|
||||
# run ALL tests to record
|
||||
DEBUG echo do_record "$*"
|
||||
get_test_params "$1"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
DEBUG printf "do_record()\n"
|
||||
# This will run record for all test if no specific test specified
|
||||
# or run recording of specified tests (names passed as parameter).
|
||||
# run ALL tests to record
|
||||
DEBUG echo do_record "$*"
|
||||
get_test_params "$1"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$_verbose" -ne 0 ]
|
||||
then
|
||||
if [ "$_verbose" -ne 0 ]
|
||||
then
|
||||
echo "do_record: $_test_name"
|
||||
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}
|
||||
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}
|
||||
}
|
||||
|
||||
do_simulation () {
|
||||
# This will play simulation
|
||||
# this will NOT produce screenshots
|
||||
DEBUG echo do_simulation "$*"
|
||||
get_test_params "$1"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
# This will play simulation
|
||||
# this will NOT produce screenshots
|
||||
DEBUG echo do_simulation "$*"
|
||||
get_test_params "$1"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
local file_name=${_base_dir}/${_test_name}.rec
|
||||
local file_name=${_base_dir}/${_test_name}.rec
|
||||
|
||||
if [ ! -e "$file_name" ]
|
||||
then
|
||||
if [ ! -e "$file_name" ]
|
||||
then
|
||||
echo Rec file "$file_name" not found.
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$_verbose" -ne 0 ]
|
||||
then
|
||||
if [ "$_verbose" -ne 0 ]
|
||||
then
|
||||
echo "do_simulation: $_test_name"
|
||||
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}
|
||||
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}
|
||||
}
|
||||
|
||||
do_play () {
|
||||
# This will play record for all test if '-a' specified.
|
||||
# or play record of tests specified as parameter.
|
||||
# run ALL tests to record
|
||||
DEBUG echo base dir: "$_base_dir"
|
||||
DEBUG echo dest dir: "$_dest_dir"
|
||||
DEBUG echo do_play "$_dest_dir" "$*"
|
||||
# Play recorded tests and produce PNG files.
|
||||
# this will produce screenshots in "_dest_dir" folder
|
||||
get_test_params "$1"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
# This will play record for all test if '-a' specified.
|
||||
# or play record of tests specified as parameter.
|
||||
# run ALL tests to record
|
||||
DEBUG echo base dir: "$_base_dir"
|
||||
DEBUG echo dest dir: "$_dest_dir"
|
||||
DEBUG echo do_play "$_dest_dir" "$*"
|
||||
# Play recorded tests and produce PNG files.
|
||||
# this will produce screenshots in "_dest_dir" folder
|
||||
get_test_params "$1"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
local file_name=${_base_dir}/${_test_name}.rec
|
||||
local file_name=${_base_dir}/${_test_name}.rec
|
||||
|
||||
if [ ! -e "$file_name" ]
|
||||
then
|
||||
if [ ! -e "$file_name" ]
|
||||
then
|
||||
echo Rec file "$file_name" not found.
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "$_dest_dir" ]
|
||||
then
|
||||
# Remove PNG files according to tests played
|
||||
if [ -e "$_dest_dir" ]
|
||||
then
|
||||
# Remove PNG files according to tests played
|
||||
rm "$_dest_dir"/${_test_name}_[0-9]*.png &> /dev/null
|
||||
else
|
||||
# Create dest dir
|
||||
else
|
||||
# Create dest dir
|
||||
mkdir -p "$_dest_dir" &> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$_verbose" -ne 0 ]
|
||||
then
|
||||
if [ "$_verbose" -ne 0 ]
|
||||
then
|
||||
echo "do_play: $_test_name"
|
||||
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}
|
||||
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}
|
||||
}
|
||||
|
||||
compare_files () {
|
||||
if [ "$_verbose" -ne 0 ]
|
||||
then
|
||||
if [ "$_verbose" -ne 0 ]
|
||||
then
|
||||
echo "compare_files: <$1> and <$2>"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "$1" ]
|
||||
# First file exists
|
||||
then
|
||||
if [ -e "$1" ]
|
||||
# First file exists
|
||||
then
|
||||
local md_file1=\`md5sum $1\`
|
||||
if [ -e "$2" ]
|
||||
then
|
||||
# Second file exists
|
||||
# Second file exists
|
||||
local md_file2=\`md5sum $2\`
|
||||
|
||||
# Get md5 of both files
|
||||
# Get md5 of both files
|
||||
local md1=\`echo "$md_file1" | cut -d ' ' -f1\`
|
||||
local md2=\`echo "$md_file2" | cut -d ' ' -f1\`
|
||||
|
||||
# Increase counter of comparisons
|
||||
# Increase counter of comparisons
|
||||
(( ncomp++ ))
|
||||
|
||||
# Compare md5 of both files
|
||||
|
@ -233,19 +232,19 @@ then
|
|||
else
|
||||
echo "$name does not match."
|
||||
fi
|
||||
# Increment counter of files not identical.
|
||||
# Increment counter of files not identical.
|
||||
(( nfail++ ))
|
||||
fi
|
||||
else
|
||||
# Failed to find second file
|
||||
# Failed to find second file
|
||||
echo "Test file was not found $2"
|
||||
(( nerr++ ))
|
||||
fi
|
||||
else
|
||||
# Failed to find first file
|
||||
else
|
||||
# Failed to find first file
|
||||
echo "Test file was not found $1"
|
||||
(( nerr++ ))
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
process_compare () {
|
||||
|
@ -260,85 +259,85 @@ process_compare () {
|
|||
}
|
||||
|
||||
do_compare () {
|
||||
DEBUG printf "do_compare()\n"
|
||||
DEBUG echo orig dir: "$_orig_dir"
|
||||
DEBUG echo dest dir: "$_dest_dir"
|
||||
# This will compare files in 'orig' folder with files in _dest_dir
|
||||
if [ $comp_unavail -ne 0 ]
|
||||
then
|
||||
DEBUG printf "do_compare()\n"
|
||||
DEBUG echo orig dir: "$_orig_dir"
|
||||
DEBUG echo dest dir: "$_dest_dir"
|
||||
# This will compare files in 'orig' folder with files in _dest_dir
|
||||
if [ $comp_unavail -ne 0 ]
|
||||
then
|
||||
if [ $# -eq 1 ]
|
||||
then
|
||||
echo "Compare software missing."
|
||||
echo "Install \"ImageMagick\" if you like to procduce \"comp\" files."
|
||||
echo "Printing diffs to output"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$_dest_dir" ]
|
||||
then
|
||||
if [ -z "$_dest_dir" ]
|
||||
then
|
||||
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" ]
|
||||
then
|
||||
if [ "$_dest_dir" = "$_orig_dir" ]
|
||||
then
|
||||
printf "Dest-Dir is $_dest_dir, exiting.\n"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
local files_list=
|
||||
for test_name in $*
|
||||
do
|
||||
local files_list=
|
||||
for test_name in $*
|
||||
do
|
||||
rm "$_dest_dir"/comp_"$test_name"_[0-9]*.png &> /dev/null
|
||||
files_list=( \`ls "$_dest_dir"/"$test_name"_[0-9]*.png\` )
|
||||
process_compare "${files_list[@]}"
|
||||
done
|
||||
done
|
||||
|
||||
if [ "$ncomp" -ne 0 ]
|
||||
then
|
||||
if [ "$ncomp" -ne 0 ]
|
||||
then
|
||||
echo "Processed $ncomp comparisons"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$nfail" -ne 0 ]
|
||||
then
|
||||
if [ "$nfail" -ne 0 ]
|
||||
then
|
||||
echo "with $nfail diff errors"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$nerr" -ne 0 ]
|
||||
then
|
||||
if [ "$nerr" -ne 0 ]
|
||||
then
|
||||
echo "$nerr PNG-files were not found"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
return 0
|
||||
}
|
||||
|
||||
name_in_args () {
|
||||
# This function gets curline as first arg
|
||||
# Then list of args to find if test name is first field of curline
|
||||
get_test_params "$1"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
# This function gets curline as first arg
|
||||
# Then list of args to find if test name is first field of curline
|
||||
get_test_params "$1"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$_test_name" ]
|
||||
then
|
||||
if [ -z "$_test_name" ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
shift
|
||||
while (( "$#" ));
|
||||
do
|
||||
shift
|
||||
while (( "$#" ));
|
||||
do
|
||||
if [ "$_test_name" = "$1" ]
|
||||
# found test name in list of args
|
||||
# found test name in list of args
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
done
|
||||
|
||||
# Not found
|
||||
return 0
|
||||
# Not found
|
||||
return 0
|
||||
}
|
||||
|
||||
# Script Entry Point
|
||||
|
@ -423,7 +422,7 @@ DEBUG echo _dest_dir="$_dest_dir"
|
|||
|
||||
if [ "$_simulation" ]
|
||||
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=
|
||||
_record=
|
||||
_compare=
|
||||
|
@ -442,7 +441,7 @@ then
|
|||
fi
|
||||
fi
|
||||
done < "$_test_file_name"
|
||||
# This will cause render simulation
|
||||
# This will cause render simulation
|
||||
fi
|
||||
|
||||
if [ ! -e "$_base_dir" ]
|
||||
|
|
Loading…
Reference in New Issue