mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
tests: disable coredumps on sanity-test
SEGV and ABRT by default cause a core dump, which may create a file, launch crash handlers, and so on. sanity-test has 21 processes that are expected to crash like this. Disable core dumps on them all. I counted 21 entries in coredumpctl list, while only 16 functions needed patching. After this patch no entries appear in coredumpctl list. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
adda7cbbb8
commit
371c26d52b
4 changed files with 53 additions and 1 deletions
|
|
@ -62,7 +62,8 @@ if test "x$GCC" = "xyes"; then
|
||||||
fi
|
fi
|
||||||
AC_SUBST(GCC_CFLAGS)
|
AC_SUBST(GCC_CFLAGS)
|
||||||
|
|
||||||
AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate])
|
AC_CHECK_HEADERS([sys/prctl.h])
|
||||||
|
AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate prctl])
|
||||||
|
|
||||||
AC_ARG_ENABLE([libraries],
|
AC_ARG_ENABLE([libraries],
|
||||||
[AC_HELP_STRING([--disable-libraries],
|
[AC_HELP_STRING([--disable-libraries],
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,13 @@ FAIL_TEST(exit_failure)
|
||||||
|
|
||||||
FAIL_TEST(fail_abort)
|
FAIL_TEST(fail_abort)
|
||||||
{
|
{
|
||||||
|
test_disable_coredumps();
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
FAIL_TEST(fail_wl_abort)
|
FAIL_TEST(fail_wl_abort)
|
||||||
{
|
{
|
||||||
|
test_disable_coredumps();
|
||||||
wl_abort("Abort the program\n");
|
wl_abort("Abort the program\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,11 +70,13 @@ FAIL_TEST(fail_kill)
|
||||||
|
|
||||||
FAIL_TEST(fail_segv)
|
FAIL_TEST(fail_segv)
|
||||||
{
|
{
|
||||||
|
test_disable_coredumps();
|
||||||
* (char **) 0 = "Goodbye, world";
|
* (char **) 0 = "Goodbye, world";
|
||||||
}
|
}
|
||||||
|
|
||||||
FAIL_TEST(sanity_assert)
|
FAIL_TEST(sanity_assert)
|
||||||
{
|
{
|
||||||
|
test_disable_coredumps();
|
||||||
/* must fail */
|
/* must fail */
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
@ -87,6 +91,7 @@ FAIL_TEST(sanity_malloc_direct)
|
||||||
assert(p); /* assert that we got memory, also prevents
|
assert(p); /* assert that we got memory, also prevents
|
||||||
* the malloc from getting optimized away. */
|
* the malloc from getting optimized away. */
|
||||||
free(NULL); /* NULL must not be counted */
|
free(NULL); /* NULL must not be counted */
|
||||||
|
test_disable_coredumps();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(disable_leak_checks)
|
TEST(disable_leak_checks)
|
||||||
|
|
@ -114,6 +119,8 @@ FAIL_TEST(sanity_malloc_indirect)
|
||||||
wl_array_add(&array, 14);
|
wl_array_add(&array, 14);
|
||||||
|
|
||||||
/* not freeing array, must leak */
|
/* not freeing array, must leak */
|
||||||
|
|
||||||
|
test_disable_coredumps();
|
||||||
}
|
}
|
||||||
|
|
||||||
FAIL_TEST(tc_client_memory_leaks)
|
FAIL_TEST(tc_client_memory_leaks)
|
||||||
|
|
@ -121,6 +128,7 @@ FAIL_TEST(tc_client_memory_leaks)
|
||||||
struct display *d = display_create();
|
struct display *d = display_create();
|
||||||
client_create_noarg(d, sanity_malloc_direct);
|
client_create_noarg(d, sanity_malloc_direct);
|
||||||
display_run(d);
|
display_run(d);
|
||||||
|
test_disable_coredumps();
|
||||||
display_destroy(d);
|
display_destroy(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,6 +137,7 @@ FAIL_TEST(tc_client_memory_leaks2)
|
||||||
struct display *d = display_create();
|
struct display *d = display_create();
|
||||||
client_create_noarg(d, sanity_malloc_indirect);
|
client_create_noarg(d, sanity_malloc_indirect);
|
||||||
display_run(d);
|
display_run(d);
|
||||||
|
test_disable_coredumps();
|
||||||
display_destroy(d);
|
display_destroy(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,6 +150,8 @@ FAIL_TEST(sanity_fd_leak)
|
||||||
/* leak 2 file descriptors */
|
/* leak 2 file descriptors */
|
||||||
if (pipe(fd) < 0)
|
if (pipe(fd) < 0)
|
||||||
exit(EXIT_SUCCESS); /* failed to fail */
|
exit(EXIT_SUCCESS); /* failed to fail */
|
||||||
|
|
||||||
|
test_disable_coredumps();
|
||||||
}
|
}
|
||||||
|
|
||||||
FAIL_TEST(sanity_fd_leak_exec)
|
FAIL_TEST(sanity_fd_leak_exec)
|
||||||
|
|
@ -152,6 +163,7 @@ FAIL_TEST(sanity_fd_leak_exec)
|
||||||
if (pipe(fd) < 0)
|
if (pipe(fd) < 0)
|
||||||
exit(EXIT_SUCCESS); /* failed to fail */
|
exit(EXIT_SUCCESS); /* failed to fail */
|
||||||
|
|
||||||
|
test_disable_coredumps();
|
||||||
exec_fd_leak_check(nr_fds);
|
exec_fd_leak_check(nr_fds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,6 +224,7 @@ FAIL_TEST(tc_client_fd_leaks)
|
||||||
client_create_noarg(d, sanity_fd_leak);
|
client_create_noarg(d, sanity_fd_leak);
|
||||||
display_run(d);
|
display_run(d);
|
||||||
|
|
||||||
|
test_disable_coredumps();
|
||||||
display_destroy(d);
|
display_destroy(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -222,12 +235,14 @@ FAIL_TEST(tc_client_fd_leaks_exec)
|
||||||
client_create_noarg(d, sanity_fd_leak);
|
client_create_noarg(d, sanity_fd_leak);
|
||||||
display_run(d);
|
display_run(d);
|
||||||
|
|
||||||
|
test_disable_coredumps();
|
||||||
display_destroy(d);
|
display_destroy(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
FAIL_TEST(timeout_tst)
|
FAIL_TEST(timeout_tst)
|
||||||
{
|
{
|
||||||
test_set_timeout(1);
|
test_set_timeout(1);
|
||||||
|
test_disable_coredumps();
|
||||||
/* test should reach timeout */
|
/* test should reach timeout */
|
||||||
test_sleep(2);
|
test_sleep(2);
|
||||||
}
|
}
|
||||||
|
|
@ -247,6 +262,7 @@ FAIL_TEST(timeout_reset_tst)
|
||||||
test_set_timeout(10);
|
test_set_timeout(10);
|
||||||
test_set_timeout(1);
|
test_set_timeout(1);
|
||||||
|
|
||||||
|
test_disable_coredumps();
|
||||||
/* test should fail on timeout */
|
/* test should fail on timeout */
|
||||||
test_sleep(2);
|
test_sleep(2);
|
||||||
}
|
}
|
||||||
|
|
@ -265,6 +281,7 @@ FAIL_TEST(tc_timeout_tst)
|
||||||
struct display *d = display_create();
|
struct display *d = display_create();
|
||||||
client_create_noarg(d, timeout_tst);
|
client_create_noarg(d, timeout_tst);
|
||||||
display_run(d);
|
display_run(d);
|
||||||
|
test_disable_coredumps();
|
||||||
display_destroy(d);
|
display_destroy(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -273,6 +290,7 @@ FAIL_TEST(tc_timeout2_tst)
|
||||||
struct display *d = display_create();
|
struct display *d = display_create();
|
||||||
client_create_noarg(d, timeout_reset_tst);
|
client_create_noarg(d, timeout_reset_tst);
|
||||||
display_run(d);
|
display_run(d);
|
||||||
|
test_disable_coredumps();
|
||||||
display_destroy(d);
|
display_destroy(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,20 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_PRCTL_H
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "test-runner.h"
|
#include "test-runner.h"
|
||||||
|
|
||||||
|
|
@ -97,3 +105,25 @@ test_sleep(unsigned int sec)
|
||||||
|
|
||||||
assert(nanosleep(&ts, NULL) == 0);
|
assert(nanosleep(&ts, NULL) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Try to disable coredumps
|
||||||
|
*
|
||||||
|
* Useful for tests that crash on purpose, to avoid creating a core file
|
||||||
|
* or launching an application crash handler service or cluttering coredumpctl.
|
||||||
|
*
|
||||||
|
* NOTE: Calling this may make the process undebuggable.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
test_disable_coredumps(void)
|
||||||
|
{
|
||||||
|
struct rlimit r;
|
||||||
|
|
||||||
|
if (getrlimit(RLIMIT_CORE, &r) == 0) {
|
||||||
|
r.rlim_cur = 0;
|
||||||
|
setrlimit(RLIMIT_CORE, &r);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
|
||||||
|
prctl(PR_SET_DUMPABLE, 0, 0, 0, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,9 @@ test_usleep(useconds_t);
|
||||||
void
|
void
|
||||||
test_sleep(unsigned int);
|
test_sleep(unsigned int);
|
||||||
|
|
||||||
|
void
|
||||||
|
test_disable_coredumps(void);
|
||||||
|
|
||||||
#define DISABLE_LEAK_CHECKS \
|
#define DISABLE_LEAK_CHECKS \
|
||||||
do { \
|
do { \
|
||||||
extern int leak_check_enabled; \
|
extern int leak_check_enabled; \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue