Skip to content

Commit

Permalink
Merge pull request #508 from aarongreig/aaron/kernelTestFixes
Browse files Browse the repository at this point in the history
Fix some issues with the program and kernel test implementations.
  • Loading branch information
aarongreig authored May 12, 2023
2 parents 44471d6 + af6b8cb commit cd2122c
Show file tree
Hide file tree
Showing 24 changed files with 39 additions and 31 deletions.
12 changes: 6 additions & 6 deletions test/conformance/kernel/urKernelCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ struct urKernelCreateTest : uur::urProgramTest {
std::string kernel_name;
ur_kernel_handle_t kernel = nullptr;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelCreateTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelCreateTest);

TEST_F(urKernelCreateTest, Success) {
TEST_P(urKernelCreateTest, Success) {
ASSERT_SUCCESS(urKernelCreate(program, kernel_name.data(), &kernel));
}

TEST_F(urKernelCreateTest, InvalidNullHandleProgram) {
TEST_P(urKernelCreateTest, InvalidNullHandleProgram) {
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
urKernelCreate(nullptr, kernel_name.data(), &kernel));
}

TEST_F(urKernelCreateTest, InvalidNullPointerName) {
TEST_P(urKernelCreateTest, InvalidNullPointerName) {
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
urKernelCreate(program, nullptr, &kernel));
}

TEST_F(urKernelCreateTest, InvalidNullPointerKernel) {
TEST_P(urKernelCreateTest, InvalidNullPointerKernel) {
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
urKernelCreate(program, kernel_name.data(), nullptr));
}

TEST_F(urKernelCreateTest, InvalidKernelName) {
TEST_P(urKernelCreateTest, InvalidKernelName) {
std::string invalid_name = "";
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_NAME,
urKernelCreate(program, invalid_name.data(), &kernel));
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/kernel/urKernelCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct urKernelCreateWithNativeHandleTest : uur::urKernelTest {
true /*isNativeHandleOwned*/
};
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelCreateWithNativeHandleTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelCreateWithNativeHandleTest);

TEST_P(urKernelCreateWithNativeHandleTest, Success) {
ASSERT_SUCCESS(urKernelCreateWithNativeHandle(
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/kernel/urKernelGetNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uur/fixtures.h>

using urKernelGetNativeHandleTest = uur::urKernelTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelGetNativeHandleTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelGetNativeHandleTest);

TEST_P(urKernelGetNativeHandleTest, Success) {
ur_native_handle_t native_kernel_handle = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/kernel/urKernelRelease.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uur/fixtures.h>

using urKernelReleaseTest = uur::urKernelTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelReleaseTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelReleaseTest);

TEST_P(urKernelReleaseTest, Success) {
ASSERT_SUCCESS(urKernelRetain(kernel));
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/kernel/urKernelRetain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uur/fixtures.h>

using urKernelRetainTest = uur::urKernelTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelRetainTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelRetainTest);

TEST_P(urKernelRetainTest, Success) {
ASSERT_SUCCESS(urKernelRetain(kernel));
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/kernel/urKernelSetArgLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct urKernelSetArgLocalTest : uur::urKernelTest {
}
size_t local_mem_size = 4 * sizeof(uint32_t);
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelSetArgLocalTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetArgLocalTest);

TEST_P(urKernelSetArgLocalTest, Success) {
ASSERT_SUCCESS(urKernelSetArgLocal(kernel, 1, local_mem_size));
Expand Down
4 changes: 2 additions & 2 deletions test/conformance/kernel/urKernelSetArgMemObj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ struct urKernelSetArgMemObjTest : uur::urKernelTest {
UUR_RETURN_ON_FATAL_FAILURE(urKernelTest::TearDown());
}

ur_mem_handle_t buffer;
ur_mem_handle_t buffer = nullptr;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelSetArgMemObjTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetArgMemObjTest);

TEST_P(urKernelSetArgMemObjTest, Success) {
ASSERT_SUCCESS(urKernelSetArgMemObj(kernel, 0, buffer));
Expand Down
4 changes: 2 additions & 2 deletions test/conformance/kernel/urKernelSetArgPointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct urKernelSetArgPointerTest : uur::urKernelTest {
void *allocation = nullptr;
size_t allocation_size = 16 * sizeof(uint32_t);
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelSetArgPointerTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetArgPointerTest);

TEST_P(urKernelSetArgPointerTest, SuccessHost) {
bool host_supported = false;
Expand Down Expand Up @@ -104,7 +104,7 @@ struct urKernelSetArgPointerNegativeTest : urKernelSetArgPointerTest {
UUR_RETURN_ON_FATAL_FAILURE(urKernelSetArgPointerTest::SetUp());
}
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelSetArgPointerNegativeTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetArgPointerNegativeTest);

TEST_P(urKernelSetArgPointerNegativeTest, InvalidNullHandleKernel) {
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/kernel/urKernelSetArgSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct urKernelSetArgSamplerTest : uur::urKernelTest {

ur_sampler_handle_t sampler = nullptr;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelSetArgSamplerTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetArgSamplerTest);

TEST_P(urKernelSetArgSamplerTest, Success) {
ASSERT_SUCCESS(urKernelSetArgSampler(kernel, 2, sampler));
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/kernel/urKernelSetArgValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct urKernelSetArgValueTest : uur::urKernelTest {

uint32_t arg_value = 42;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelSetArgValueTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetArgValueTest);

TEST_P(urKernelSetArgValueTest, Success) {
ASSERT_SUCCESS(
Expand Down
4 changes: 2 additions & 2 deletions test/conformance/kernel/urKernelSetExecInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uur/fixtures.h>

using urKernelSetExecInfoTest = uur::urKernelTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelSetExecInfoTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetExecInfoTest);

TEST_P(urKernelSetExecInfoTest, SuccessIndirectAccess) {
bool property_value = false;
Expand Down Expand Up @@ -53,7 +53,7 @@ struct urKernelSetExecInfoUSMPointersTest : uur::urKernelTest {
size_t allocation_size = 16;
void *allocation = nullptr;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelSetExecInfoUSMPointersTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetExecInfoUSMPointersTest);

TEST_P(urKernelSetExecInfoUSMPointersTest, SuccessHost) {
bool host_supported = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct urKernelSetSpecializationConstantsTest : uur::urKernelTest {
ur_specialization_constant_info_t info = {0, sizeof(spec_value),
&spec_value};
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urKernelSetSpecializationConstantsTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetSpecializationConstantsTest);

TEST_P(urKernelSetSpecializationConstantsTest, Success) {
ASSERT_SUCCESS(urKernelSetSpecializationConstants(kernel, 1, &info));
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/program/urProgramBuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uur/fixtures.h>

using urProgramBuildTest = uur::urProgramTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramBuildTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramBuildTest);

TEST_P(urProgramBuildTest, Success) {
ASSERT_SUCCESS(urProgramBuild(context, program, nullptr));
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/program/urProgramCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uur/fixtures.h>

using urProgramCompileTest = uur::urProgramTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramCompileTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramCompileTest);

TEST_P(urProgramCompileTest, Success) {
ASSERT_SUCCESS(urProgramCompile(context, program, nullptr));
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/program/urProgramCreateWithBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct urProgramCreateWithBinaryTest : uur::urProgramTest {
std::vector<uint8_t> binary;
ur_program_handle_t binary_program = nullptr;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramCreateWithBinaryTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramCreateWithBinaryTest);

TEST_P(urProgramCreateWithBinaryTest, Success) {
ASSERT_SUCCESS(urProgramCreateWithBinary(context, device, binary.size(),
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/program/urProgramCreateWithIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct urProgramCreateWithILTest : uur::urContextTest {

std::shared_ptr<std::vector<char>> il_binary;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramCreateWithILTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramCreateWithILTest);

TEST_P(urProgramCreateWithILTest, Success) {
ur_program_handle_t program = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct urProgramCreateWithNativeHandleTest : uur::urProgramTest {
ur_native_handle_t native_program_handle = nullptr;
ur_program_handle_t native_program = nullptr;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramCreateWithNativeHandleTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramCreateWithNativeHandleTest);

TEST_P(urProgramCreateWithNativeHandleTest, Success) {
ASSERT_SUCCESS(urProgramCreateWithNativeHandle(native_program_handle,
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/program/urProgramGetFunctionPointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct urProgramGetFunctionPointerTest : uur::urProgramTest {

std::string function_name;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramGetFunctionPointerTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramGetFunctionPointerTest);

TEST_P(urProgramGetFunctionPointerTest, Success) {
void *function_pointer = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/program/urProgramGetNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uur/fixtures.h>

using urProgramGetNativeHandleTest = uur::urProgramTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramGetNativeHandleTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramGetNativeHandleTest);

TEST_P(urProgramGetNativeHandleTest, Success) {
ur_native_handle_t native_program_handle = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/program/urProgramLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct urProgramLinkTest : uur::urProgramTest {
std::shared_ptr<std::vector<char>> bar_binary;
std::vector<ur_program_handle_t> programs;
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramLinkTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramLinkTest);

TEST_P(urProgramLinkTest, Success) {
ASSERT_SUCCESS(urProgramLink(context, programs.size(), programs.data(),
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/program/urProgramRelease.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uur/fixtures.h>

using urProgramReleaseTest = uur::urProgramTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramReleaseTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramReleaseTest);

TEST_P(urProgramReleaseTest, Success) {
ASSERT_SUCCESS(urProgramRetain(program));
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/program/urProgramRetain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uur/fixtures.h>

using urProgramRetainTest = uur::urProgramTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramRetainTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramRetainTest);

TEST_P(urProgramRetainTest, Success) {
ASSERT_SUCCESS(urProgramRetain(program));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct urProgramSetSpecializationConstantsTest : uur::urProgramTest {
ur_specialization_constant_info_t info = {0, sizeof(spec_value),
&spec_value};
};
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urProgramSetSpecializationConstantsTest);
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramSetSpecializationConstantsTest);

TEST_P(urProgramSetSpecializationConstantsTest, Success) {
ASSERT_SUCCESS(urProgramSetSpecializationConstants(program, 1, &info));
Expand Down
8 changes: 8 additions & 0 deletions test/conformance/testing/include/uur/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ struct urDeviceTest : urPlatformTest,
return uur::GetPlatformAndDeviceName(info.param); \
})

#define UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(FIXTURE) \
INSTANTIATE_TEST_SUITE_P( \
, FIXTURE, \
::testing::ValuesIn(uur::KernelsEnvironment::instance->devices), \
[](const ::testing::TestParamInfo<ur_device_handle_t> &info) { \
return uur::GetPlatformAndDeviceName(info.param); \
})

namespace uur {

template <class T>
Expand Down

0 comments on commit cd2122c

Please sign in to comment.