tests: Zero the rlimit in standalone tests which are expected to abort

This should hopefully stop the kernel spending a lot of memory and disk
bandwidth creating coredumps for them unnecessarily, which slows down
the rest of the tests and generally wastes resources.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2939
This commit is contained in:
Philip Withnall 2023-05-02 11:06:18 +01:00
parent e8c1bdbf4f
commit 85af9b73c9
2 changed files with 18 additions and 0 deletions

View File

@ -18,12 +18,21 @@
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#include <glib.h>
int
main (int argc,
char **argv)
{
#ifdef HAVE_SYS_RESOURCE_H
/* We expect this test to abort, so try to avoid that creating a coredump */
struct rlimit limit = { 0, 0 };
(void) setrlimit (RLIMIT_CORE, &limit);
#endif
g_assert (42 < 0);
return 0;

View File

@ -23,6 +23,9 @@
#include "config.h"
#include <dlfcn.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#include <glib.h>
static gboolean malloc_eom = FALSE;
@ -56,6 +59,12 @@ int
main (int argc,
char *argv[])
{
#ifdef HAVE_SYS_RESOURCE_H
/* We expect this test to abort, so try to avoid that creating a coredump */
struct rlimit limit = { 0, 0 };
(void) setrlimit (RLIMIT_CORE, &limit);
#endif
g_setenv ("LC_ALL", "C", TRUE);
#ifndef ENOMEM