Fixed up indentation and some general style.
This commit is contained in:
parent
802baf489f
commit
bf5f589310
|
@ -9,7 +9,7 @@
|
||||||
#_DEBUG="on"
|
#_DEBUG="on"
|
||||||
function DEBUG()
|
function DEBUG()
|
||||||
{
|
{
|
||||||
[ "$_DEBUG" == "on" ] && $@
|
[ "$_DEBUG" == "on" ] && $@
|
||||||
}
|
}
|
||||||
|
|
||||||
do_help () {
|
do_help () {
|
||||||
|
@ -75,177 +75,176 @@ echo "$0 -v -p [-b BaseDir] [-d DestDir] TestsFile"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_test_params () {
|
get_test_params () {
|
||||||
# This function analyze input line and sets test-file-name, rec-file-name
|
# This function analyze input line and sets test-file-name, rec-file-name
|
||||||
# reset globals
|
# reset globals
|
||||||
_test_name=
|
|
||||||
_test_cmd=
|
|
||||||
local line="$1"
|
|
||||||
local c=${line:0:1}
|
|
||||||
if [ "$c" = "#" ]
|
|
||||||
then
|
|
||||||
# This line is a comment
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local p=\`expr index "$line" \\ \`
|
|
||||||
if [ $p -ne 0 ]
|
|
||||||
then
|
|
||||||
(( p-- ))
|
|
||||||
fi
|
|
||||||
_test_name=${line:0:p}
|
|
||||||
(( p++ ))
|
|
||||||
_test_cmd=${line:p}
|
|
||||||
|
|
||||||
# Test that input is valid
|
|
||||||
if [ -z "$_test_name" ]
|
|
||||||
then
|
|
||||||
_test_name=
|
_test_name=
|
||||||
_test_cmd=
|
_test_cmd=
|
||||||
return 1
|
local line="$1"
|
||||||
fi
|
local c=${line:0:1}
|
||||||
|
if [ "$c" = "#" ]
|
||||||
|
then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$_test_cmd" ]
|
local p=\`expr index "$line" \\ \`
|
||||||
then
|
if [ $p -ne 0 ]
|
||||||
_test_name=
|
then
|
||||||
_test_cmd=
|
(( p-- ))
|
||||||
return 1
|
fi
|
||||||
fi
|
_test_name=${line:0:p}
|
||||||
|
(( p++ ))
|
||||||
|
_test_cmd=${line:p}
|
||||||
|
|
||||||
DEBUG echo test name=\""$_test_name"\"
|
# Test that input is valid
|
||||||
DEBUG echo test cmd=\""$_test_cmd"\"
|
if [ -z "$_test_name" ]
|
||||||
return 0
|
then
|
||||||
|
_test_name=
|
||||||
|
_test_cmd=
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$_test_cmd" ]
|
||||||
|
then
|
||||||
|
_test_name=
|
||||||
|
_test_cmd=
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
DEBUG echo test name=\""$_test_name"\"
|
||||||
|
DEBUG echo test cmd=\""$_test_cmd"\"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
do_record () {
|
do_record () {
|
||||||
DEBUG printf "do_record()\n"
|
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
|
|
||||||
echo "compare_files: <$1> and <$2>"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e "$1" ]
|
|
||||||
# First file exists
|
|
||||||
then
|
|
||||||
local md_file1=\`md5sum $1\`
|
|
||||||
if [ -e "$2" ]
|
|
||||||
then
|
then
|
||||||
# Second file exists
|
echo "compare_files: <$1> and <$2>"
|
||||||
local md_file2=\`md5sum $2\`
|
fi
|
||||||
|
|
||||||
# Get md5 of both files
|
if [ -e "$1" ]
|
||||||
local md1=\`echo "$md_file1" | cut -d ' ' -f1\`
|
# First file exists
|
||||||
local md2=\`echo "$md_file2" | cut -d ' ' -f1\`
|
then
|
||||||
|
local md_file1=\`md5sum $1\`
|
||||||
# Increase counter of comparisons
|
if [ -e "$2" ]
|
||||||
(( ncomp++ ))
|
|
||||||
|
|
||||||
# Compare md5 of both files
|
|
||||||
if [ "x$md1" != "x$md2" ]
|
|
||||||
then
|
then
|
||||||
if [ $comp_unavail -eq 0 ]
|
# Second file exists
|
||||||
|
local md_file2=\`md5sum $2\`
|
||||||
|
|
||||||
|
# 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
|
||||||
|
(( ncomp++ ))
|
||||||
|
|
||||||
|
# Compare md5 of both files
|
||||||
|
if [ "x$md1" != "x$md2" ]
|
||||||
then
|
then
|
||||||
# Create diff-file with 'comp_' prefix.
|
if [ $comp_unavail -eq 0 ]
|
||||||
local name=\`basename "$1"\`
|
then
|
||||||
compare "$1" "$2" "$_dest_dir"/comp_"$name"
|
# Create diff-file with 'comp_' prefix.
|
||||||
else
|
local name=\`basename "$1"\`
|
||||||
echo "$name does not match."
|
compare "$1" "$2" "$_dest_dir"/comp_"$name"
|
||||||
|
else
|
||||||
|
echo "$name does not match."
|
||||||
|
fi
|
||||||
|
# Increment counter of files not identical.
|
||||||
|
(( nfail++ ))
|
||||||
fi
|
fi
|
||||||
# Increment counter of files not identical.
|
else
|
||||||
(( nfail++ ))
|
# Failed to find second file
|
||||||
|
echo "Test file was not found $2"
|
||||||
|
(( nerr++ ))
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Failed to find second file
|
# Failed to find first file
|
||||||
echo "Test file was not found $2"
|
echo "Test file was not found $1"
|
||||||
(( nerr++ ))
|
(( nerr++ ))
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
# Failed to find first file
|
|
||||||
echo "Test file was not found $1"
|
|
||||||
(( nerr++ ))
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process_compare () {
|
process_compare () {
|
||||||
|
@ -260,85 +259,85 @@ process_compare () {
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
if [ $# -eq 1 ]
|
|
||||||
then
|
then
|
||||||
echo "Compare software missing."
|
if [ $# -eq 1 ]
|
||||||
echo "Install \"ImageMagick\" if you like to procduce \"comp\" files."
|
then
|
||||||
echo "Printing diffs to output"
|
echo "Compare software missing."
|
||||||
|
echo "Install \"ImageMagick\" if you like to procduce \"comp\" files."
|
||||||
|
echo "Printing diffs to output"
|
||||||
|
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" ]
|
||||||
|
then
|
||||||
|
printf "Dest-Dir is $_dest_dir, exiting.\n"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if [ "$ncomp" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "Processed $ncomp comparisons"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$nfail" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "with $nfail diff errors"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$nerr" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "$nerr PNG-files were not found"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$_dest_dir" = "$_orig_dir" ]
|
|
||||||
then
|
|
||||||
printf "Dest-Dir is $_dest_dir, exiting.\n"
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
if [ "$ncomp" -ne 0 ]
|
|
||||||
then
|
|
||||||
echo "Processed $ncomp comparisons"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$nfail" -ne 0 ]
|
|
||||||
then
|
|
||||||
echo "with $nfail diff errors"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$nerr" -ne 0 ]
|
|
||||||
then
|
|
||||||
echo "$nerr PNG-files were not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
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
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$_test_name" ]
|
|
||||||
then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
shift
|
|
||||||
while (( "$#" ));
|
|
||||||
do
|
|
||||||
if [ "$_test_name" = "$1" ]
|
|
||||||
# found test name in list of args
|
|
||||||
then
|
then
|
||||||
return 1
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$_test_name" ]
|
||||||
|
then
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shift
|
shift
|
||||||
done
|
while (( "$#" ));
|
||||||
|
do
|
||||||
|
if [ "$_test_name" = "$1" ]
|
||||||
|
# found test name in list of args
|
||||||
|
then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Not found
|
shift
|
||||||
return 0
|
done
|
||||||
|
|
||||||
|
# Not found
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Script Entry Point
|
# Script Entry Point
|
||||||
|
@ -378,16 +377,16 @@ do
|
||||||
d) _dest_dir="$OPTARG"
|
d) _dest_dir="$OPTARG"
|
||||||
;;
|
;;
|
||||||
p) _play=1
|
p) _play=1
|
||||||
_compare=1
|
_compare=1
|
||||||
_remove_fail=1
|
_remove_fail=1
|
||||||
;;
|
;;
|
||||||
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
|
||||||
|
@ -423,7 +422,7 @@ 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=
|
||||||
_record=
|
_record=
|
||||||
_compare=
|
_compare=
|
||||||
|
@ -442,7 +441,7 @@ then
|
||||||
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" ]
|
||||||
|
|
Loading…
Reference in New Issue