From c0e6447961ba7369d2cf8da246cb65dd2cd4c7f3 Mon Sep 17 00:00:00 2001 From: Michael Rizkalla Date: Thu, 27 Nov 2025 00:20:46 +0000 Subject: [PATCH] Implement negative tests for clEnqueueMarkerWithWaitList (#2502) This change adds negative tests for `clEnqueueMarkerWithWaitList` Signed-off-by: Michael Rizkalla --- test_conformance/api/CMakeLists.txt | 1 + .../api/negative_enqueue_marker.cpp | 97 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 test_conformance/api/negative_enqueue_marker.cpp diff --git a/test_conformance/api/CMakeLists.txt b/test_conformance/api/CMakeLists.txt index b781e49b..c0ab77b5 100644 --- a/test_conformance/api/CMakeLists.txt +++ b/test_conformance/api/CMakeLists.txt @@ -6,6 +6,7 @@ set(${MODULE_NAME}_SOURCES main.cpp negative_platform.cpp negative_queue.cpp + negative_enqueue_marker.cpp negative_enqueue_map_image.cpp test_api_consistency.cpp test_bool.cpp diff --git a/test_conformance/api/negative_enqueue_marker.cpp b/test_conformance/api/negative_enqueue_marker.cpp new file mode 100644 index 00000000..182b3dbf --- /dev/null +++ b/test_conformance/api/negative_enqueue_marker.cpp @@ -0,0 +1,97 @@ +// +// Copyright (c) 2025 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "testBase.h" +#include "harness/typeWrappers.h" + +REGISTER_TEST(negative_enqueue_marker_with_wait_list) +{ + cl_platform_id platform = getPlatformFromDevice(device); + cl_context_properties props[3] = { + CL_CONTEXT_PLATFORM, reinterpret_cast(platform), + 0 + }; + + cl_int err = CL_SUCCESS; + clContextWrapper ctx = + clCreateContext(props, 1, &device, nullptr, nullptr, &err); + test_error(err, "clCreateContext failed"); + + cl_event ret_event = nullptr; + + err = clEnqueueMarkerWithWaitList(nullptr, 0, nullptr, &ret_event); + test_failure_error_ret(err, CL_INVALID_COMMAND_QUEUE, + "clEnqueueMarkerWithWaitList should return " + "CL_INVALID_COMMAND_QUEUE when: \"command_queue is " + "not a valid host command-queue\" using a nullptr", + TEST_FAIL); + test_assert_error(ret_event == nullptr, + "if clEnqueueMarkerWithWaitList failed, no ret_event " + "should be created"); + + clEventWrapper different_ctx_event = clCreateUserEvent(ctx, &err); + test_error(err, "clCreateUserEvent failed"); + + err = + clEnqueueMarkerWithWaitList(queue, 1, &different_ctx_event, &ret_event); + test_failure_error_ret( + err, CL_INVALID_CONTEXT, + "clEnqueueMarkerWithWaitList should return CL_INVALID_CONTEXT when: " + "\"The context of both the command queue and the events in ret_event " + "wait list are not the same\"", + TEST_FAIL); + test_assert_error(ret_event == nullptr, + "if clEnqueueMarkerWithWaitList failed, no ret_event " + "should be created"); + + err = clEnqueueMarkerWithWaitList(queue, 1, nullptr, &ret_event); + test_failure_error_ret( + err, CL_INVALID_EVENT_WAIT_LIST, + "clEnqueueMarkerWithWaitList should return CL_INVALID_EVENT_WAIT_LIST " + "when: \"num_events_in_wait_list > 0 but event_wait_list is NULL\"", + TEST_FAIL); + test_assert_error(ret_event == nullptr, + "if clEnqueueMarkerWithWaitList failed, no ret_event " + "should be created"); + + + clEventWrapper event = clCreateUserEvent(context, &err); + test_error(err, "clCreateUserEvent failed"); + + err = clEnqueueMarkerWithWaitList(queue, 0, &event, &ret_event); + test_failure_error_ret( + err, CL_INVALID_EVENT_WAIT_LIST, + "clEnqueueMarkerWithWaitList should return CL_INVALID_EVENT_WAIT_LIST " + "when: \"num_events_in_wait_list is 0 but event_wait_list is not " + "NULL\"", + TEST_FAIL); + test_assert_error(ret_event == nullptr, + "if clEnqueueMarkerWithWaitList failed, no ret_event " + "should be created"); + + cl_event invalid_event_wait_list[] = { nullptr }; + err = clEnqueueMarkerWithWaitList(queue, 1, invalid_event_wait_list, + &ret_event); + test_failure_error_ret( + err, CL_INVALID_EVENT_WAIT_LIST, + "clEnqueueMarkerWithWaitList should return CL_INVALID_EVENT_WAIT_LIST " + "when: \"event objects in event_wait_list are not valid events\"", + TEST_FAIL); + test_assert_error(ret_event == nullptr, + "if clEnqueueMarkerWithWaitList failed, no ret_event " + "should be created"); + + return TEST_PASS; +}