| 1 | //===------- Offload API tests - olMemFree --------------------------------===// |
| 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 olMemFreeTest = OffloadDeviceTest; |
| 14 | OFFLOAD_TESTS_INSTANTIATE_DEVICE_FIXTURE(olMemFreeTest); |
| 15 | |
| 16 | TEST_P(olMemFreeTest, SuccessFreeManaged) { |
| 17 | void *Alloc = nullptr; |
| 18 | ASSERT_SUCCESS(olMemAlloc(Device, OL_ALLOC_TYPE_MANAGED, 1024, &Alloc)); |
| 19 | ASSERT_SUCCESS(olMemFree(Alloc)); |
| 20 | } |
| 21 | |
| 22 | TEST_P(olMemFreeTest, SuccessFreeHost) { |
| 23 | void *Alloc = nullptr; |
| 24 | ASSERT_SUCCESS(olMemAlloc(Device, OL_ALLOC_TYPE_HOST, 1024, &Alloc)); |
| 25 | ASSERT_SUCCESS(olMemFree(Alloc)); |
| 26 | } |
| 27 | |
| 28 | TEST_P(olMemFreeTest, SuccessFreeDevice) { |
| 29 | void *Alloc = nullptr; |
| 30 | ASSERT_SUCCESS(olMemAlloc(Device, OL_ALLOC_TYPE_DEVICE, 1024, &Alloc)); |
| 31 | ASSERT_SUCCESS(olMemFree(Alloc)); |
| 32 | } |
| 33 | |
| 34 | TEST_P(olMemFreeTest, InvalidNullPtr) { |
| 35 | void *Alloc = nullptr; |
| 36 | ASSERT_SUCCESS(olMemAlloc(Device, OL_ALLOC_TYPE_DEVICE, 1024, &Alloc)); |
| 37 | ASSERT_ERROR(OL_ERRC_INVALID_NULL_POINTER, olMemFree(nullptr)); |
| 38 | ASSERT_SUCCESS(olMemFree(Alloc)); |
| 39 | } |
| 40 | |