mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Move api tests to single cpp
Change-Id: Ie591e4680cfdeb68f47c7d16b5977bd03202c997
This commit is contained in:
committed by
sys_ocldev
parent
8c0aa92048
commit
83dc651d3c
220
unit_tests/api/cl_enqueue_read_image_tests.inl
Normal file
220
unit_tests/api/cl_enqueue_read_image_tests.inl
Normal file
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "cl_api_tests.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/command_queue/command_queue.h"
|
||||
#include "runtime/helpers/surface_formats.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
typedef api_tests clEnqueueReadImageTests;
|
||||
|
||||
namespace ULT {
|
||||
|
||||
struct clEnqueueReadImageTests : public api_fixture,
|
||||
public ::testing::Test {
|
||||
void SetUp() override {
|
||||
api_fixture::SetUp();
|
||||
|
||||
// clang-format off
|
||||
imageFormat.image_channel_order = CL_YUYV_INTEL;
|
||||
imageFormat.image_channel_data_type = CL_UNORM_INT8;
|
||||
|
||||
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imageDesc.image_width = 32;
|
||||
imageDesc.image_height = 32;
|
||||
imageDesc.image_depth = 1;
|
||||
imageDesc.image_array_size = 1;
|
||||
imageDesc.image_row_pitch = 0;
|
||||
imageDesc.image_slice_pitch = 0;
|
||||
imageDesc.num_mip_levels = 0;
|
||||
imageDesc.num_samples = 0;
|
||||
imageDesc.mem_object = nullptr;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
api_fixture::TearDown();
|
||||
}
|
||||
|
||||
cl_image_format imageFormat;
|
||||
cl_image_desc imageDesc;
|
||||
};
|
||||
|
||||
TEST_F(clEnqueueReadImageTests, NullCommandQueue_returnsError) {
|
||||
auto retVal = clEnqueueReadImage(
|
||||
nullptr,
|
||||
nullptr,
|
||||
false,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueReadImageTests, nullImageReturnsError) {
|
||||
auto retVal = clEnqueueReadImage(
|
||||
pCommandQueue,
|
||||
nullptr,
|
||||
false,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_INVALID_MEM_OBJECT, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueReadImageTests, returnSuccess) {
|
||||
imageFormat.image_channel_order = CL_RGBA;
|
||||
auto image = clCreateImage(
|
||||
pContext,
|
||||
CL_MEM_READ_WRITE,
|
||||
&imageFormat,
|
||||
&imageDesc,
|
||||
nullptr,
|
||||
&retVal);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_NE(nullptr, image);
|
||||
const size_t origin[] = {2, 2, 0};
|
||||
const size_t region[] = {2, 2, 1};
|
||||
auto retVal = clEnqueueReadImage(
|
||||
pCommandQueue,
|
||||
image,
|
||||
false,
|
||||
origin,
|
||||
region,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
retVal = clReleaseMemObject(image);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
typedef clEnqueueReadImageTests clEnqueueReadImageYUV_;
|
||||
|
||||
TEST_F(clEnqueueReadImageYUV_, returnSuccess) {
|
||||
auto image = clCreateImage(
|
||||
pContext,
|
||||
CL_MEM_READ_ONLY,
|
||||
&imageFormat,
|
||||
&imageDesc,
|
||||
nullptr,
|
||||
&retVal);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_NE(nullptr, image);
|
||||
const size_t origin[] = {2, 2, 0};
|
||||
const size_t region[] = {2, 2, 1};
|
||||
auto retVal = clEnqueueReadImage(
|
||||
pCommandQueue,
|
||||
image,
|
||||
false,
|
||||
origin,
|
||||
region,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
retVal = clReleaseMemObject(image);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueReadImageYUV_, invalidOrigin) {
|
||||
auto image = clCreateImage(
|
||||
pContext,
|
||||
CL_MEM_READ_ONLY,
|
||||
&imageFormat,
|
||||
&imageDesc,
|
||||
nullptr,
|
||||
&retVal);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_NE(nullptr, image);
|
||||
const size_t origin[] = {1, 2, 0};
|
||||
const size_t region[] = {2, 2, 0};
|
||||
auto retVal = clEnqueueReadImage(
|
||||
pCommandQueue,
|
||||
image,
|
||||
false,
|
||||
origin,
|
||||
region,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
retVal = clReleaseMemObject(image);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueReadImageYUV_, invalidRegion) {
|
||||
auto image = clCreateImage(
|
||||
pContext,
|
||||
CL_MEM_READ_ONLY,
|
||||
&imageFormat,
|
||||
&imageDesc,
|
||||
nullptr,
|
||||
&retVal);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_NE(nullptr, image);
|
||||
const size_t origin[] = {2, 2, 0};
|
||||
const size_t region[] = {1, 2, 0};
|
||||
auto retVal = clEnqueueReadImage(
|
||||
pCommandQueue,
|
||||
image,
|
||||
false,
|
||||
origin,
|
||||
region,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
retVal = clReleaseMemObject(image);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
} // namespace ULT
|
||||
Reference in New Issue
Block a user