Skip to content

Commit 10293ea

Browse files
committed
Add test
1 parent baf070f commit 10293ea

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

offload/unittests/OffloadAPI/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ add_offload_unittest("event"
1212
event/olDestroyEvent.cpp
1313
event/olWaitEvent.cpp)
1414

15+
add_offload_unittest("init"
16+
init/olInit.cpp)
17+
target_compile_definitions("init.unittests" PRIVATE DISABLE_WRAPPER)
18+
1519
add_offload_unittest("kernel"
1620
kernel/olGetKernel.cpp
1721
kernel/olLaunchKernel.cpp)

offload/unittests/OffloadAPI/common/Environment.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ using namespace llvm;
1717

1818
// Wrapper so we don't have to constantly init and shutdown Offload in every
1919
// test, while having sensible lifetime for the platform environment
20+
#ifndef DISABLE_WRAPPER
2021
struct OffloadInitWrapper {
2122
OffloadInitWrapper() { olInit(); }
2223
~OffloadInitWrapper() { olShutDown(); }
2324
};
2425
static OffloadInitWrapper Wrapper{};
26+
#endif
2527

2628
static cl::opt<std::string>
2729
SelectedPlatform("platform", cl::desc("Only test the specified platform"),
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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, Uninitialized) {
19+
ASSERT_ERROR(OL_ERRC_UNINITIALIZED,
20+
olIterateDevices(
21+
[](ol_device_handle_t, void *) { return false; }, nullptr));
22+
}

0 commit comments

Comments
 (0)