[5/7] egl-context-preemption: Add a subtest to reuse the same display.

Submitted by Rafael Antognolli on Oct. 4, 2018, 3:35 p.m.

Details

Message ID 20181004153535.17863-6-rafael.antognolli@intel.com
State New
Headers show
Series "New preemption test." ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Rafael Antognolli Oct. 4, 2018, 3:35 p.m.
Add a subtest that reuses the same EGLDisplay used in the main thread.
This is just another case we can test and see if there's a difference in
the preemption behavior.
---
 tests/egl/egl-context-preemption.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/egl/egl-context-preemption.c b/tests/egl/egl-context-preemption.c
index 85f5c8fd5..26ead9d58 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -51,6 +51,7 @@  struct test_data {
 	int nruns;
 	EGLDisplay dpy;
 	EGLContext ctx;
+	const struct test_profile *p;
 };
 
 struct test_profile {
@@ -58,6 +59,7 @@  struct test_profile {
 	size_t bufsize;
 	GLenum draw_mode;
 	GLuint (*shader_setup)(void);
+	bool same_display;
 };
 
 static bool small = false;
@@ -307,8 +309,9 @@  setup_thread_context(struct test_data *d)
 	bool ok = false;
 	EGLContext ctx2 = EGL_NO_CONTEXT;
 
-	EGLDisplay dpy;
-	if (init_other_display(&dpy) == PIGLIT_SKIP) {
+	EGLDisplay dpy = d->dpy;
+	if (!d->p->same_display &&
+	    init_other_display(&dpy) == PIGLIT_SKIP) {
 		piglit_loge("failed to get display\n");
 		result = PIGLIT_FAIL;
 		return result;
@@ -358,7 +361,9 @@  setup_thread_context(struct test_data *d)
 cleanup:
 	if (ctx2 != EGL_NO_CONTEXT)
 		eglDestroyContext(dpy, ctx2);
-	eglTerminate(dpy);
+
+	if (!d->p->same_display)
+		eglTerminate(dpy);
 
 	return result;
 }
@@ -445,7 +450,8 @@  thread2_create_high_priority_context(void *data)
 
 	if (d->ctx != EGL_NO_CONTEXT)
 		eglDestroyContext(d->dpy, d->ctx);
-	eglTerminate(d->dpy);
+	if (!d->p->same_display)
+		eglTerminate(d->dpy);
 
 	return result;
 }
@@ -486,6 +492,7 @@  test_preemption(void *data)
 	struct test_data d = {
 		.main_finished = false,
 		.nruns = 0,
+		.p = profile,
 	};
 	d.dpy = eglGetCurrentDisplay();
 
@@ -633,6 +640,14 @@  static struct test_profile trifan = {
 	.shader_setup = setup_shaders,
 };
 
+static struct test_profile triangles_same_display = {
+	.vertices = triangle_vertices,
+	.bufsize = sizeof(triangle_vertices),
+	.draw_mode = GL_TRIANGLES,
+	.shader_setup = setup_shaders,
+	.same_display = true,
+};
+
 static const struct piglit_subtest subtests[] = {
 	{
 		"triangles",
@@ -646,6 +661,12 @@  static const struct piglit_subtest subtests[] = {
 		test_preemption,
 		&trifan,
 	},
+	{
+		"triangles_same_display",
+		"same_display",
+		test_preemption,
+		&triangles_same_display,
+	},
 	{0},
 };