tasn pushed a commit to branch master.

commit bf5f58931003c74d03034b7bc39ef7795a1c655f
Author: Tom Hacohen <[email protected]>
Date:   Fri Apr 26 10:25:57 2013 +0100

    Fixed up indentation and some general style.
---
 src/scripts/exactness.in | 407 +++++++++++++++++++++++------------------------
 1 file changed, 203 insertions(+), 204 deletions(-)

diff --git a/src/scripts/exactness.in b/src/scripts/exactness.in
index 43e0469..05635ae 100755
--- a/src/scripts/exactness.in
+++ b/src/scripts/exactness.in
@@ -9,7 +9,7 @@
 #_DEBUG="on"
 function DEBUG()
 {
-   [ "$_DEBUG" == "on" ] &&  $@
+   [ "$_DEBUG" == "on" ] && $@
 }
 
 do_help () {
@@ -75,177 +75,176 @@ 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
-   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
+   # This function analyze input line and sets test-file-name, rec-file-name
+   # reset globals
    _test_name=
    _test_cmd=
-   return 1
-fi
+   local line="$1"
+   local c=${line:0:1}
+   if [ "$c" = "#" ]
+   then
+      return 1
+   fi
 
-if [ -z "$_test_cmd" ]
-then
-   _test_name=
-   _test_cmd=
-   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}
 
-DEBUG echo test name=\""$_test_name"\"
-DEBUG echo test cmd=\""$_test_cmd"\"
-return 0
+   # Test that input is valid
+   if [ -z "$_test_name" ]
+   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 () {
-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
+   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
 
-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}
+   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}
 }
 
 do_simulation () {
-# This will play simulation
-# this will NOT produce screenshots
-DEBUG echo do_simulation "$*"
-get_test_params "$1"
-if [ $? -ne 0 ]
-then
-   return 0
-fi
+   # This will play simulation
+   # this will NOT produce screenshots
+   DEBUG echo do_simulation "$*"
+   get_test_params "$1"
+   if [ $? -ne 0 ]
+   then
+      return 0
+   fi
 
-local file_name=${_base_dir}/${_test_name}.rec
+   local file_name=${_base_dir}/${_test_name}.rec
 
-if [ ! -e "$file_name" ]
-then
-   echo Rec file "$file_name" not found.
-   return 1
-fi
+   if [ ! -e "$file_name" ]
+   then
+      echo Rec file "$file_name" not found.
+      return 1
+   fi
 
 
-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}
+   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}
 }
 
 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
-   return 0
-fi
+   # 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
 
-local file_name=${_base_dir}/${_test_name}.rec
+   local file_name=${_base_dir}/${_test_name}.rec
 
-if [ ! -e "$file_name" ]
-then
-   echo Rec file "$file_name" not found.
-   return 1
-fi
+   if [ ! -e "$file_name" ]
+   then
+      echo Rec file "$file_name" not found.
+      return 1
+   fi
 
-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
-   mkdir -p "$_dest_dir" &> /dev/null
-fi
+   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
+      mkdir -p "$_dest_dir" &> /dev/null
+   fi
 
-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}
+   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}
 }
 
 compare_files () {
-if [ "$_verbose" -ne 0 ]
-then
-   echo "compare_files: <$1> and <$2>"
-fi
+   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" ]
+   if [ -e "$1" ]
+      # First file exists
    then
-# Second file exists
-      local md_file2=\`md5sum $2\`
+      local md_file1=\`md5sum $1\`
+      if [ -e "$2" ]
+      then
+         # 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\`
+         # 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++ ))
+         # Increase counter of comparisons
+         (( ncomp++ ))
 
-      # Compare md5 of both files
-      if [ "x$md1" != "x$md2" ]
-      then
-         if [ $comp_unavail -eq 0 ]
+         # Compare md5 of both files
+         if [ "x$md1" != "x$md2" ]
          then
-            # Create diff-file with 'comp_' prefix.
-            local name=\`basename "$1"\`
-            compare "$1" "$2" "$_dest_dir"/comp_"$name"
-         else
-            echo "$name does not match."
+            if [ $comp_unavail -eq 0 ]
+            then
+               # Create diff-file with 'comp_' prefix.
+               local name=\`basename "$1"\`
+               compare "$1" "$2" "$_dest_dir"/comp_"$name"
+            else
+               echo "$name does not match."
+            fi
+            # Increment counter of files not identical.
+            (( nfail++ ))
          fi
-# Increment counter of files not identical.
-         (( nfail++ ))
+      else
+         # Failed to find second file
+         echo "Test file was not found $2"
+         (( nerr++ ))
       fi
    else
-# Failed to find second file
-      echo "Test file was not found $2"
+      # Failed to find first file
+      echo "Test file was not found $1"
       (( nerr++ ))
    fi
-else
-# Failed to find first file
-   echo "Test file was not found $1"
-   (( nerr++ ))
-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
-   if [ $# -eq 1  ]
+   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
-      echo "Compare software missing."
-      echo "Install \"ImageMagick\" if you like to procduce \"comp\" files."
-      echo "Printing diffs to output"
+      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
-   printf "Dest-Dir is $_dest_dir, exiting.\n"
-   return 0
-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
+   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 [ "$ncomp" -ne 0 ]
+   then
+      echo "Processed $ncomp comparisons"
+   fi
 
-if [ "$nfail" -ne 0 ]
-then
-   echo "with $nfail diff errors"
-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 [ "$nerr" -ne 0 ]
+   then
+      echo "$nerr PNG-files were not found"
+   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
-   return 0
-fi
-
-if [ -z "$_test_name" ]
-then
-   return 0
-fi
+   # 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
 
-shift
-while (( "$#" ));
-do
-   if [ "$_test_name" = "$1" ]
-# found test name in list of args
+   if [ -z "$_test_name" ]
    then
-      return 1
+      return 0
    fi
 
    shift
-done
+   while (( "$#" ));
+   do
+      if [ "$_test_name" = "$1" ]
+         # found test name in list of args
+      then
+         return 1
+      fi
+
+      shift
+   done
 
-# Not found
-return 0
+   # Not found
+   return 0
 }
 
 # Script Entry Point
@@ -378,16 +377,16 @@ do
       d)  _dest_dir="$OPTARG"
          ;;
       p)  _play=1
-          _compare=1
-          _remove_fail=1
+         _compare=1
+         _remove_fail=1
          ;;
       r)  _record=1
-          _remove_fail=1
+         _remove_fail=1
          ;;
       i)  _dest_dir="$_orig_dir"
-          _init=1
-          _play=1
-          _remove_fail=1
+         _init=1
+         _play=1
+         _remove_fail=1
          ;;
       s)  _dest_dir="$_orig_dir"
          _simulation=1
@@ -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" ]

-- 

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr

Reply via email to