1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
/*
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/helpers/unit_test_helper.h"
#include "opencl/source/context/context.h"
#include "opencl/test/unit_test/mocks/mock_kernel.h"
#include "cl_api_tests.h"
#include <type_traits>
using namespace NEO;
namespace ULT {
TEST(clReleaseCommandQueueTest, GivenNullCmdQueueWhenReleasingCmdQueueThenClInvalidCommandQueueErrorIsReturned) {
auto retVal = clReleaseCommandQueue(nullptr);
EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retVal);
}
using ClReleaseCommandQueueTests = ApiTests;
TEST_F(ClReleaseCommandQueueTests, givenBlockedEnqueueWithOutputEventStoredAsVirtualEventWhenReleasingCmdQueueThenInternalRefCountIsDecrementedAndQueueDeleted) {
cl_command_queue cmdQ = nullptr;
cl_queue_properties properties = 0;
ClDevice *device = (ClDevice *)testedClDevice;
MockKernelWithInternals kernelInternals(*device, pContext);
cmdQ = clCreateCommandQueue(pContext, testedClDevice, properties, &retVal);
ASSERT_NE(nullptr, cmdQ);
ASSERT_EQ(CL_SUCCESS, retVal);
size_t offset[] = {0, 0, 0};
size_t gws[] = {1, 1, 1};
cl_int retVal = CL_SUCCESS;
cl_int success = CL_SUCCESS;
cl_event event = clCreateUserEvent(pContext, &retVal);
cl_event eventOut = nullptr;
EXPECT_EQ(success, retVal);
retVal = clEnqueueNDRangeKernel(cmdQ, kernelInternals.mockMultiDeviceKernel, 1, offset, gws, nullptr, 1, &event, &eventOut);
EXPECT_EQ(success, retVal);
EXPECT_NE(nullptr, eventOut);
clSetUserEventStatus(event, CL_COMPLETE);
clReleaseEvent(event);
clReleaseEvent(eventOut);
retVal = clReleaseCommandQueue(cmdQ);
EXPECT_EQ(success, retVal);
}
} // namespace ULT
|