[Beignet] [PATCH 3/5] Utest: Fix utest memleaks
Xiuli Pan
xiuli.pan at intel.com
Thu May 5 06:42:17 UTC 2016
From: Pan Xiuli <xiuli.pan at intel.com>
Free all memory allocated and release all cl objects.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
utests/compare_image_2d_and_1d_array.cpp | 2 ++
utests/compiler_fill_image_1d_array.cpp | 1 +
utests/compiler_function_qualifiers.cpp | 1 +
utests/image_1D_buffer.cpp | 1 +
utests/load_program_from_gen_bin.cpp | 4 ++++
utests/load_program_from_spir.cpp | 2 ++
utests/runtime_compile_link.cpp | 8 ++++++++
utests/utest_helper.cpp | 1 +
8 files changed, 20 insertions(+)
diff --git a/utests/compare_image_2d_and_1d_array.cpp b/utests/compare_image_2d_and_1d_array.cpp
index dfa4273..f2db680 100644
--- a/utests/compare_image_2d_and_1d_array.cpp
+++ b/utests/compare_image_2d_and_1d_array.cpp
@@ -84,6 +84,8 @@ static void compare_image_2d_and_1d_array(void)
free(dst0);
free(dst1);
+ free(image_data1);
+ free(image_data2);
OCL_CALL(clReleaseSampler, sampler);
}
diff --git a/utests/compiler_fill_image_1d_array.cpp b/utests/compiler_fill_image_1d_array.cpp
index 67f9643..23a8425 100644
--- a/utests/compiler_fill_image_1d_array.cpp
+++ b/utests/compiler_fill_image_1d_array.cpp
@@ -69,6 +69,7 @@ static void compiler_fill_image_1d_array(void)
for (uint32_t i = 0; i < w; i++) {
OCL_ASSERT(dst[(array - 1)*w + i] == 0x0);
}
+ free(src);
free(dst);
}
diff --git a/utests/compiler_function_qualifiers.cpp b/utests/compiler_function_qualifiers.cpp
index 622313c..4599c95 100644
--- a/utests/compiler_function_qualifiers.cpp
+++ b/utests/compiler_function_qualifiers.cpp
@@ -13,6 +13,7 @@ void compiler_function_qualifiers(void)
param_value = malloc(param_value_size);
err = clGetKernelInfo(kernel, CL_KERNEL_ATTRIBUTES, param_value_size, param_value, NULL);
OCL_ASSERT(err == CL_SUCCESS);
+ free(param_value);
}
MAKE_UTEST_FROM_FUNCTION(compiler_function_qualifiers);
diff --git a/utests/image_1D_buffer.cpp b/utests/image_1D_buffer.cpp
index e2cfcde..f2eb7a3 100644
--- a/utests/image_1D_buffer.cpp
+++ b/utests/image_1D_buffer.cpp
@@ -60,6 +60,7 @@ void image_1D_buffer(void)
}
OCL_UNMAP_BUFFER(0);
OCL_UNMAP_BUFFER(1);
+ free(buf_content);
}
MAKE_UTEST_FROM_FUNCTION(image_1D_buffer);
diff --git a/utests/load_program_from_gen_bin.cpp b/utests/load_program_from_gen_bin.cpp
index 3db13b2..7504aa3 100644
--- a/utests/load_program_from_gen_bin.cpp
+++ b/utests/load_program_from_gen_bin.cpp
@@ -88,6 +88,10 @@ static void test_load_program_from_gen_bin(void)
OCL_ASSERT(((float *)buf_data[1])[i] == cpu_dst[i]);
OCL_UNMAP_BUFFER(1);
}
+ cl_file_map_delete(fm);
+ clReleaseProgram(bin_program);
+ free(binary);
+ free(ker_path);
}
MAKE_UTEST_FROM_FUNCTION(test_load_program_from_gen_bin);
diff --git a/utests/load_program_from_spir.cpp b/utests/load_program_from_spir.cpp
index 8ea1cd4..76dbef4 100644
--- a/utests/load_program_from_spir.cpp
+++ b/utests/load_program_from_spir.cpp
@@ -85,6 +85,8 @@ static void test_load_program_from_spir(void)
OCL_ASSERT(((float *)buf_data[1])[i] == cpu_dst[i]);
OCL_UNMAP_BUFFER(1);
}
+ free(ker_path);
+ cl_file_map_delete(fm);
}
MAKE_UTEST_FROM_FUNCTION(test_load_program_from_spir);
diff --git a/utests/runtime_compile_link.cpp b/utests/runtime_compile_link.cpp
index 4a39b6a..48c3fa1 100644
--- a/utests/runtime_compile_link.cpp
+++ b/utests/runtime_compile_link.cpp
@@ -157,6 +157,14 @@ void runtime_compile_link(void)
}
OCL_UNMAP_BUFFER(2);
OCL_DESTROY_KERNEL_KEEP_PROGRAM(true);
+ clReleaseProgram(foo_pg);
+ clReleaseProgram(myinc_pg);
+ clReleaseProgram(program_A);
+ clReleaseProgram(program_B);
+ clReleaseProgram(linked_program);
+ clReleaseProgram(new_linked_program);
+ clReleaseProgram(program_with_binary);
+ free(binary);
}
MAKE_UTEST_FROM_FUNCTION(runtime_compile_link);
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp
index 9696dac..4d2d4df 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -365,6 +365,7 @@ cl_kernel_link(const char *file_name, const char *kernel_name, const char * link
program = clLinkProgram(ctx, 1, &device, link_opt, 1, input_programs, NULL, NULL, &status);
OCL_ASSERT(program != NULL);
OCL_ASSERT(status == CL_SUCCESS);
+ clReleaseProgram(input_programs[0]);
}
/* Create a kernel from the program */
--
2.5.0
More information about the Beignet
mailing list