mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
tests: Avoid generating cores in softsig-helper
Our opr/softsig-t tests run softsig-helper to generate SIGSEGV and SIGBUS signals (among other things), which may generate core files (if 'ulimit -c' is nonzero). The core files are useless, since we expect those signals to be generated. Usually the core files are generated in the build tree (where we run the tests from), which is a minor annoyance. But some systems may be configured to store core files in a central location (e.g. /var/lib/systemd/coredump), which starts to build up over time after many builds. To avoid this, prevent core files from being generated in softsig-helper for the SIGSEGV and SIGBUS cases by calling setrlimit(). Change-Id: Ice71e79009cf2b44d4cbe32233d3a7ee12e08d2d Reviewed-on: https://gerrit.openafs.org/15795 Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Tested-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
parent
c78e2b4c64
commit
1acc612687
@ -32,6 +32,9 @@
|
||||
#include <roken.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/mman.h>
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#include <afs/opr.h>
|
||||
#include <opr/softsig.h>
|
||||
@ -79,8 +82,27 @@ mythread(void *arg) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
disable_core(void)
|
||||
{
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
struct rlimit rlp;
|
||||
|
||||
memset(&rlp, 0, sizeof(rlp));
|
||||
|
||||
/*
|
||||
* Set our core limit to 0 for SIGSEGV/SIGBUS, so we don't litter core
|
||||
* files around when running the test.
|
||||
*/
|
||||
if (setrlimit(RLIMIT_CORE, &rlp) < 0) {
|
||||
perror("setrlimit(RLIMIT_CORE)");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void *
|
||||
crashingThread(void *arg) {
|
||||
disable_core();
|
||||
*(char *)1 = 'a'; /* raises SIGSEGV */
|
||||
return NULL; /* Ha! */
|
||||
}
|
||||
@ -90,6 +112,7 @@ thrownUnderTheBusThread(void *arg) {
|
||||
char *path = arg;
|
||||
int fd = open(path, O_CREAT | O_APPEND, 0660);
|
||||
char *m = mmap(NULL, 10, PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
disable_core();
|
||||
*(m + 11) = 'a'; /* raises SIGBUS */
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user