Skip to content

Commit 6499330

Browse files
authored
[UR][CTS] Flip command-buffer assert condition (#18409)
The comparison on the assert conditions was incorrect, and should be flipped to verify that the allocation size is greater than or equal to the bytes being copied/read/written. Discovered during local testing with a debug build ``` [ RUN ] urCommandBufferMemcpyCommandsTest.Buffer/NVIDIA_CUDA_BACKEND__NVIDIA_GeForce_GT_1030_ID0ID______W_________B______size__256__offset_src__127__offset_src__127__copy_size__128 test-exp_command_buffer: unified-runtime/test/conformance/exp_command_buffer/copy.cpp:28: virtual void urCommandBufferMemcpyCommandsTest::SetUp(): Assertion `size <= offset_src + copy_size' failed. Aborted (core dumped) ``` We could just remove these asserts, as they are not present in other CTS tests, but I think they do add some value in catching programmer error when adding additional parameterized gtest cases, so kept the corrected version around
1 parent 713a9dd commit 6499330

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

unified-runtime/test/conformance/exp_command_buffer/copy.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ struct urCommandBufferMemcpyCommandsTest
2525
offset_src = std::get<1>(GetParam()).offset_src;
2626
offset_dst = std::get<1>(GetParam()).offset_dst;
2727
copy_size = std::get<1>(GetParam()).copy_size;
28-
assert(size <= offset_src + copy_size);
29-
assert(size <= offset_dst + copy_size);
28+
assert(size >= offset_src + copy_size);
29+
assert(size >= offset_dst + copy_size);
3030
// Allocate USM pointers
3131
ASSERT_SUCCESS(
3232
urUSMDeviceAlloc(context, device, nullptr, nullptr, size, &device_ptr));

unified-runtime/test/conformance/exp_command_buffer/read.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct urCommandBufferReadCommandsTest
2222
size = std::get<1>(GetParam()).size;
2323
offset = std::get<1>(GetParam()).offset;
2424
read_size = std::get<1>(GetParam()).read_size;
25-
assert(size <= offset + read_size);
25+
assert(size >= offset + read_size);
2626
// Allocate USM pointers
2727
ASSERT_SUCCESS(
2828
urUSMDeviceAlloc(context, device, nullptr, nullptr, size, &device_ptr));

unified-runtime/test/conformance/exp_command_buffer/write.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct urCommandBufferWriteCommandsTest
2323
size = std::get<1>(GetParam()).size;
2424
offset = std::get<1>(GetParam()).offset;
2525
write_size = std::get<1>(GetParam()).write_size;
26-
assert(size <= offset + write_size);
26+
assert(size >= offset + write_size);
2727
// Allocate USM pointers
2828
ASSERT_SUCCESS(
2929
urUSMDeviceAlloc(context, device, nullptr, nullptr, size, &device_ptr));

0 commit comments

Comments
 (0)