view tests/test-c-stack2.sh @ 10275:4c08c1b6678e

c-stack: Expose false positives when not using libsigsegv. * modules/c-stack-tests (Files): Expand test. * tests/test-c-stack.c (main): Add means to conditionally trigger non-overflow SIGSEGV. * tests/test-c-stack2.sh: New file. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Wed, 16 Jul 2008 16:28:13 -0600
parents
children adfc5a204195
line wrap: on
line source

#!/bin/sh

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

tmpfiles="t-c-stack2.tmp"

# Sanitize exit status within a subshell, since some shells fail to
# redirect stderr on their message about death due to signal.
(./test-c-stack${EXEEXT} 1; exit $?) 2> t-c-stack2.tmp

case $? in
  77) if grep 'stack overflow' t-c-stack2.tmp >/dev/null ; then
	echo 'cannot distinguish stack overflow from crash' >&2
      else
       cat t-c-stack2.tmp >&2
      fi
      (exit 77); exit 77 ;;
  0) (exit 1); exit 1 ;;
esac
if grep 'program error' t-c-stack2.tmp >/dev/null ; then
  :
else
  (exit 1); exit 1
fi

rm -fr $tmpfiles

exit 0