Common 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. #
  3. # Common - Elements shared by all regression tests for fped
  4. #
  5. # Written 2010, 2011 by Werner Almesberger
  6. # Copyright 2010, 2011 Werner Almesberger
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. fped()
  14. {
  15. echo -n "$1: " 1>&2
  16. shift
  17. cat >_in
  18. $VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 || {
  19. echo FAILED "($SCRIPT)" 1>&2
  20. cat _out
  21. rm -f _in _out
  22. exit 1
  23. }
  24. rm -f _in
  25. }
  26. fped_dump()
  27. {
  28. fped "$@" -T -T
  29. }
  30. fped_fail()
  31. {
  32. echo -n "$1: " 1>&2
  33. shift
  34. cat >_in
  35. $VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 && {
  36. echo FAILED "($SCRIPT)" 1>&2
  37. cat _out
  38. rm -f _in _out
  39. exit 1
  40. }
  41. rm -f _in
  42. }
  43. expect()
  44. {
  45. diff -u - "$@" _out >_diff || {
  46. echo FAILED "($SCRIPT)" 1>&2
  47. cat _diff 1>&2
  48. rm -f _out _diff
  49. exit 1
  50. }
  51. echo PASSED 1>&2
  52. rm -f _out _diff
  53. passed=`expr ${passed:-0} + 1`
  54. }
  55. expect_grep()
  56. {
  57. grep "$1" <_out >_tmp || exit 1
  58. mv _tmp _out
  59. shift
  60. expect "$@"
  61. }
  62. expect_sed()
  63. {
  64. sed "$1" <_out >_tmp || exit 1
  65. mv _tmp _out
  66. shift
  67. expect "$@"
  68. }
  69. if [ ! -z "$CWD_PREFIX" -a ! -z "$FPED" -a "$FPED" = "${FPED#/}" ]; then
  70. FPED="$CWD_PREFIX/$FPED"
  71. fi