mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-31 07:11:27 -04:00
tests: support testing fd inheritance over exec
Add facility for testing how (many) file descriptors survive an exec. This allows implementing O_CLOEXEC tests. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
parent
7c0aa1a4a3
commit
da6b1a8e47
5 changed files with 124 additions and 4 deletions
|
|
@ -23,6 +23,8 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test-runner.h"
|
||||
|
||||
|
|
@ -50,3 +52,13 @@ count_open_fds(void)
|
|||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
exec_fd_leak_check(int nr_expected_fds)
|
||||
{
|
||||
const char *exe = "./exec-fd-leak-checker";
|
||||
char number[16] = { 0 };
|
||||
|
||||
snprintf(number, sizeof number - 1, "%d", nr_expected_fds);
|
||||
execl(exe, exe, number, (char *)NULL);
|
||||
assert(0 && "execing fd leak checker failed");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue