| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/tests/src/test_gpuinfo.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include <catch2/catch_all.hpp> |
| 5 | |
| 6 | #include "core/info/gpuinfo.h"cxx . . $ `<file>/src/core/info/gpuinfo.h`/ |
| 7 | #include "core/info/ihwidtranslator.h"cxx . . $ `<file>/src/core/info/ihwidtranslator.h`/ |
| 8 | |
| 9 | namespace Testscxx . . $ Tests/::GPUInfocxx . . $ Tests/GPUInfo/ { |
| 10 | |
| 11 | class ProviderStubcxx . . $ Tests/GPUInfo/ProviderStub# : public IGPUInfocxx . . $ IGPUInfo#::IProvidercxx . . $ IGPUInfo#IProvider# |
| 12 | { |
| 13 | public: |
| 14 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> |
| 15 | provideInfocxx . . $ Tests/GPUInfo/ProviderStub#provideInfo(5b65f7e996e13d80).(Vendorcxx . . $ Vendor#, int, IGPUInfocxx . . $ IGPUInfo#::Pathcxx . . $ IGPUInfo#Path# const &, |
| 16 | IHWIDTranslatorcxx . . $ IHWIDTranslator# const &) const override |
| 17 | { |
| 18 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> infocxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 19 | info.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).("info_key", "info"); |
| 20 | return infocxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 21 | } |
| 22 | |
| 23 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> |
| 24 | provideCapabilitiescxx . . $ Tests/GPUInfo/ProviderStub#provideCapabilities(da28437f5803dad2).(Vendorcxx . . $ Vendor#, int, IGPUInfocxx . . $ IGPUInfo#::Pathcxx . . $ IGPUInfo#Path# const &) const override |
| 25 | { |
| 26 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> capcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 27 | cap.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).("capability"); |
| 28 | return capcxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | class HWIDTranslatorStubcxx . . $ Tests/GPUInfo/HWIDTranslatorStub# : public IHWIDTranslatorcxx . . $ IHWIDTranslator# |
| 33 | { |
| 34 | public: |
| 35 | stdcxx . . $ std/::stringcxx . . $ std/string# vendorcxx . . $ Tests/GPUInfo/HWIDTranslatorStub#vendor(ed3976f106e8bf8e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &) const override |
| 36 | { |
| 37 | return ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 38 | } |
| 39 | |
| 40 | stdcxx . . $ std/::stringcxx . . $ std/string# devicecxx . . $ Tests/GPUInfo/HWIDTranslatorStub#device(ee8c6c2661a93592).(stdcxx . . $ std/::stringcxx . . $ std/string# const &, stdcxx . . $ std/::stringcxx . . $ std/string# const &) const override |
| 41 | { |
| 42 | return ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 43 | } |
| 44 | |
| 45 | stdcxx . . $ std/::stringcxx . . $ std/string# subdevicecxx . . $ Tests/GPUInfo/HWIDTranslatorStub#subdevice(f1e1f68436fc7a45).(stdcxx . . $ std/::stringcxx . . $ std/string# const &, stdcxx . . $ std/::stringcxx . . $ std/string# const &, |
| 46 | stdcxx . . $ std/::stringcxx . . $ std/string# const &, stdcxx . . $ std/::stringcxx . . $ std/string# const &) const override |
| 47 | { |
| 48 | return ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | TEST_CASEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:144:11`!("GPUInfo tests", "[Info][GPUInfo]") |
| 53 | { |
| 54 | int gpuIndex{123}; |
| 55 | ::GPUInfocxx . . $ GPUInfo# tscxx . . $ GPUInfo#GPUInfo(88a5808916d38e5d).(Vendorcxx . . $ Vendor#::AMDcxx . . $ Vendor#AMD., gpuIndex, IGPUInfocxx . . $ IGPUInfo#Path#Path(df8cb93b336b884d).::Pathcxx . . $ IGPUInfo#Path#("_sys_"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "_dev_"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)); |
| 56 | |
| 57 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has vendor") |
| 58 | { |
| 59 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.vendor() == Vendor::AMD); |
| 60 | } |
| 61 | |
| 62 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has GPU index") |
| 63 | { |
| 64 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.index() == gpuIndex); |
| 65 | } |
| 66 | |
| 67 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has device paths") |
| 68 | { |
| 69 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.path().sys == "_sys_"); |
| 70 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.path().dev == "_dev_"); |
| 71 | } |
| 72 | |
| 73 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("GPU info and capabilities are collected on initialization") |
| 74 | { |
| 75 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.keys().empty()); |
| 76 | |
| 77 | HWIDTranslatorStubcxx . . $ Tests/GPUInfo/HWIDTranslatorStub# hwidTranStub; |
| 78 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IGPUInfocxx . . $ IGPUInfo#::IProvidercxx . . $ IGPUInfo#IProvider#>> providerscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 79 | providers.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ProviderStubcxx . . $ Tests/GPUInfo/ProviderStub#>()); |
| 80 | |
| 81 | ts.initializecxx . . $ GPUInfo#initialize(c158fff4aa1693ae).(providers, hwidTranStub); |
| 82 | auto keys = ts.keyscxx . . $ GPUInfo#keys(491c255a7e496038).(); |
| 83 | |
| 84 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(keys.size() == 1); |
| 85 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(keys.front() == "info_key"); |
| 86 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.info("info_key") == "info"); |
| 87 | |
| 88 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.hasCapability("capability")); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | } // namespace Tests::GPUInfo |