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
|
|
@ -53,11 +53,13 @@ FAIL_TEST(exit_failure)
|
|||
|
||||
FAIL_TEST(fail_abort)
|
||||
{
|
||||
test_disable_coredumps();
|
||||
abort();
|
||||
}
|
||||
|
||||
FAIL_TEST(fail_wl_abort)
|
||||
{
|
||||
test_disable_coredumps();
|
||||
wl_abort("Abort the program\n");
|
||||
}
|
||||
|
||||
|
|
@ -68,11 +70,13 @@ FAIL_TEST(fail_kill)
|
|||
|
||||
FAIL_TEST(fail_segv)
|
||||
{
|
||||
test_disable_coredumps();
|
||||
* (char **) 0 = "Goodbye, world";
|
||||
}
|
||||
|
||||
FAIL_TEST(sanity_assert)
|
||||
{
|
||||
test_disable_coredumps();
|
||||
/* must fail */
|
||||
assert(0);
|
||||
}
|
||||
|
|
@ -87,6 +91,7 @@ FAIL_TEST(sanity_malloc_direct)
|
|||
assert(p); /* assert that we got memory, also prevents
|
||||
* the malloc from getting optimized away. */
|
||||
free(NULL); /* NULL must not be counted */
|
||||
test_disable_coredumps();
|
||||
}
|
||||
|
||||
TEST(disable_leak_checks)
|
||||
|
|
@ -114,6 +119,8 @@ FAIL_TEST(sanity_malloc_indirect)
|
|||
wl_array_add(&array, 14);
|
||||
|
||||
/* not freeing array, must leak */
|
||||
|
||||
test_disable_coredumps();
|
||||
}
|
||||
|
||||
FAIL_TEST(tc_client_memory_leaks)
|
||||
|
|
@ -121,6 +128,7 @@ FAIL_TEST(tc_client_memory_leaks)
|
|||
struct display *d = display_create();
|
||||
client_create_noarg(d, sanity_malloc_direct);
|
||||
display_run(d);
|
||||
test_disable_coredumps();
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
|
|
@ -129,6 +137,7 @@ FAIL_TEST(tc_client_memory_leaks2)
|
|||
struct display *d = display_create();
|
||||
client_create_noarg(d, sanity_malloc_indirect);
|
||||
display_run(d);
|
||||
test_disable_coredumps();
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
|
|
@ -141,6 +150,8 @@ FAIL_TEST(sanity_fd_leak)
|
|||
/* leak 2 file descriptors */
|
||||
if (pipe(fd) < 0)
|
||||
exit(EXIT_SUCCESS); /* failed to fail */
|
||||
|
||||
test_disable_coredumps();
|
||||
}
|
||||
|
||||
FAIL_TEST(sanity_fd_leak_exec)
|
||||
|
|
@ -152,6 +163,7 @@ FAIL_TEST(sanity_fd_leak_exec)
|
|||
if (pipe(fd) < 0)
|
||||
exit(EXIT_SUCCESS); /* failed to fail */
|
||||
|
||||
test_disable_coredumps();
|
||||
exec_fd_leak_check(nr_fds);
|
||||
}
|
||||
|
||||
|
|
@ -212,6 +224,7 @@ FAIL_TEST(tc_client_fd_leaks)
|
|||
client_create_noarg(d, sanity_fd_leak);
|
||||
display_run(d);
|
||||
|
||||
test_disable_coredumps();
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
|
|
@ -222,12 +235,14 @@ FAIL_TEST(tc_client_fd_leaks_exec)
|
|||
client_create_noarg(d, sanity_fd_leak);
|
||||
display_run(d);
|
||||
|
||||
test_disable_coredumps();
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
FAIL_TEST(timeout_tst)
|
||||
{
|
||||
test_set_timeout(1);
|
||||
test_disable_coredumps();
|
||||
/* test should reach timeout */
|
||||
test_sleep(2);
|
||||
}
|
||||
|
|
@ -247,6 +262,7 @@ FAIL_TEST(timeout_reset_tst)
|
|||
test_set_timeout(10);
|
||||
test_set_timeout(1);
|
||||
|
||||
test_disable_coredumps();
|
||||
/* test should fail on timeout */
|
||||
test_sleep(2);
|
||||
}
|
||||
|
|
@ -265,6 +281,7 @@ FAIL_TEST(tc_timeout_tst)
|
|||
struct display *d = display_create();
|
||||
client_create_noarg(d, timeout_tst);
|
||||
display_run(d);
|
||||
test_disable_coredumps();
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
|
|
@ -273,6 +290,7 @@ FAIL_TEST(tc_timeout2_tst)
|
|||
struct display *d = display_create();
|
||||
client_create_noarg(d, timeout_reset_tst);
|
||||
display_run(d);
|
||||
test_disable_coredumps();
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,20 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.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"
|
||||
|
||||
|
|
@ -97,3 +105,25 @@ test_sleep(unsigned int sec)
|
|||
|
||||
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
|
||||
test_sleep(unsigned int);
|
||||
|
||||
void
|
||||
test_disable_coredumps(void);
|
||||
|
||||
#define DISABLE_LEAK_CHECKS \
|
||||
do { \
|
||||
extern int leak_check_enabled; \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue