tst-setcontext3.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. # Bug 18125: Test the exit functionality of setcontext().
  3. # Copyright (C) 2015-2019 Free Software Foundation, Inc.
  4. # This file is part of the GNU C Library.
  5. # The GNU C Library is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 2.1 of the License, or (at your option) any later version.
  9. # The GNU C Library 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 GNU
  12. # Lesser General Public License for more details.
  13. # You should have received a copy of the GNU Lesser General Public
  14. # License along with the GNU C Library; if not, see
  15. # <http://www.gnu.org/licenses/>.
  16. set -e
  17. common_objpfx=$1
  18. test_program_prefix_before_env=$2
  19. run_program_env=$3
  20. test_program_prefix_after_env=$4
  21. objpfx=$5
  22. test_pre="${test_program_prefix_before_env} ${run_program_env}"
  23. test="${test_program_prefix_after_env} ${objpfx}tst-setcontext3"
  24. out=${objpfx}tst-setcontext3.out
  25. cleanup() {
  26. rm -f $tempfile
  27. }
  28. trap cleanup 0
  29. tempfile=$(mktemp "${objpfx}tst-setcontext3.XXXXXXXXXX")
  30. # We want to run the test program and see if secontext called
  31. # exit() and wrote out the test file we specified. If the
  32. # test exits with a non-zero status this will fail because we
  33. # are using `set -e`.
  34. $test_pre $test "$tempfile"
  35. # Look for resulting file.
  36. if [ -e "$tempfile" ]; then
  37. echo "PASS: tst-setcontext3 an exit() and created $tempfile"
  38. exit 0
  39. else
  40. echo "FAIL: tst-setcontext3 did not create $tempfile"
  41. exit 1
  42. fi