/bin/ed/test/ckscripts.sh

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 37 lines · 22 code · 4 blank · 11 comment · 6 complexity · 58a11a5e25600ea6df62784f74920d4c MD5 · raw file

  1. #!/bin/sh -
  2. # This script runs the .ed scripts generated by mkscripts.sh
  3. # and compares their output against the .r files, which contain
  4. # the correct output
  5. #
  6. # $FreeBSD$
  7. PATH="/bin:/usr/bin:/usr/local/bin/:."
  8. ED=$1
  9. [ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
  10. # Run the *.red scripts first, since these don't generate output;
  11. # they exit with non-zero status
  12. for i in *.red; do
  13. echo $i
  14. if $i; then
  15. echo "*** The script $i exited abnormally ***"
  16. fi
  17. done >errs.o 2>&1
  18. # Run the remainding scripts; they exit with zero status
  19. for i in *.ed; do
  20. # base=`expr $i : '\([^.]*\)'`
  21. # base=`echo $i | sed 's/\..*//'`
  22. base=`$ED - \!"echo $i" <<-EOF
  23. s/\..*
  24. EOF`
  25. if $base.ed; then
  26. if cmp -s $base.o $base.r; then :; else
  27. echo "*** Output $base.o of script $i is incorrect ***"
  28. fi
  29. else
  30. echo "*** The script $i exited abnormally ***"
  31. fi
  32. done >scripts.o 2>&1
  33. grep -h '\*\*\*' errs.o scripts.o