Files
compute-runtime/unit_tests/api/cl_release_program_tests.inl
Adam Cetnerowski a060bd2c5d ULT renaming: Release Program tests
Related-To: NEO-2236

Change-Id: Ie338b1a47939e8a8360dc863a07edc56d1bf9593
Signed-off-by: Adam Cetnerowski <adam.cetnerowski@intel.com>
2019-07-17 10:04:22 +02:00

49 lines
1.4 KiB
C++

/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/context/context.h"
#include "cl_api_tests.h"
using namespace NEO;
typedef api_tests clReleaseProgramTests;
TEST_F(clReleaseProgramTests, GivenNullProgramWhenReleasingProgramThenClInvalidProgramIsReturned) {
auto retVal = clReleaseProgram(nullptr);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
}
static const char fakeSrc[] = "__kernel void func(void) { }";
TEST_F(clReleaseProgramTests, GivenRetainedProgramWhenReleasingProgramThenProgramIsReleasedAndProgramReferenceCountDecrementedCorrectly) {
size_t srcLen = sizeof(fakeSrc);
const char *src = fakeSrc;
cl_int retVal;
cl_uint theRef;
cl_program prog = clCreateProgramWithSource(pContext, 1, &src, &srcLen, &retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = clRetainProgram(prog);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = clGetProgramInfo(prog, CL_PROGRAM_REFERENCE_COUNT,
sizeof(cl_uint), &theRef, NULL);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(2u, theRef);
retVal = clReleaseProgram(prog);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = clGetProgramInfo(prog, CL_PROGRAM_REFERENCE_COUNT,
sizeof(cl_uint), &theRef, NULL);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, theRef);
retVal = clReleaseProgram(prog);
EXPECT_EQ(CL_SUCCESS, retVal);
}