From a1bee97d4f093db01dee834bf3292eabd5b13d17 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 2 May 2023 11:03:00 +0100 Subject: tests: Reformat assert-msg-test.c to follow coding style Signed-off-by: Philip Withnall --- glib/tests/assert-msg-test.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/glib/tests/assert-msg-test.c b/glib/tests/assert-msg-test.c index 75591c853..87e75b794 100644 --- a/glib/tests/assert-msg-test.c +++ b/glib/tests/assert-msg-test.c @@ -1,7 +1,10 @@ #include -int main(int argc, char **argv) +int +main (int argc, + char **argv) { - g_assert(42 < 0); - return 0; + + g_assert (42 < 0); + return 0; } -- cgit v1.2.1 From e8c1bdbf4ff85a63a3ca437e34a1e7f89ac10145 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 2 May 2023 11:03:49 +0100 Subject: tests: Add copyright/licensing header to assert-msg-test This is put together through git archaeology: ``` git log -- glib/tests/assert-msg-test.c tests/assert-msg-test.c ``` The following commits were too trivial to have meaningful copyright: - 8e59d8602ca5921d78245f5d2b405b517a5e7cf9 - 44c004c84e9080040ff4e0e90b322dda0561cf85 - 207b8cb8a50d68e207d28b59e588311a5cbd9772 - a1bee97d4f093db01dee834bf3292eabd5b13d17 Signed-off-by: Philip Withnall Helps: #1415 --- glib/tests/assert-msg-test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/glib/tests/assert-msg-test.c b/glib/tests/assert-msg-test.c index 87e75b794..e91b1f4c3 100644 --- a/glib/tests/assert-msg-test.c +++ b/glib/tests/assert-msg-test.c @@ -1,3 +1,23 @@ +/* GLib testing framework examples and tests + * + * Copyright © 2009 Canonical Limited + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + #include int -- cgit v1.2.1 From 85af9b73c9ad0bbeac0f5151f86411dcf89221a6 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 2 May 2023 11:06:18 +0100 Subject: 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 Fixes: #2939 --- glib/tests/assert-msg-test.c | 9 +++++++++ glib/tests/messages-low-memory.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/glib/tests/assert-msg-test.c b/glib/tests/assert-msg-test.c index e91b1f4c3..b46496635 100644 --- a/glib/tests/assert-msg-test.c +++ b/glib/tests/assert-msg-test.c @@ -18,12 +18,21 @@ * Public License along with this library; if not, see . */ +#include "config.h" +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif #include 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; diff --git a/glib/tests/messages-low-memory.c b/glib/tests/messages-low-memory.c index af35c4e26..ecb507024 100644 --- a/glib/tests/messages-low-memory.c +++ b/glib/tests/messages-low-memory.c @@ -23,6 +23,9 @@ #include "config.h" #include +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif #include 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 -- cgit v1.2.1