Use setrlimit instead of ulimit -c in backtrace tests

This commit is contained in:
rl1987 2019-02-13 15:50:09 +02:00 committed by David Goulet
parent c320c52e89
commit b7ad8bcaad
3 changed files with 12 additions and 2 deletions

4
changes/bug29061 Normal file
View File

@ -0,0 +1,4 @@
o Minor bugfixes (testing):
- Call setrlimit() to disable core dumps in test_bt_cl.c instead of
using `ulimit -c` in test_bt.sh, which violates POSIX shell
compatibility. Fixes bug 29061; bugfix on 0.3.5.1-alpha.

View File

@ -3,8 +3,6 @@
exitcode=0 exitcode=0
ulimit -c 0
export ASAN_OPTIONS="handle_segv=0:allow_user_segv_handler=1" export ASAN_OPTIONS="handle_segv=0:allow_user_segv_handler=1"
"${builddir:-.}/src/test/test-bt-cl" backtraces || exit $? "${builddir:-.}/src/test/test-bt-cl" backtraces || exit $?
"${builddir:-.}/src/test/test-bt-cl" assert 2>&1 | "${PYTHON:-python}" "${abs_top_srcdir:-.}/src/test/bt_test.py" || exitcode="$?" "${builddir:-.}/src/test/test-bt-cl" assert 2>&1 | "${PYTHON:-python}" "${abs_top_srcdir:-.}/src/test/bt_test.py" || exitcode="$?"

View File

@ -4,6 +4,9 @@
#include "orconfig.h" #include "orconfig.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
/* To prevent 'assert' from going away. */ /* To prevent 'assert' from going away. */
#undef TOR_COVERAGE #undef TOR_COVERAGE
@ -88,6 +91,11 @@ main(int argc, char **argv)
return 1; return 1;
} }
#ifdef HAVE_SYS_RESOURCE_H
struct rlimit rlim = { .rlim_cur = 0, .rlim_max = 0 };
setrlimit(RLIMIT_CORE, &rlim);
#endif
#if !(defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \ #if !(defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \
defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION)) defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION))
puts("Backtrace reporting is not supported on this platform"); puts("Backtrace reporting is not supported on this platform");