Skip to content

Commit

Permalink
Fix memory leaks in loader_test. (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerilk authored Feb 8, 2024
1 parent 5383646 commit 932d826
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/driver_stub/cl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1835,11 +1835,13 @@ clEnqueueNativeKernel(cl_command_queue command_queue ,
return return_value;
}

static void extFunc(void) { }

CL_API_ENTRY void * CL_API_CALL
clGetExtensionFunctionAddressForPlatform(cl_platform_id platform ,
const char * func_name) CL_API_SUFFIX__VERSION_1_2
{
void *return_value = (void *) malloc(sizeof(void *));
void *return_value = (void *)(size_t)&extFunc;
test_icd_stub_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n",
platform,
func_name);
Expand Down
4 changes: 4 additions & 0 deletions test/loader_test/test_create_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,16 @@ int test_create_calls()

test_clCreateBuffer(clCreateBufferData);

test_clReleaseMemObject(clReleaseMemObjectData);

test_clCreateBufferWithProperties(clCreateBufferWithPropertiesData);

test_clCreateSubBuffer(clCreateSubBufferData);

test_clCreateImage(clCreateImageData);

test_clReleaseMemObject(clReleaseMemObjectDataImage);

test_clCreateImageWithProperties(clCreateImageWithPropertiesData);

test_clReleaseMemObject(clReleaseMemObjectDataImage);
Expand Down
5 changes: 5 additions & 0 deletions test/loader_test/test_program_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ int test_clCompileProgram(const struct clCompileProgram_st *data)
int test_clLinkProgram(const struct clLinkProgram_st *data)
{
cl_program program;
cl_int ret_val;
test_icd_app_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n",
context,
data->num_devices,
Expand All @@ -147,6 +148,10 @@ int test_clLinkProgram(const struct clLinkProgram_st *data)

test_icd_app_log("Value returned: %p\n", program);

test_icd_app_log("clReleaseProgram(%p)\n", program);
ret_val = clReleaseProgram(program);
test_icd_app_log("Value returned: %d\n", ret_val);

return 0;

}
Expand Down

0 comments on commit 932d826

Please sign in to comment.