|
| 1 | +//===------ test_sycl_event_interface.cpp - Test cases for event interface ===// |
| 2 | +// |
| 3 | +// Data Parallel Control (dpctl) |
| 4 | +// |
| 5 | +// Copyright 2020-2021 Intel Corporation |
| 6 | +// |
| 7 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +// you may not use this file except in compliance with the License. |
| 9 | +// You may obtain a copy of the License at |
| 10 | +// |
| 11 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +// |
| 13 | +// Unless required by applicable law or agreed to in writing, software |
| 14 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +// See the License for the specific language governing permissions and |
| 17 | +// limitations under the License. |
| 18 | +// |
| 19 | +//===----------------------------------------------------------------------===// |
| 20 | +/// |
| 21 | +/// \file |
| 22 | +/// This file has unit test cases for functions defined in |
| 23 | +/// dpctl_sycl_event_interface.h. |
| 24 | +/// |
| 25 | +//===----------------------------------------------------------------------===// |
| 26 | + |
| 27 | +#include "Support/CBindingWrapping.h" |
| 28 | +#include "dpctl_sycl_event_interface.h" |
| 29 | +#include <CL/sycl.hpp> |
| 30 | +#include <gtest/gtest.h> |
| 31 | + |
| 32 | +using namespace cl::sycl; |
| 33 | + |
| 34 | +namespace |
| 35 | +{ |
| 36 | +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(event, DPCTLSyclEventRef) |
| 37 | +} // namespace |
| 38 | + |
| 39 | +struct TestDPCTLSyclEventInterface : public ::testing::Test |
| 40 | +{ |
| 41 | + DPCTLSyclEventRef ERef = nullptr; |
| 42 | + |
| 43 | + TestDPCTLSyclEventInterface() |
| 44 | + { |
| 45 | + EXPECT_NO_FATAL_FAILURE(ERef = DPCTLEvent_Create()); |
| 46 | + } |
| 47 | + |
| 48 | + void SetUp() |
| 49 | + { |
| 50 | + ASSERT_TRUE(ERef); |
| 51 | + } |
| 52 | + |
| 53 | + ~TestDPCTLSyclEventInterface() |
| 54 | + { |
| 55 | + EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Delete(ERef)); |
| 56 | + } |
| 57 | +}; |
| 58 | + |
| 59 | +TEST_F(TestDPCTLSyclEventInterface, CheckEvent_Copy) |
| 60 | +{ |
| 61 | + DPCTLSyclEventRef Copied_ERef = nullptr; |
| 62 | + EXPECT_NO_FATAL_FAILURE(Copied_ERef = DPCTLEvent_Copy(ERef)); |
| 63 | + EXPECT_TRUE(bool(Copied_ERef)); |
| 64 | + EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Copied_ERef)); |
| 65 | +} |
| 66 | + |
| 67 | +TEST_F(TestDPCTLSyclEventInterface, CheckCopy_Invalid) |
| 68 | +{ |
| 69 | + DPCTLSyclEventRef E1 = nullptr; |
| 70 | + DPCTLSyclEventRef E2 = nullptr; |
| 71 | + EXPECT_NO_FATAL_FAILURE(E2 = DPCTLEvent_Copy(E1)); |
| 72 | + EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Delete(E1)); |
| 73 | + EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Delete(E2)); |
| 74 | +} |
0 commit comments