mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 23:30:28 +01:00
libnm-util/test: fix tests not to write a core file
test_libnm_linking() executes ./test-libnm-linking which
is supposed to crash. When the user set `ulimit -c unlimited`
before, this will leave a left-over core file.
In case of `make distcheck`, this is quite bad because it lets
the make target fail:
ERROR: files left in build directory after distclean:
./libnm-util/tests/core.31481
Fix this by setting the (soft) rlimit for writing core files
to 0 before executing the test binary.
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
5c31ed880d
commit
242d350fcf
1 changed files with 23 additions and 1 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include <netinet/ether.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <nm-utils.h>
|
||||
|
||||
|
|
@ -2446,6 +2447,26 @@ test_connection_normalize_virtual_iface_name (void)
|
|||
g_object_unref (con);
|
||||
}
|
||||
|
||||
static void
|
||||
_test_libnm_linking_setup_child_process (gpointer user_data)
|
||||
{
|
||||
int val;
|
||||
struct rlimit limit;
|
||||
|
||||
/* the child process is supposed to crash. We don't want it
|
||||
* to write a core dump. */
|
||||
|
||||
val = getrlimit (RLIMIT_CORE, &limit);
|
||||
if (val == 0) {
|
||||
limit.rlim_cur = 0;
|
||||
val = setrlimit (RLIMIT_CORE, &limit);
|
||||
if (val == 0)
|
||||
return;
|
||||
}
|
||||
/* on error, do not crash or fail assertion. Instead just exit */
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static void
|
||||
test_libnm_linking (void)
|
||||
{
|
||||
|
|
@ -2454,7 +2475,8 @@ test_libnm_linking (void)
|
|||
int status;
|
||||
GError *error = NULL;
|
||||
|
||||
g_spawn_sync (BUILD_DIR, argv, NULL, 0 /*G_SPAWN_DEFAULT*/, NULL, NULL,
|
||||
g_spawn_sync (BUILD_DIR, argv, NULL, 0 /*G_SPAWN_DEFAULT*/,
|
||||
_test_libnm_linking_setup_child_process, NULL,
|
||||
&out, &err, &status, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue