archive_image_diff.sh 2.9 KB
#!/bin/sh -f

SIM="all"

##################################################
#
#  Usage message
#
##################################################
usage()
{
  echo "Usage: nightly_image_diff.sh <-s> simulator"
  echo "  Simulator: c, cv, io, gate, all, default = all"
  exit 0
}

##################################################
#
#  Compare .rgb, .cov, and .z files
#
#  $1 = file prefix
#  $2 = compare type
#
##################################################
compare_function()
{
	for sufx in  rgb cov z 
	do
	    f1=OutData/${1}_${2}_0.${sufx}

	    if [ $2 -eq "gate" ] 
            then
	      f2=OutData/${1}_io_0.${sufx}.archive
            else
	      f2=${f1}.archive
	    fi

	    df=${1}_${2}_idf.${sufx}

            if [ -r $f1 -a -r $f2 ]
	    then
		../../tools/iclr $f1 
	        if cmp -s $f1 $f2
	        then
	            echo "INFO:  ${sufx} equate."
	        else
	            echo "ERROR: ${sufx} differ. Diff generated as $df."
	            idf -d $f1 $f2 $df
	            if [ $? -eq 0 ]
	            then
		        echo "HINT:  Differences probably SOLELY due to dithering."
	            fi
	        fi
	    else
	        if [ ! -r $f1 ]
	        then
	          echo "ERROR: $f1 not present or not readable."
		fi
	
	        if [ ! -r $f2 ]
		then
	          echo "ERROR: $f2 not present or not readable."
		fi
	    fi
	done
}
   
##################################################
#
#  Parse options
#
##################################################
    while getopts "s:" a
    do
      case $a in
        s)  SIM=$OPTARG;;
        \?) usage ;;
      esac
    done
    shift `expr $OPTIND - 1`


###############################################################################
#
# For each incoming arg, generate file names by appending appropriate suffixes,
# use iclr to strip out garbage from the image file header, then use cmp to
# compare the resulting binary data.  If a difference is detected, use idf -d
# to generate a viewable difference file, and to determine whether or not the
# differences are == 0x08, which are usually attributable to dithering.
#
###############################################################################
    echo "\n"
    echo "#"
    echo "# Compare of image files generated from ${SIM}sim to archived files"
    echo "# `date`"
    echo "#"

    for fprefix do

      echo "INFO:  ==============  $fprefix  =============="
      #
      #  C compares
      #

      if [ $SIM = "c" -o $SIM = "all" ]
      then
	  compare_function $fprefix "c"
      fi

      #
      #  IO compares
      #

      if [ $SIM = "io" -o $SIM = "all" ]
      then
	  compare_function $fprefix "io"
      fi

      #
      #  GATE compares
      #

      if [ $SIM = "gate" -o $SIM = "all" ]
      then
	  compare_function $fprefix "gate"
      fi

      #
      #  CV compares
      #

      if [ $SIM = "cv" -o $SIM = "all" ]
      then
	  compare_function $fprefix "cv"
      fi

      echo "\n"
    done