[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: Makefile.am



  User: danmc   
  Date: 07/04/13 23:18:22

  Added:       .        Makefile.am README.txt run_tests.sh tests.list
  Log:
  add refdes_renum testsuite
  
  
  
  
  Revision  Changes    Path
  1.1                  eda/geda/gaf/utils/tests/refdes_renum/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  ## $Id: Makefile.am,v 1.1 2007/04/14 03:18:20 danmc Exp $
  ##
  
  SUBDIRS= inputs outputs
  
  TESTS_ENVIRONMENT= PERL=${PERL}
  
  RUN_TESTS= run_tests.sh
  
  check_SCRIPTS= ${RUN_TESTS}
  
  TESTS= ${RUN_TESTS}
  
  EXTRA_DIST= ${RUN_TESTS} tests.list README.txt
  
  
  
  
  1.1                  eda/geda/gaf/utils/tests/refdes_renum/README.txt
  
  Index: README.txt
  ===================================================================
  # $Id: README.txt,v 1.1 2007/04/14 03:18:20 danmc Exp $
  #
  
  This directory contains the testsuite for the "refdes_renum" script.
  No modifications to refdes_renum are allowed without adding tests here.
  If a bug report is filed, a test must be added to show the bug before
  it is allowed to be fixed.
  
  If you require additional input files, add them in the inputs/ directory.
  Reference output files go in outputs/.  Add the test description to
  tests.list.
  
  
  
  
  1.1                  eda/geda/gaf/utils/tests/refdes_renum/run_tests.sh
  
  Index: run_tests.sh
  ===================================================================
  #!/bin/sh
  #
  # $Id: run_tests.sh,v 1.1 2007/04/14 03:18:20 danmc Exp $
  #
  
  regen=no
  
  usage() {
  cat << EOF
  
  $0 -- Testsuite program for refdes_renum
  
  Usage
  
    $0 [-h | --help]
    $0 [-r | --regen] [test1 [test2 [....]]]
  
  Options
  
    -h | --help     Prints this help message and exits.
  
    -r | --regen    Regenerates the reference files.  If you use
                    this option, YOU MUST HAND VERIFY THE RESULTS
                    BEFORE COMMITTING to the repository.
  
  Description
  
  $0 reads a file, tests.list,  describing tests to run on refdes_renum.
  If no specific test is specified on the $0 command line, then all 
  tests are run.
  
  Examples
  
  $0
  $0 basic_renum
  $0 --regen new_test 
  
  EOF
  }
  while test -n "$1"
  do
      case "$1"
      in
  
      -h|--help)
  	usage
  	exit 0
  	;;
  
      -r|--regen)
  	# regenerate the 'golden' output files.  Use this with caution.
  	# In particular, all differences should be noted and understood.
  	regen=yes
  	shift
  	;;
  
      -*)
  	echo "unknown option: $1"
  	usage
  	exit 1
  	;;
  
      *)
  	break
  	;;
  
      esac
  done
  
  
  # make sure we have the right paths when running this from inside the
  # source tree and also from outside the source tree.
  here=`pwd`
  srcdir=${srcdir:-$here}
  srcdir=`cd $srcdir && pwd`
  
  top_srcdir=${top_srcdir:-$here/../..}
  top_srcdir=`cd $top_srcdir && pwd`
  
  # the perl program
  PERL=${PERL:-perl}
  
  rundir=${here}/run
  
  GOLDEN_DIR=${srcdir}/outputs
  INPUT_DIR=${srcdir}/inputs
  
  
  TESTLIST=${srcdir}/tests.list
  
  if test ! -f $TESTLIST ; then
      echo "ERROR: ($0)  Test list $TESTLIST does not exist"
      exit 1
  fi
  
  # fail/pass/total counts
  fail=0
  pass=0
  skip=0
  tot=0
  
  if test -z "$1" ; then
      all_tests=`awk 'BEGIN{FS="|"} /^#/{next} /^[ \t]*$/{next} {print $1}' $TESTLIST | sed 's; ;;g'`
  else
      all_tests=$*
  fi
  
  cat << EOF
  
  Starting tests in $here
  srcdir:     $srcdir
  top_srcdir: $top_srcdir
  INPUT_DIR:  ${INPUT_DIR}
  GOLDEN_DIR: ${GOLDEN_DIR}
  all_tests:
  
  ${all_tests}
  
  EOF
  
  for t in $all_tests ; do
  
      # strip any leading garbage
      t=`echo $t | sed 's;^\*;;g'`
  
      # figure out what files we need to copy for this test and what
      # arguments to feed refdes_renum
      files=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $2}'`
      args=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $3}'`
      code=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $4}'`
      if test "X$code" = "X" ; then
  	code=0
      fi
  
  
      tot=`expr $tot + 1`
  
      # create temporary run directory
      if test ! -d $rundir ; then
  	mkdir -p $rundir
      fi
  
      # Create the files needed
      if test ! -z "$files" ; then
  	for f in $files ; do
  	    cp ${INPUT_DIR}/${f} ${rundir}
  	done
      fi
      
      # run refdes_renum
      #
      
      echo "${PERL} -w ${top_srcdir}/scripts/refdes_renum $args $files"
      cd ${rundir} && ${PERL} -w ${top_srcdir}/scripts/refdes_renum $args $files 
      rc=$?
      if test $rc -ne $code ; then
  	echo "FAILED:  refdes_renum returned $rc which did not match the expected $code"
  	fail=`expr $fail + 1`
  	continue
      fi
  
      good=1
      bad=0
      soso=0
      for f in ${files} ; do
  	ref=${GOLDEN_DIR}/${t}:${f}
  	out=${rundir}/${f}
  
  	if test "X$regen" = "Xyes" ; then
  	    cp ${out} ${ref}
  	    echo "Regenerated ${ref}"
  	elif test -f ${ref} ; then
  	    if diff -w ${ref} ${out} >/dev/null ; then
  		echo "PASS"
  	    else
  		echo "FAILED:  See diff -w ${ref} ${out}"
  		fail=`expr $fail + 1`
  		bad=1
  		good=0
  	    fi
  	else
  	    echo "No reference file.  Skipping"
  	    skip=`expr $skip + 1`
  	    soso=1
  	fi
      done
      if test $soso -ne 0 ; then
  	good=0
  	bad=0
      fi
      pass=`expr $pass + $good`
      fail=`expr $fail + $bad`
      skip=`expr $skip + $soso`
  
      cd $here
      
      # clean up the rundirectory
      rm -fr ${rundir}
  
  done
  
  echo "Passed $pass, failed $fail, skipped $skip out of $tot tests."
  
  rc=0
  if test $pass -ne $tot ; then
      rc=`expr $tot - $pass`
  
  fi
  
  exit $rc
  
  
  
  1.1                  eda/geda/gaf/utils/tests/refdes_renum/tests.list
  
  Index: tests.list
  ===================================================================
  # $Id: tests.list,v 1.1 2007/04/14 03:18:21 danmc Exp $
  #
  #
  # Format:
  #
  # test_name | input files | extra flags to pass to refdes_renum | return code if non-zero expected
  #
  
  
  # -----------------------------------------
  # Single schematic page
  # -----------------------------------------
  
  
  single_renum | file1.sch |
  single_clear | file1.sch | --clear
  single_pgskip1 | file1.sch | --pgskip
  single_pgskip2 | file1.sch | --pgskip 10
  
  # check to see what happens if we have more elements of a given
  # prefix than the value we used for pgskip
  single_pgskip3 | more_than_10.sch | --pgskip 10 | 1
  
  multi_renum | file1.sch file2.sch file3.sch |
  multi_clear | file1.sch file2.sch file3.sch | --clear
  multi_pgskip1 | file1.sch file2.sch file3.sch | --pgskip
  multi_pgskip2 | file1.sch file2.sch file3.sch | --pgskip 10
  
  
  
  


_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs