From e59e81fde566b114e48910e63a9d43501c00cee2 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Mon, 25 May 2015 19:40:42 -0400 Subject: gl-framework: always destroy gl context on exit Currently a piglit_report_result in init (or earlier) would cause the framework to not get torn down. This ensures that the teardown happens on exit, which also enables usage of valgrind to detect memory leaks. This is a refinment of commit 121fb6b7d84 for winsys and commit 50402d6c7 which introduced the fbo framework. Signed-off-by: Ilia Mirkin Reviewed-by: Emil Velikov --- tests/util/piglit-framework-gl.c | 8 ++++++++ tests/util/piglit-framework-gl/piglit_fbo_framework.c | 1 - tests/util/piglit-framework-gl/piglit_winsys_framework.c | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c index 3539a5b73..1973dbcef 100644 --- a/tests/util/piglit-framework-gl.c +++ b/tests/util/piglit-framework-gl.c @@ -174,6 +174,13 @@ piglit_gl_process_args(int *argc, char *argv[], } +static void +destroy(void) +{ + if (gl_fw->destroy) + gl_fw->destroy(gl_fw); +} + void piglit_gl_test_run(int argc, char *argv[], const struct piglit_gl_test_config *config) @@ -188,6 +195,7 @@ piglit_gl_test_run(int argc, char *argv[], piglit_report_result(PIGLIT_FAIL); } + atexit(destroy); gl_fw->run_test(gl_fw, argc, argv); assert(false); } diff --git a/tests/util/piglit-framework-gl/piglit_fbo_framework.c b/tests/util/piglit-framework-gl/piglit_fbo_framework.c index 8f4a19df2..456cf7eb1 100644 --- a/tests/util/piglit-framework-gl/piglit_fbo_framework.c +++ b/tests/util/piglit-framework-gl/piglit_fbo_framework.c @@ -50,7 +50,6 @@ run_test(struct piglit_gl_framework *gl_fw, gl_fw->test_config->init(argc, argv); if (gl_fw->test_config->display) result = gl_fw->test_config->display(); - gl_fw->destroy(gl_fw); piglit_report_result(result); } diff --git a/tests/util/piglit-framework-gl/piglit_winsys_framework.c b/tests/util/piglit-framework-gl/piglit_winsys_framework.c index d9a40eba6..c80e97287 100644 --- a/tests/util/piglit-framework-gl/piglit_winsys_framework.c +++ b/tests/util/piglit-framework-gl/piglit_winsys_framework.c @@ -78,7 +78,6 @@ run_test(struct piglit_gl_framework *gl_fw, if (gl_fw->test_config->display) result = gl_fw->test_config->display(); - gl_fw->destroy(gl_fw); piglit_report_result(result); } -- cgit v1.2.3