nightly_image_diff.sh 3.79 KB
#!/bin/sh -f

SIM="all"
USE_BB_FILES=""

##################################################
#
#  Usage message
#
##################################################
usage()
{
  echo "Usage: nightly_image_diff.sh <-s> simulator"
  echo "  Simulator: cio, ccv, cvio, all, default = all"
  exit 0
}

##################################################
#
#  Compare .rgb, .cov, and .z files
#
#  $1 = file prefix
#  $2 = compare type
#
##################################################
compare_function()
{
	fprefix=$1
        if [ "$USE_BB_FILES" = "TRUE" ]
        then
            if [ $2 = "cio" ]
            then
                t1="bb_c"
                t2="bb_io"
            elif [ $2 = "ccv" ]
            then
                t1="bb_c"
                t2="bb_cv"
            elif [ $2 = "cvio" ]
            then
                t1="bb_cv"
                t2="bb_io"
	    elif [ $2 = "hwio" ]
	    then 
		# Compare iosim with hardware results
		t1="hw"
		t2="bb_io"
            fi
        else
            if [ $2 = "cio" ]
            then
	      t1="c"
	      t2="io"
	    elif [ $2 = "ccv" ]
	    then
	      t1="c"
	      t2="cv"
	    elif [ $2 = "cvio" ]
	    then
	      t1="cv"
	      t2="io"
	    fi
        fi
	t3=""

	for sufx in  rgb cov z 
	do
	    echo "       /* $sufx */"
	    f1=OutData/${fprefix}_${t1}${t3}_0.${sufx}
	    f2=OutData/${fprefix}_${t2}${t3}_0.${sufx}
	    df=${fprefix}_idf_${t1}_${t2}.${sufx}

            if [ -r $f1 -a -r $f2 ]
	    then
		../../tools/iclr $f1 
		../../tools/iclr $f2
	        if cmp -s $f1 $f2
	        then
	            echo "INFO:  Image files $f1 and $f2 equate."
	        else
	            $ROOT/usr/sbin/idf -d $f1 $f2 $df
	            if [ $? -eq 0 ]
	            then
			echo "WARING: Image files $f1 and $f2 differ."
                        echo "    Difference file generated as $df."
		        echo "    Differences probably SOLELY due to dithering."
	            else
			echo "ERROR: Image files $f1 and $f2 differ."
                        echo "    Difference file generated as $df."
	            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:b" a
    do
      case $a in
        s)  SIM=$OPTARG;;
        b)  USE_BB_FILES=TRUE;;
        \?) 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

    for fprefix do

      echo "==============  $fprefix  =============="
      #
      #  C/CV compares
      #

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

      #
      #  C/IO compares
      #

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

      #
      #  CV/IO compares
      #

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

      if [ $SIM = "hwio" ]
      then
	  compare_function $fprefix "hwio"
      fi

      echo "\n"
    done