| 1 | //===------- Offload API tests - olGetKernel ---------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "../common/Fixtures.hpp" |
| 10 | #include <OffloadAPI.h> |
| 11 | #include <gtest/gtest.h> |
| 12 | |
| 13 | using olGetKernelTest = OffloadProgramTest; |
| 14 | OFFLOAD_TESTS_INSTANTIATE_DEVICE_FIXTURE(olGetKernelTest); |
| 15 | |
| 16 | TEST_P(olGetKernelTest, Success) { |
| 17 | ol_kernel_handle_t Kernel = nullptr; |
| 18 | ASSERT_SUCCESS(olGetKernel(Program, "foo" , &Kernel)); |
| 19 | ASSERT_NE(Kernel, nullptr); |
| 20 | } |
| 21 | |
| 22 | TEST_P(olGetKernelTest, InvalidNullProgram) { |
| 23 | ol_kernel_handle_t Kernel = nullptr; |
| 24 | ASSERT_ERROR(OL_ERRC_INVALID_NULL_HANDLE, |
| 25 | olGetKernel(nullptr, "foo" , &Kernel)); |
| 26 | } |
| 27 | |
| 28 | TEST_P(olGetKernelTest, InvalidNullKernelPointer) { |
| 29 | ASSERT_ERROR(OL_ERRC_INVALID_NULL_POINTER, |
| 30 | olGetKernel(Program, "foo" , nullptr)); |
| 31 | } |
| 32 | |
| 33 | // Error code returning from plugin interface not yet supported |
| 34 | TEST_P(olGetKernelTest, InvalidKernelName) { |
| 35 | ol_kernel_handle_t Kernel = nullptr; |
| 36 | ASSERT_ERROR(OL_ERRC_NOT_FOUND, |
| 37 | olGetKernel(Program, "invalid_kernel_name" , &Kernel)); |
| 38 | } |
| 39 | |