[Piglit] [PATCH] gl-framework: always destroy gl context on exit
Ilia Mirkin
imirkin at alum.mit.edu
Mon May 25 16:51:38 PDT 2015
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 <imirkin at alum.mit.edu>
---
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 b9ab2f8..0c2595e 100644
--- a/tests/util/piglit-framework-gl.c
+++ b/tests/util/piglit-framework-gl.c
@@ -165,6 +165,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)
@@ -179,6 +186,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 8f4a19d..456cf7e 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 d9a40eb..c80e972 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);
}
--
2.3.6
More information about the Piglit
mailing list