mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-13 05:34:21 -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
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue