Skip to content

Commit

Permalink
Fixes for UT getObjectInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-wozniak-mobica committed Jul 13, 2023
1 parent 0aacec0 commit 0c395f4
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions tests/test_openclhpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4343,7 +4343,16 @@ static cl_mem clCreateFromGLBuffer_testgetObjectInfo(cl_context context,
cl_int *errcode_ret,
int num_calls)
{
(void)num_calls;
switch (num_calls) {
case 0:
TEST_ASSERT_EQUAL(0, bufobj);
break;
case 1:
TEST_ASSERT_EQUAL(1, bufobj);
break;
default:
break;
}

TEST_ASSERT_EQUAL_PTR(make_context(0), context);
TEST_ASSERT_EQUAL(0, flags);
Expand All @@ -4357,10 +4366,24 @@ static cl_int clGetGLObjectInfo_testgetObjectInfo(cl_mem memobj,
cl_GLuint *gl_object_name,
int num)
{
memobj = make_mem(0);
*type = CL_GL_OBJECT_TEXTURE2D_ARRAY;
cl_int ret = CL_SUCCESS;
TEST_ASSERT_EQUAL(memobj, make_mem(0));
switch (num) {
case 0:
TEST_ASSERT_EQUAL(CL_GL_OBJECT_TEXTURE2D_ARRAY, *type);
*type = CL_GL_OBJECT_BUFFER;
break;
case 1:
TEST_ASSERT_EQUAL(CL_GL_OBJECT_BUFFER, *type);
*type = CL_GL_OBJECT_TEXTURE2D_ARRAY;
ret = CL_DEVICE_NOT_FOUND;
break;
default:
break;
}

*gl_object_name = 0;
return CL_SUCCESS;
return ret;
}

cl_int clReleaseMemObject_testgetObjectInfo(cl_mem memobj, int ret)
Expand All @@ -4380,9 +4403,17 @@ void testgetObjectInfo() {
clReleaseMemObject_StubWithCallback(clReleaseMemObject_testgetObjectInfo);
cl::BufferGL buffer(contextPool[0], flags, bufobj, &err);

buffer.getObjectInfo(&type, &bufobj);

TEST_ASSERT_EQUAL_PTR(make_mem(0), buffer());
TEST_ASSERT_EQUAL(CL_SUCCESS, err);

TEST_ASSERT_EQUAL(buffer.getObjectInfo(&type, &bufobj), CL_SUCCESS);
TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER);
TEST_ASSERT_EQUAL(bufobj, 0);
type = CL_GL_OBJECT_BUFFER;
bufobj = 1;

TEST_ASSERT_EQUAL(buffer.getObjectInfo(&type, &bufobj), CL_DEVICE_NOT_FOUND);
TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_TEXTURE2D_ARRAY);
TEST_ASSERT_EQUAL(bufobj, 0);
}
} // extern "C"

0 comments on commit 0c395f4

Please sign in to comment.