1 //===------- Offload API tests - olGetPlatform -----------------------===// 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 olGetPlatformTest = offloadTest; 14 15 TEST_F(olGetPlatformTest, Success) { 16 uint32_t PlatformCount; 17 ASSERT_SUCCESS(olGetPlatformCount(&PlatformCount)); 18 std::vector<ol_platform_handle_t> Platforms(PlatformCount); 19 ASSERT_SUCCESS(olGetPlatform(PlatformCount, Platforms.data())); 20 } 21 22 TEST_F(olGetPlatformTest, InvalidNumEntries) { 23 uint32_t PlatformCount; 24 ASSERT_SUCCESS(olGetPlatformCount(&PlatformCount)); 25 std::vector<ol_platform_handle_t> Platforms(PlatformCount); 26 ASSERT_ERROR(OL_ERRC_INVALID_SIZE, 27 olGetPlatform(PlatformCount + 1, Platforms.data())); 28 } 29