1 //===------- Offload API tests - olGetDevice -------------------------===// 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 olGetDeviceTest = offloadPlatformTest; 14 15 TEST_F(olGetDeviceTest, Success) { 16 uint32_t Count = 0; 17 ASSERT_SUCCESS(olGetDeviceCount(Platform, &Count)); 18 if (Count == 0) 19 GTEST_SKIP() << "No available devices on this platform."; 20 21 std::vector<ol_device_handle_t> Devices(Count); 22 ASSERT_SUCCESS(olGetDevice(Platform, Count, Devices.data())); 23 for (auto Device : Devices) { 24 ASSERT_NE(nullptr, Device); 25 } 26 } 27 28 TEST_F(olGetDeviceTest, SuccessSubsetOfDevices) { 29 uint32_t Count; 30 ASSERT_SUCCESS(olGetDeviceCount(Platform, &Count)); 31 if (Count < 2) 32 GTEST_SKIP() << "Only one device is available on this platform."; 33 34 std::vector<ol_device_handle_t> Devices(Count - 1); 35 ASSERT_SUCCESS(olGetDevice(Platform, Count - 1, Devices.data())); 36 for (auto Device : Devices) { 37 ASSERT_NE(nullptr, Device); 38 } 39 } 40