gdb/contrib/expect-read1.sh - gdb

  1. #! /bin/sh
  2. # runtest wrapper to reliably reproduce racy incomplete reads in the testsuite.

  3. # Copyright (C) 2013-2015 Free Software Foundation, Inc.
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program.  If not, see <http://www.gnu.org/licenses/>.

  16. # This tool excercise any incomplete reads handling in the testsuite by
  17. # simulating read always returns just 1 character.
  18. # Testsuite incompatibilities are tracked as GDB PR testsuite/12649.

  19. # Example usage:
  20. #
  21. # bash$ cd $objdir/gdb/testsuite
  22. # bash$ EXPECT=$srcdir/gdb/contrib/expect-read1.sh runtest
  23. # or
  24. # bash$ EXPECT=../contrib/expect-read1.sh runtest

  25. C=`echo $0|sed 's/\.sh$/.c/'`
  26. if ! test -e $C; then
  27.   echo >&2 "$0: Cannot find 'srcdir/gdb/contrib/expect-read1.c' at '$C'."
  28.   exit 2
  29. fi
  30. SO=/tmp/expect-read1.$$.so
  31. rm -f $SO
  32. CMD="${CC_FOR_TARGET:-gcc} -o $SO -Wall -fPIC -shared $C"
  33. if ! $CMD; then
  34.   echo >&2 "$0: Failed: $CMD"
  35.   exit 2
  36. fi
  37. trap "rm -f $SO" EXIT
  38. LD_PRELOAD=$SO expect "$@"