| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include <catch2/catch_all.hpp> |
| 5 | |
| 6 | #include "common/hwidtranslatorstub.h" |
| 7 | #include "common/stringdatasourcestub.h" |
| 8 | #include "core/info/common/gpuinfovulkan.h" |
| 9 | |
| 10 | namespace Tests::GPUInfoVulkan { |
| 11 | |
| 12 | TEST_CASE("GPUInfoVulkan tests", "[Info][GPUInfo][GPUInfoVulkan]") |
| 13 | { |
| 14 | Vendor vendor(Vendor::AMD); |
| 15 | int const gpuIndex = 0; |
| 16 | IGPUInfo::Path path("_sys_", "_dev_"); |
| 17 | HWIDTranslatorStub hwIDTranslator; |
| 18 | |
| 19 | SECTION("Provides api version (v1)") |
| 20 | { |
| 21 | std::string const infoData( |
| 22 | // clang-format off |
| 23 | "...\n\ |
| 24 | VkPhysicalDeviceProperties:\n\ |
| 25 | ...\n\ |
| 26 | apiVersion = 4194306\n\ |
| 27 | ..."); // clang-format on |
| 28 | |
| 29 | ::GPUInfoVulkan ts( |
| 30 | std::make_unique<StringDataSourceStub>("vulkaninfo", infoData)); |
| 31 | |
| 32 | auto output = ts.provideInfo(vendor, gpuIndex, path, hwIDTranslator); |
| 33 | |
| 34 | auto apiVersion = std::make_pair( |
| 35 | std::string(::GPUInfoVulkan::Keys::apiVersion), std::string("4194306")); |
| 36 | REQUIRE_THAT(output, Catch::Matchers::VectorContains(apiVersion)); |
| 37 | } |
| 38 | |
| 39 | SECTION("Provides api version (v2)") |
| 40 | { |
| 41 | std::string const infoData( |
| 42 | // clang-format off |
| 43 | "...\n\ |
| 44 | VkPhysicalDeviceProperties:\n\ |
| 45 | ...\n\ |
| 46 | apiVersion = 0x401046 (1.1.70)\n\ |
| 47 | ..."); // clang-format on |
| 48 | |
| 49 | ::GPUInfoVulkan ts( |
| 50 | std::make_unique<StringDataSourceStub>("vulkaninfo", infoData)); |
| 51 | |
| 52 | auto output = ts.provideInfo(vendor, gpuIndex, path, hwIDTranslator); |
| 53 | |
| 54 | auto apiVersion = std::make_pair( |
| 55 | std::string(::GPUInfoVulkan::Keys::apiVersion), std::string("1.1.70")); |
| 56 | REQUIRE_THAT(output, Catch::Matchers::VectorContains(apiVersion)); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | } // namespace Tests::GPUInfoVulkan |