| 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/stringpathdatasourcestub.h" |
| 7 | #include "core/info/amd/gpuinfopm.h" |
| 8 | |
| 9 | namespace Tests::AMD::GPUInfoPM { |
| 10 | |
| 11 | TEST_CASE("GPUInfoPM tests", "[AMD][Info][GPUInfo][GPUInfoPM]") |
| 12 | { |
| 13 | Vendor vendor(Vendor::AMD); |
| 14 | int const gpuIndex = 0; |
| 15 | IGPUInfo::Path path("_sys_", "_dev_"); |
| 16 | std::vector<std::shared_ptr<IDataSource<std::string, std::filesystem::path const>>> |
| 17 | dataSources; |
| 18 | |
| 19 | SECTION("Provides Legacy capability") |
| 20 | { |
| 21 | dataSources.emplace_back(std::make_shared<StringPathDataSourceStub>( |
| 22 | "power_method", "dynpm", true)); |
| 23 | dataSources.emplace_back(std::make_shared<StringPathDataSourceStub>( |
| 24 | "power_method", "profile", true)); |
| 25 | ::AMD::GPUInfoPM ts(std::move(dataSources)); |
| 26 | |
| 27 | auto output = ts.provideCapabilities(vendor, gpuIndex, path); |
| 28 | REQUIRE(output.size() == 2); |
| 29 | REQUIRE(output.front() == ::AMD::GPUInfoPM::Legacy); |
| 30 | REQUIRE(output.back() == ::AMD::GPUInfoPM::Legacy); |
| 31 | } |
| 32 | |
| 33 | SECTION("Provides Radeon capability") |
| 34 | { |
| 35 | |
| 36 | dataSources.emplace_back(std::make_shared<StringPathDataSourceStub>( |
| 37 | "power_method", "dpm", true)); |
| 38 | ::AMD::GPUInfoPM ts(std::move(dataSources)); |
| 39 | |
| 40 | auto output = ts.provideCapabilities(vendor, gpuIndex, path); |
| 41 | REQUIRE(output.size() == 1); |
| 42 | REQUIRE(output.front() == ::AMD::GPUInfoPM::Radeon); |
| 43 | } |
| 44 | |
| 45 | SECTION("Provides Amdgpu capability") |
| 46 | { |
| 47 | |
| 48 | dataSources.emplace_back(std::make_shared<StringPathDataSourceStub>( |
| 49 | "power_dpm_force_performance_level", "some_value", true)); |
| 50 | ::AMD::GPUInfoPM ts(std::move(dataSources)); |
| 51 | |
| 52 | auto output = ts.provideCapabilities(vendor, gpuIndex, path); |
| 53 | REQUIRE(output.size() == 1); |
| 54 | REQUIRE(output.front() == ::AMD::GPUInfoPM::Amdgpu); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | } // namespace Tests::AMD::GPUInfoPM |