summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-01-19 22:15:13 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-01-19 22:24:23 +0100
commit5b9147513029ca1e1eaf2c028e6f868adc3359f6 (patch)
treeded4e90dd91c0876dcc1e345055ba699599e2aec
parent7d2ba073adef9c4c6f7a679befa2a5d19cbf4735 (diff)
tests/gem_fd_exhaustion: Make it work
- We need to drop root to actually hit the limits. This requires us to fork the actual test since otherwise the exit handlers (which require root) fail the entire test. - Don't assert that the gem create ioctl succeeds, it won't on the final run of the loop. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--tests/gem_fd_exhaustion.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/tests/gem_fd_exhaustion.c b/tests/gem_fd_exhaustion.c
index 77faff2e..afaa1007 100644
--- a/tests/gem_fd_exhaustion.c
+++ b/tests/gem_fd_exhaustion.c
@@ -57,27 +57,35 @@ igt_simple_main
igt_assert(open("/dev/null", O_RDONLY) >= 0);
- for (i = 0; ; i++) {
- int tmp_fd = open("/dev/null", O_RDONLY);
- uint32_t handle;
+ igt_fork(n, 1) {
+ igt_drop_root();
- if (tmp_fd >= 0 && i < FD_ARR_SZ)
- fd_arr[i] = tmp_fd;
+ for (i = 0; ; i++) {
+ int tmp_fd = open("/dev/null", O_RDONLY);
+ uint32_t handle;
- handle = gem_create(fd, 4096);
- if (handle)
- gem_close(fd, handle);
+ if (tmp_fd >= 0 && i < FD_ARR_SZ)
+ fd_arr[i] = tmp_fd;
+ handle = __gem_create(fd, 4096);
+ if (handle)
+ gem_close(fd, handle);
- if (!handle || tmp_fd < 0) {
- printf("fd exhaustion after %i rounds.\n", i);
- break;
+
+ if (tmp_fd < 0) {
+ /* Ensure we actually hit the failure path ... */
+ igt_assert(handle == 0);
+ printf("fd exhaustion after %i rounds.\n", i);
+ break;
+ }
}
+
+ /* The child will free all the fds when exiting, so no need to
+ * clean up to mess to ensure that the parent can at least run
+ * the exit handlers. */
}
- /* free a few fd so that the exit handlers can at least run. */
- for (i = 0; i < FD_ARR_SZ; i++)
- close(fd_arr[i]);
+ igt_waitchildren();
close(fd);
}