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

gEDA-cvs: CVS update: Makefile.am



  User: sdb     
  Date: 07/04/21 13:13:42

  Added:       .        Makefile.am run_tests.sh tests.list
  Log:
  Created regression test suite for spice-sdb
  
  
  
  
  Revision  Changes    Path
  1.1                  eda/geda/gaf/gnetlist/tests/spice-sdb/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  ## $Id: Makefile.am,v 1.1 2007/04/21 17:13:42 sdb 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
  
  
  
  
  1.1                  eda/geda/gaf/gnetlist/tests/spice-sdb/run_tests.sh
  
  Index: run_tests.sh
  ===================================================================
  #!/bin/sh
  #
  # This script runs the tests called out for in test.list
  #
  
  regen=no
  
  usage() {
  cat << EOF
  
  $0 -- Testsuite program for spice-sdb
  
  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 spice-sdb.
  If no specific test is specified on the $0 command line, then all 
  tests are run.
  
  Examples
  
  $0
  $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
  
  # here's where we look at the test.list file and extract the names of all
  # the tests we want to run.
  if test -z "$1" ; then
      all_tests=`awk 'BEGIN{FS="|"} /^#/{next} /^[ \t]*$/{next} {print $1}' $TESTLIST | sed 's; ;;g'`
  else
      all_tests=$*
  fi
  echo All tests = $all_tests
  
  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
  
  # Now run through all tests in test.list, prepare the $rundir,
  # then run the tests. 
  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 gnetlist 
      schematics=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $2}'`
      auxfiles=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $3}'`
      args=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $4}'`
      code=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $5}'`
      echo Schematics to copy = $schematics
      echo Args to copy = $args
      echo Return codes to copy = $code
      if test "X$code" = "X" ; then
  	code=0
      fi
  
  
      tot=`expr $tot + 1`
  
      # create temporary run directory and required subdirs
      if test ! -d $rundir ; then
  	mkdir -p $rundir
  	mkdir -p $rundir/sym
  	mkdir -p $rundir/models
      fi
  
      # Create the files needed
      # Note that we need to include not only the .sch files,
      # but also the contents of the sym and model directories.
      if test ! -z "$schematics" ; then
  	echo "Copying over schematics to run dir"
  	for f in $schematics ; do
  	    echo cp ${INPUT_DIR}/${f} ${rundir}/${f}
  	    cp ${INPUT_DIR}/${f} ${rundir}/${f}
  	done
      fi
      if test ! -z "$auxfiles" ; then
  	echo "Copying over aux files to run dir"
  	for f in $auxfiles ; do
  	    echo cp ${INPUT_DIR}/${f} ${rundir}/${f}
  	    cp ${INPUT_DIR}/${f} ${rundir}/${f}
  	done
      fi
      
      # run gnetlist -g spice-sdb
      echo "${top_srcdir}/src/gnetlist -g spice-sdb $args $schematics"
      cd ${rundir} && ${top_srcdir}/src/gnetlist -g spice-sdb $args $schematics 
      rc=$?
      if test $rc -ne $code ; then
  	echo "FAILED:  gnetlist -g spice-sdb returned $rc which did not match the expected $code"
  	fail=`expr $fail + 1`
  	continue
      fi
  
      # OK, now check results of run.
      good=1
      bad=0
      soso=0
  
      ref=${GOLDEN_DIR}/${t}-output.net
      out=${rundir}/output.net
      
      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
  
      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
      
      # Delete the run directory in prep for the next test
      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/gnetlist/tests/spice-sdb/tests.list
  
  Index: tests.list
  ===================================================================
  # Format:
  #
  # test_name | input schematics | aux files (gafrc, symbols, etc) | \ 
  # extra flags to pass to gnetlist -g spice-sdb | \
  # return code if non-zero expected
  #
  
  
  # -----------------------------------------
  # Simple netlisting tests
  # -----------------------------------------
  
  # The two stage amp
  TwoStageAmp | TwoStageAmp.sch | Simulation.cmd gafrc models/2N3904.mod sym/transistor.sym | | 
  TwoStageAmp_Include | TwoStageAmp.sch | Simulation.cmd gafrc models/2N3904.mod sym/transistor.sym | -I
  TwoStageAmp_Sort | TwoStageAmp.sch | Simulation.cmd gafrc models/2N3904.mod sym/transistor.sym | -s
  
  # John Doty's test circuit
  JD | LVDfoo.sch | gafrc models/openIP_5.cir sym/LVD.sym | | 
  JD_Include | LVDfoo.sch | gafrc models/openIP_5.cir sym/LVD.sym | -I
  JD_Sort | LVDfoo.sch | gafrc models/openIP_5.cir sym/LVD.sym | -s
  
  
  
  


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