Skip to content

Commit

Permalink
fix bugs in negative command_buffer tests
Browse files Browse the repository at this point in the history
- CL_INVALID_VALUE from command_queue != NULL should only be returned
  if the device doesn't support cl_khr_command_buffer_multi_device

- some tests enqueued commands with multiple invalid arguments, e.g.
  clCommandCopyImageToBufferKHR with two images and invalid sync points.
  AFAIK the order of argument checking is not defined, so multiple errors
  can be returned for such API calls, but the tests assumed only one error.
  Fix the tests to be unambiguous.
  • Loading branch information
franz committed May 23, 2024
1 parent d3e3bda commit 4277322
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ struct CommandBufferBarrierNotNullQueue : public BasicCommandBufferTest

return CL_SUCCESS;
}

bool Skip() override
{
return is_extension_available(device,
"cl_khr_command_buffer_multi_device");
}
};

// CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ struct CommandCopyBaseTest : BasicCommandBufferTest

cl_int SetUp(int elements) override
{
num_elements = elements;
origin[0] = origin[1] = origin[2] = 0;
region[0] = elements / 64;
region[1] = 64;
region[2] = 1;
cl_int error = BasicCommandBufferTest::SetUp(elements);
test_error(error, "BasicCommandBufferTest::SetUp failed");

src_image = create_image_2d(context, CL_MEM_READ_ONLY, &formats, 512,
512, 0, NULL, &error);
src_image = create_image_2d(context, CL_MEM_READ_ONLY, &formats,
elements / 64, 64, 0, NULL, &error);
test_error(error, "create_image_2d failed");

dst_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats, 512,
512, 0, NULL, &error);
dst_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats,
elements / 64, 64, 0, NULL, &error);
test_error(error, "create_image_2d failed");

return CL_SUCCESS;
Expand All @@ -58,8 +63,8 @@ struct CommandCopyBaseTest : BasicCommandBufferTest
clMemWrapper src_image;
clMemWrapper dst_image;
const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 };
const size_t origin[3] = { 0, 0, 0 };
const size_t region[3] = { 512, 512, 1 };
size_t origin[3];
size_t region[3];
};

namespace {
Expand All @@ -81,7 +86,7 @@ struct CommandBufferCopyImageQueueNotNull : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(command_buffer, queue, src_image,
dst_image, origin, region, 0, 0,
out_mem, origin, region, 0, 0,
nullptr, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_COMMAND_QUEUE,
Expand Down Expand Up @@ -119,8 +124,8 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(
command_buffer, nullptr, src_image_ctx, dst_image, origin, region,
0, 0, nullptr, nullptr, nullptr);
command_buffer, nullptr, src_image_ctx, out_mem, origin, region, 0,
0, nullptr, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_CONTEXT,
"clCommandCopyImageToBufferKHR should return "
Expand Down Expand Up @@ -159,7 +164,7 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(
command_buffer, nullptr, src_image, dst_image, origin, region, 0, 0,
command_buffer, nullptr, src_image, out_mem, origin, region, 0, 0,
nullptr, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_CONTEXT,
Expand All @@ -179,11 +184,11 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest
test_error(error, "Failed to create context");

src_image_ctx = create_image_2d(context1, CL_MEM_READ_ONLY, &formats,
512, 512, 0, NULL, &error);
elements / 64, 64, 0, NULL, &error);
test_error(error, "create_image_2d failed");

dst_image_ctx = create_image_2d(context1, CL_MEM_WRITE_ONLY, &formats,
512, 512, 0, NULL, &error);
elements / 64, 64, 0, NULL, &error);
test_error(error, "create_image_2d failed");

queue1 = clCreateCommandQueue(context1, device, 0, &error);
Expand Down Expand Up @@ -220,7 +225,7 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(
command_buffer, nullptr, src_image, dst_image, origin, region, 0, 1,
command_buffer, nullptr, src_image, out_mem, origin, region, 0, 1,
&invalid_point, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR,
Expand All @@ -239,7 +244,7 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(
command_buffer, nullptr, src_image, dst_image, origin, region, 0, 1,
command_buffer, nullptr, src_image, out_mem, origin, region, 0, 1,
nullptr, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR,
Expand All @@ -263,7 +268,7 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(
command_buffer, nullptr, src_image, dst_image, origin, region, 0, 0,
command_buffer, nullptr, src_image, out_mem, origin, region, 0, 0,
&point, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR,
Expand Down Expand Up @@ -294,7 +299,7 @@ struct CommandBufferCopyImageInvalidCommandBuffer : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(nullptr, nullptr, src_image,
dst_image, origin, region, 0, 0,
out_mem, origin, region, 0, 0,
nullptr, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_COMMAND_BUFFER_KHR,
Expand Down Expand Up @@ -327,7 +332,7 @@ struct CommandBufferCopyImageFinalizedCommandBuffer : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(
command_buffer, nullptr, src_image, dst_image, origin, region, 0, 0,
command_buffer, nullptr, src_image, out_mem, origin, region, 0, 0,
nullptr, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_OPERATION,
Expand Down Expand Up @@ -358,7 +363,7 @@ struct CommandBufferCopyImageMutableHandleNotNull : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(
command_buffer, nullptr, src_image, dst_image, origin, region, 0, 0,
command_buffer, nullptr, src_image, out_mem, origin, region, 0, 0,
nullptr, nullptr, &mutable_handle);

test_failure_error_ret(error, CL_INVALID_VALUE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ struct CommandBufferCommandSVMQueueNotNull : public BasicSVMCommandBufferTest
}

const cl_char pattern_1 = 0x14;

bool Skip() override
{
return is_extension_available(device,
"cl_khr_command_buffer_multi_device");
}
};

// CL_INVALID_SYNC_POINT_WAIT_LIST_KHR if sync_point_wait_list is NULL and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ struct CommandNDRangeKernelQueueNotNull : public BasicCommandBufferTest

return CL_SUCCESS;
}

bool Skip() override
{
return is_extension_available(device,
"cl_khr_command_buffer_multi_device");
}
};

// CL_INVALID_CONTEXT if the context associated with command_queue,
Expand Down Expand Up @@ -108,7 +114,7 @@ struct CommandNDRangeKerneSyncPointsNullOrNumZero
cl_sync_point_khr invalid_point = 0;
cl_sync_point_khr* invalid_sync_points[] = { &invalid_point };
cl_int error = clCommandNDRangeKernelKHR(
command_buffer, nullptr, nullptr, kernel, 0, nullptr, &num_elements,
command_buffer, nullptr, nullptr, kernel, 1, nullptr, &num_elements,
nullptr, 1, invalid_sync_points[0], nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR,
Expand All @@ -134,7 +140,7 @@ struct CommandNDRangeKerneSyncPointsNullOrNumZero

cl_sync_point_khr* sync_points[] = { &point };
error = clCommandNDRangeKernelKHR(
command_buffer, nullptr, nullptr, kernel, 0, nullptr, &num_elements,
command_buffer, nullptr, nullptr, kernel, 1, nullptr, &num_elements,
nullptr, 0, sync_points[0], nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR,
Expand Down

0 comments on commit 4277322

Please sign in to comment.