Mesa (master): tests: Fix memory leaks in DispatchSanity
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 7 22:59:28 UTC 2021
Module: Mesa
Branch: master
Commit: ab0d17338f9a8fd1185aa14ca3ebf5a9c7b89acd
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ab0d17338f9a8fd1185aa14ca3ebf5a9c7b89acd
Author: Adam Jackson <ajax at redhat.com>
Date: Thu Jan 7 13:36:11 2021 -0500
tests: Fix memory leaks in DispatchSanity
Needed to pass asan CI.
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8353>
---
src/mesa/main/tests/dispatch_sanity.cpp | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 72c1e0bc739..bbb3ee03791 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -79,7 +79,9 @@ extern const struct function gles31_functions_possible[];
class DispatchSanity_test : public ::testing::Test {
public:
virtual void SetUp();
+ virtual void TearDown();
void SetUpCtx(gl_api api, unsigned int version);
+ void TearDownCtx();
struct gl_config visual;
struct dd_function_table driver_functions;
@@ -102,6 +104,12 @@ DispatchSanity_test::SetUp()
nop_table = (_glapi_proc *) _mesa_new_nop_table(size);
}
+void
+DispatchSanity_test::TearDown()
+{
+ free(nop_table);
+}
+
void
DispatchSanity_test::SetUpCtx(gl_api api, unsigned int version)
{
@@ -119,6 +127,13 @@ DispatchSanity_test::SetUpCtx(gl_api api, unsigned int version)
_mesa_initialize_vbo_vtxfmt(&ctx);
}
+void
+DispatchSanity_test::TearDownCtx()
+{
+ _vbo_DestroyContext(&ctx);
+ _mesa_free_context_data(&ctx, false);
+}
+
static const char *
offset_to_proc_name_safe(unsigned offset)
{
@@ -182,6 +197,7 @@ TEST_F(DispatchSanity_test, GL31_CORE)
validate_functions(&ctx, common_desktop_functions_possible, nop_table);
validate_functions(&ctx, gl_core_functions_possible, nop_table);
validate_nops(&ctx, nop_table);
+ TearDownCtx();
}
TEST_F(DispatchSanity_test, GL30)
@@ -190,6 +206,7 @@ TEST_F(DispatchSanity_test, GL30)
validate_functions(&ctx, common_desktop_functions_possible, nop_table);
validate_functions(&ctx, gl_compatibility_functions_possible, nop_table);
validate_nops(&ctx, nop_table);
+ TearDownCtx();
}
TEST_F(DispatchSanity_test, GLES11)
@@ -197,6 +214,7 @@ TEST_F(DispatchSanity_test, GLES11)
SetUpCtx(API_OPENGLES, 11);
validate_functions(&ctx, gles11_functions_possible, nop_table);
validate_nops(&ctx, nop_table);
+ TearDownCtx();
}
TEST_F(DispatchSanity_test, GLES2)
@@ -204,6 +222,7 @@ TEST_F(DispatchSanity_test, GLES2)
SetUpCtx(API_OPENGLES2, 20);
validate_functions(&ctx, gles2_functions_possible, nop_table);
validate_nops(&ctx, nop_table);
+ TearDownCtx();
}
TEST_F(DispatchSanity_test, GLES3)
@@ -212,6 +231,7 @@ TEST_F(DispatchSanity_test, GLES3)
validate_functions(&ctx, gles2_functions_possible, nop_table);
validate_functions(&ctx, gles3_functions_possible, nop_table);
validate_nops(&ctx, nop_table);
+ TearDownCtx();
}
TEST_F(DispatchSanity_test, GLES31)
@@ -221,6 +241,7 @@ TEST_F(DispatchSanity_test, GLES31)
validate_functions(&ctx, gles3_functions_possible, nop_table);
validate_functions(&ctx, gles31_functions_possible, nop_table);
validate_nops(&ctx, nop_table);
+ TearDownCtx();
}
const struct function common_desktop_functions_possible[] = {
More information about the mesa-commit
mailing list