Init-test.inc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright (C) 2014, 2015 Free Software Foundation, Inc.
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3, or (at your option)
  6. # any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. # Set up standalone info test environment
  16. # This file is to be sourced, not to be run directly
  17. # write each expanded command to the *.log file for the test.
  18. set -x
  19. # Allow running with "make check" and individual tests at the command-line
  20. srcdir=${srcdir:-.}
  21. # Use the second line to run the program under valgrind.
  22. GINFO="./ginfo --init-file $srcdir/t/Infokey-config"
  23. #GINFO="valgrind --log-file=$0.val.log --leak-check=full ./ginfo --init-file $srcdir/t/Infokey-config"
  24. # Set this to the name of the process
  25. GINFO_NAME=ginfo
  26. #GINFO_NAME=memcheck-x86-li
  27. # Only look for Info files in our test directory
  28. infodir=$srcdir/t/infodir; export infodir
  29. INFOPATH=$infodir; export INFOPATH
  30. t=$srcdir/t; export t
  31. GINFO_OUTPUT=t/`basename $0.out`
  32. # These are only used for interactive tests
  33. PIPEIN=t/`basename $0.pipein`
  34. PTY_TYPE=t/`basename $0.pipeout`
  35. # Remove left over file from previous tests
  36. rm -f $GINFO_OUTPUT
  37. # File to dump nodes to with M-x print-node
  38. INFO_PRINT_COMMAND=">$GINFO_OUTPUT"; export INFO_PRINT_COMMAND
  39. # Not an interactive test
  40. PTY_PID=0
  41. SUBSHELL=0
  42. # Get error messages in English
  43. LC_ALL=C; export LC_ALL
  44. # Make sure that non-interactive operation works even if terminal is dumb
  45. TERM=dumb; export TERM
  46. # For interactive tests, we try to set this in Init-inter.inc
  47. STTY=true
  48. reset_required=no
  49. # Clean up if the test is interrupted, for example if the user types
  50. # C-c, to avoid lingering child processes. Signal 2 is SIGINT.
  51. trap cleanup 2
  52. # Cleanup and exit
  53. cleanup ()
  54. {
  55. # Delete created files and kill spawned processes if any.
  56. test $PTY_PID -ne 0 && kill $PTY_PID
  57. test $SUBSHELL -ne 0 && kill $SUBSHELL
  58. rm -f $GINFO_OUTPUT
  59. rm -f $PIPEIN $PTY_TYPE
  60. rm -f $FINISHEDFIFO
  61. # We do this because some versions of ksh93 (including that in
  62. # Solaris 11) have a bug where a timed-out "read -t" can mess up
  63. # the terminal settings, leading to characters not being echoed.
  64. # This is only done if we don't start with "-echo" at the beginning.
  65. test $reset_required = yes && { $STTY | grep '[-]echo' ; } && $STTY sane
  66. if test -n "$TIMED_OUT"; then
  67. exit 1
  68. fi
  69. #killall `basename $0` # see below
  70. exit $RETVAL
  71. }
  72. # Uncomment this line and "killall" above if previous test runs were not
  73. # cleaned up properly, and rerun "make check".
  74. #cleanup