summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-29 10:06:51 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-29 18:18:33 +0200
commitcd1f220847c34610ab9e07c3cf1c5a7e77284eb8 (patch)
tree8c3f54af9c7b7303d03157f26c4c51413224394c /tests
parent90a25055e3ec7d9779663bec9cbae93187671bfd (diff)
lib/drmtest: extract igt_fork from gem_concurrent_blt
Making sure that we correctly collect the exit codes from all children is a bit a hassle. So add another magic igt codeblock for easy forking and joining. Note that children are (currently at least) not allowed to call igt_skip. Add an assert to enforce this. v2: - Properly propagate the exit code. - Fix the segfault. - Add a child int and num_children paramter to the magic codeblock as suggested by Chris Wilson. - Don't dump noise into stdout when a child thread fails, the parent will do that for us already. v3: Now with some docs. v4: Fixup igt_waitchildren to properly reset state so it can be used again. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests')
-rw-r--r--tests/gem_concurrent_blit.c58
1 files changed, 24 insertions, 34 deletions
diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c
index 69477748..b6d316d1 100644
--- a/tests/gem_concurrent_blit.c
+++ b/tests/gem_concurrent_blit.c
@@ -267,47 +267,37 @@ static void run_forked(struct access_mode *mode,
do_test do_test_func)
{
const int old_num_buffers = num_buffers;
- pid_t children[16];
- num_buffers /= ARRAY_SIZE(children);
+ num_buffers /= 16;
num_buffers += 2;
igt_fork_signal_helper();
- for (int nc = 0; nc < ARRAY_SIZE(children); nc++) {
- switch ((children[nc] = fork())) {
- case -1: igt_assert(0);
- default: break;
- case 0:
- /* recreate process local variables */
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- drm_intel_bufmgr_gem_enable_reuse(bufmgr);
- batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
- for (int i = 0; i < num_buffers; i++) {
- src[i] = mode->create_bo(bufmgr, i, width, height);
- dst[i] = mode->create_bo(bufmgr, ~i, width, height);
- }
- dummy = mode->create_bo(bufmgr, 0, width, height);
- for (int loop = 0; loop < 10; loop++)
- do_test_func(mode, src, dst, dummy);
- /* as we borrow the fd, we need to reap our bo */
- for (int i = 0; i < num_buffers; i++) {
- drm_intel_bo_unreference(src[i]);
- drm_intel_bo_unreference(dst[i]);
- }
- drm_intel_bo_unreference(dummy);
- intel_batchbuffer_free(batch);
- drm_intel_bufmgr_destroy(bufmgr);
- exit(0);
+ igt_fork(child, 16) {
+ igt_fail(6);
+
+ /* recreate process local variables */
+ bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
+ drm_intel_bufmgr_gem_enable_reuse(bufmgr);
+ batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
+ for (int i = 0; i < num_buffers; i++) {
+ src[i] = mode->create_bo(bufmgr, i, width, height);
+ dst[i] = mode->create_bo(bufmgr, ~i, width, height);
}
+ dummy = mode->create_bo(bufmgr, 0, width, height);
+ for (int loop = 0; loop < 10; loop++)
+ do_test_func(mode, src, dst, dummy);
+ /* as we borrow the fd, we need to reap our bo */
+ for (int i = 0; i < num_buffers; i++) {
+ drm_intel_bo_unreference(src[i]);
+ drm_intel_bo_unreference(dst[i]);
+ }
+ drm_intel_bo_unreference(dummy);
+ intel_batchbuffer_free(batch);
+ drm_intel_bufmgr_destroy(bufmgr);
}
- for (int nc = 0; nc < ARRAY_SIZE(children); nc++) {
- int status = -1;
- while (waitpid(children[nc], &status, 0) == -1 &&
- errno == -EINTR)
- ;
- igt_assert(status == 0);
- }
+
+ igt_waitchildren();
igt_stop_signal_helper();