| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/tests/src/test_gpuinfouevent.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include <catch2/catch_all.hpp> |
| 5 | #include <catch2/trompeloeil.hpp> |
| 6 | |
| 7 | #include "core/idatasource.h"cxx . . $ `<file>/src/core/idatasource.h`/ |
| 8 | #include "core/info/common/gpuinfouevent.h"cxx . . $ `<file>/src/core/info/common/gpuinfouevent.h`/ |
| 9 | #include "core/info/ihwidtranslator.h"cxx . . $ `<file>/src/core/info/ihwidtranslator.h`/ |
| 10 | |
| 11 | extern template struct trompeloeil::reportercxx . . $ trompeloeil/reporter#<trompeloeilcxx . . $ trompeloeil/::specializedcxx . . $ trompeloeil/specialized#>; |
| 12 | |
| 13 | using trompeloeilcxx . . $ trompeloeil/::_cxx . . $ _.; |
| 14 | |
| 15 | namespace Testscxx . . $ Tests/::GPUInfoUeventcxx . . $ Tests/GPUInfoUevent/ { |
| 16 | |
| 17 | class GPUInfoUeventDataSourceStubcxx . . $ Tests/GPUInfoUevent/GPUInfoUeventDataSourceStub# |
| 18 | : public IDataSourcecxx . . $ IDataSource#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>, stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const> |
| 19 | { |
| 20 | public: |
| 21 | stdcxx . . $ std/::stringcxx . . $ std/string# sourcecxx . . $ Tests/GPUInfoUevent/GPUInfoUeventDataSourceStub#source(219584694fe2b248).() const override |
| 22 | { |
| 23 | return "uevent"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 24 | } |
| 25 | |
| 26 | bool readcxx . . $ Tests/GPUInfoUevent/GPUInfoUeventDataSourceStub#read(b14c1b4ec0a23c2b).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> &data, stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const &) override |
| 27 | { |
| 28 | data.clearcxx . . $ std/vector#clear(ced63f7c635d850d).(); |
| 29 | data.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).("DRIVER=driver"); |
| 30 | data.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).("PCI_ID=1111:2222"); |
| 31 | data.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).("PCI_SUBSYS_ID=3333:4444"); |
| 32 | data.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).("PCI_SLOT_NAME=0000:01:00.0"); |
| 33 | return true; |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | class HWIDTranslatorMockcxx . . $ Tests/GPUInfoUevent/HWIDTranslatorMock# : public IHWIDTranslatorcxx . . $ IHWIDTranslator# |
| 38 | { |
| 39 | public: |
| 40 | MAKE_CONST_MOCK1cxx . . $ `<external>/1068432606165018960/mock.hpp:4241:9`!(vendor, std::string(std::string const &)); |
| 41 | MAKE_CONST_MOCK2cxx . . $ `<external>/1068432606165018960/mock.hpp:4242:9`!(device, std::string(std::string const &, std::string const &)); |
| 42 | MAKE_CONST_MOCK4cxx . . $ `<external>/1068432606165018960/mock.hpp:4244:9`!(subdevice, |
| 43 | std::string(std::string const &, std::string const &, |
| 44 | std::string const &, std::string const &)); |
| 45 | }; |
| 46 | |
| 47 | TEST_CASEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:144:11`!("GPUInfoUevent tests", "[Info][GPUInfo][GPUInfoUevent]") |
| 48 | { |
| 49 | stdcxx . . $ std/::stringcxx . . $ std/string# vNamecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).("v_name"); |
| 50 | stdcxx . . $ std/::stringcxx . . $ std/string# dNamecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).("d_name"); |
| 51 | stdcxx . . $ std/::stringcxx . . $ std/string# sdNamecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).("s_name"); |
| 52 | |
| 53 | Vendorcxx . . $ Vendor# vendor(Vendorcxx . . $ Vendor#::AMDcxx . . $ Vendor#AMD.); |
| 54 | int const gpuIndex = 0; |
| 55 | IGPUInfocxx . . $ IGPUInfo#::Pathcxx . . $ IGPUInfo#Path# pathcxx . . $ IGPUInfo#Path#Path(df8cb93b336b884d).("_sys_"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "_dev_"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).); |
| 56 | HWIDTranslatorMockcxx . . $ Tests/GPUInfoUevent/HWIDTranslatorMock# hwIDTranslator; |
| 57 | ALLOW_CALLcxx . . $ `<external>/1068432606165018960/mock.hpp:4337:9`!(hwIDTranslator, vendor(_)).LR_RETURNcxx . . $ `<external>/1068432606165018960/mock.hpp:4349:9`!(vName); |
| 58 | ALLOW_CALLcxx . . $ `<external>/1068432606165018960/mock.hpp:4337:9`!(hwIDTranslator, device(_, _)).LR_RETURNcxx . . $ `<external>/1068432606165018960/mock.hpp:4349:9`!(dName); |
| 59 | ALLOW_CALLcxx . . $ `<external>/1068432606165018960/mock.hpp:4337:9`!(hwIDTranslator, subdevice(_, _, _, _)).LR_RETURNcxx . . $ `<external>/1068432606165018960/mock.hpp:4349:9`!(sdName); |
| 60 | |
| 61 | ::GPUInfoUeventcxx . . $ GPUInfoUevent# tscxx . . $ GPUInfoUevent#GPUInfoUevent(50458470b84e8b0c).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<GPUInfoUeventDataSourceStubcxx . . $ Tests/GPUInfoUevent/GPUInfoUeventDataSourceStub#>()); |
| 62 | |
| 63 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Provides driver") |
| 64 | { |
| 65 | auto output = ts.provideInfocxx . . $ GPUInfoUevent#provideInfo(5b65f7e996e13d80).(vendor, gpuIndex, path, hwIDTranslator); |
| 66 | auto driver = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(stdcxx . . $ std/::stringcxx . . $ std/string#(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::drivercxx . . $ IGPUInfo#Keys#driver.), |
| 67 | stdcxx . . $ std/::stringcxx . . $ std/string#("driver")); |
| 68 | |
| 69 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(output, Catch::Matchers::VectorContains(driver)); |
| 70 | } |
| 71 | |
| 72 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Provides PCI slot") |
| 73 | { |
| 74 | auto output = ts.provideInfocxx . . $ GPUInfoUevent#provideInfo(5b65f7e996e13d80).(vendor, gpuIndex, path, hwIDTranslator); |
| 75 | auto driver = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(stdcxx . . $ std/::stringcxx . . $ std/string#(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::pciSlotcxx . . $ IGPUInfo#Keys#pciSlot.), |
| 76 | stdcxx . . $ std/::stringcxx . . $ std/string#("0000:01:00.0")); |
| 77 | |
| 78 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(output, Catch::Matchers::VectorContains(driver)); |
| 79 | } |
| 80 | |
| 81 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Provides vendor id") |
| 82 | { |
| 83 | auto output = ts.provideInfocxx . . $ GPUInfoUevent#provideInfo(5b65f7e996e13d80).(vendor, gpuIndex, path, hwIDTranslator); |
| 84 | auto vendorID = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(stdcxx . . $ std/::stringcxx . . $ std/string#(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::vendorIDcxx . . $ IGPUInfo#Keys#vendorID.), |
| 85 | stdcxx . . $ std/::stringcxx . . $ std/string#("1111")); |
| 86 | |
| 87 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(output, Catch::Matchers::VectorContains(vendorID)); |
| 88 | } |
| 89 | |
| 90 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Provides vendor name") |
| 91 | { |
| 92 | REQUIRE_CALLcxx . . $ `<external>/1068432606165018960/mock.hpp:4335:9`!(hwIDTranslator, vendor("1111")).LR_RETURNcxx . . $ `<external>/1068432606165018960/mock.hpp:4349:9`!(vName); |
| 93 | auto output = ts.provideInfocxx . . $ GPUInfoUevent#provideInfo(5b65f7e996e13d80).(vendor, gpuIndex, path, hwIDTranslator); |
| 94 | auto vendorName = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(stdcxx . . $ std/::stringcxx . . $ std/string#(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::vendorNamecxx . . $ IGPUInfo#Keys#vendorName.), |
| 95 | vName); |
| 96 | |
| 97 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(output, Catch::Matchers::VectorContains(vendorName)); |
| 98 | } |
| 99 | |
| 100 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Provides device id") |
| 101 | { |
| 102 | auto output = ts.provideInfocxx . . $ GPUInfoUevent#provideInfo(5b65f7e996e13d80).(vendor, gpuIndex, path, hwIDTranslator); |
| 103 | auto deviceID = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(stdcxx . . $ std/::stringcxx . . $ std/string#(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::deviceIDcxx . . $ IGPUInfo#Keys#deviceID.), |
| 104 | stdcxx . . $ std/::stringcxx . . $ std/string#("2222")); |
| 105 | |
| 106 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(output, Catch::Matchers::VectorContains(deviceID)); |
| 107 | } |
| 108 | |
| 109 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Provides device name") |
| 110 | { |
| 111 | REQUIRE_CALLcxx . . $ `<external>/1068432606165018960/mock.hpp:4335:9`!(hwIDTranslator, device("1111", "2222")).LR_RETURNcxx . . $ `<external>/1068432606165018960/mock.hpp:4349:9`!(dName); |
| 112 | |
| 113 | auto output = ts.provideInfocxx . . $ GPUInfoUevent#provideInfo(5b65f7e996e13d80).(vendor, gpuIndex, path, hwIDTranslator); |
| 114 | auto deviceName = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(stdcxx . . $ std/::stringcxx . . $ std/string#(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::deviceNamecxx . . $ IGPUInfo#Keys#deviceName.), |
| 115 | dName); |
| 116 | |
| 117 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(output, Catch::Matchers::VectorContains(deviceName)); |
| 118 | } |
| 119 | |
| 120 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Provides subvendor id") |
| 121 | { |
| 122 | auto output = ts.provideInfocxx . . $ GPUInfoUevent#provideInfo(5b65f7e996e13d80).(vendor, gpuIndex, path, hwIDTranslator); |
| 123 | auto subvendorID = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(stdcxx . . $ std/::stringcxx . . $ std/string#(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::subvendorIDcxx . . $ IGPUInfo#Keys#subvendorID.), |
| 124 | stdcxx . . $ std/::stringcxx . . $ std/string#("3333")); |
| 125 | |
| 126 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(output, Catch::Matchers::VectorContains(subvendorID)); |
| 127 | } |
| 128 | |
| 129 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Provides subdevice id") |
| 130 | { |
| 131 | auto output = ts.provideInfocxx . . $ GPUInfoUevent#provideInfo(5b65f7e996e13d80).(vendor, gpuIndex, path, hwIDTranslator); |
| 132 | auto subdeviceID = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(stdcxx . . $ std/::stringcxx . . $ std/string#(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::subdeviceIDcxx . . $ IGPUInfo#Keys#subdeviceID.), |
| 133 | stdcxx . . $ std/::stringcxx . . $ std/string#("4444")); |
| 134 | |
| 135 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(output, Catch::Matchers::VectorContains(subdeviceID)); |
| 136 | } |
| 137 | |
| 138 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Provides subdevice name") |
| 139 | { |
| 140 | REQUIRE_CALLcxx . . $ `<external>/1068432606165018960/mock.hpp:4335:9`!(hwIDTranslator, subdevice("1111", "2222", "3333", "4444")) |
| 141 | .LR_RETURNcxx . . $ `<external>/1068432606165018960/mock.hpp:4349:9`!(sdName); |
| 142 | |
| 143 | auto output = ts.provideInfocxx . . $ GPUInfoUevent#provideInfo(5b65f7e996e13d80).(vendor, gpuIndex, path, hwIDTranslator); |
| 144 | auto subdeviceName = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).( |
| 145 | stdcxx . . $ std/::stringcxx . . $ std/string#(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::subdeviceNamecxx . . $ IGPUInfo#Keys#subdeviceName.), sdName); |
| 146 | |
| 147 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(output, Catch::Matchers::VectorContains(subdeviceName)); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | } // namespace Tests::GPUInfoUevent |