| 1 |
//===------- Offload API tests - olInit -----------------------------------===// |
| 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 |
// NOTE: For this test suite, the implicit olInit/olShutDown doesn't happen, so |
| 10 |
// tests have to do it themselves |
| 11 |
|
| 12 |
#include "../common/Fixtures.hpp" |
| 13 |
#include <OffloadAPI.h> |
| 14 |
#include <gtest/gtest.h> |
| 15 |
|
| 16 |
struct olInitTest : ::testing::Test {}; |
| 17 |
|
| 18 |
TEST_F(olInitTest, Success) { |
| 19 |
ASSERT_SUCCESS(olInit()); |
| 20 |
ASSERT_SUCCESS(olShutDown()); |
| 21 |
} |
| 22 |
|
| 23 |
TEST_F(olInitTest, Uninitialized) { |
| 24 |
ASSERT_ERROR(OL_ERRC_UNINITIALIZED, |
| 25 |
olIterateDevices( |
| 26 |
[](ol_device_handle_t, void *) { return false; }, nullptr)); |
| 27 |
} |
| 28 |
|
| 29 |
TEST_F(olInitTest, RepeatedInit) { |
| 30 |
for (size_t I = 0; I < 10; I++) { |
| 31 |
ASSERT_SUCCESS(olInit()); |
| 32 |
ASSERT_SUCCESS(olShutDown()); |
| 33 |
} |
| 34 |
} |