| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/tests/src/test_cpuinfo.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include <catch2/catch_all.hpp> |
| 5 | |
| 6 | #include "core/info/cpuinfo.h"cxx . . $ `<file>/src/core/info/cpuinfo.h`/ |
| 7 | |
| 8 | namespace Testscxx . . $ Tests/::CPUInfocxx . . $ Tests/CPUInfo/ { |
| 9 | |
| 10 | class ProviderStubcxx . . $ Tests/CPUInfo/ProviderStub# : public ICPUInfocxx . . $ ICPUInfo#::IProvidercxx . . $ ICPUInfo#IProvider# |
| 11 | { |
| 12 | public: |
| 13 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> |
| 14 | provideInfocxx . . $ Tests/CPUInfo/ProviderStub#provideInfo(ba0be1eb8c175b81).(int, stdcxx . . $ std/::vectorcxx . . $ std/vector#<ICPUInfocxx . . $ ICPUInfo#::ExecutionUnitcxx . . $ ICPUInfo#ExecutionUnit#> const &) override |
| 15 | { |
| 16 | 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).; |
| 17 | info.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).("info_key", "info"); |
| 18 | return infocxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 19 | } |
| 20 | |
| 21 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> |
| 22 | provideCapabilitiescxx . . $ Tests/CPUInfo/ProviderStub#provideCapabilities(61866227792b2a60).(int, stdcxx . . $ std/::vectorcxx . . $ std/vector#<ICPUInfocxx . . $ ICPUInfo#::ExecutionUnitcxx . . $ ICPUInfo#ExecutionUnit#> const &) override |
| 23 | { |
| 24 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> capcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 25 | cap.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).("capability"); |
| 26 | return capcxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | TEST_CASEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:144:11`!("CPUInfo tests", "[Info][CPUInfo]") |
| 31 | { |
| 32 | int physicalId{0}; |
| 33 | ::CPUInfocxx . . $ CPUInfo# tscxx . . $ CPUInfo#CPUInfo(cf59e0143b35dd9e).(physicalId, {cxx . . $ std/vector#vector(9619226211e5a241).{0, 0, "/proc/cpu0"}}); |
| 34 | |
| 35 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has CPU physical id") |
| 36 | { |
| 37 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.physicalId() == physicalId); |
| 38 | } |
| 39 | |
| 40 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has execution units") |
| 41 | { |
| 42 | REQUIRE_FALSEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:128:11`!(ts.executionUnits().empty()); |
| 43 | |
| 44 | auto &unit = ts.executionUnitscxx . . $ CPUInfo#executionUnits(d06c1a4c98578052).().frontcxx . . $ std/vector#front(af0004c3ce7cab93).(); |
| 45 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(unit.cpuId == 0); |
| 46 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(unit.coreId == 0); |
| 47 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(unit.sysPath == "/proc/cpu0"); |
| 48 | } |
| 49 | |
| 50 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("CPU info and capabilities are collected on initialization") |
| 51 | { |
| 52 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.keys().empty()); |
| 53 | |
| 54 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ICPUInfocxx . . $ ICPUInfo#::IProvidercxx . . $ ICPUInfo#IProvider#>> providerscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 55 | providers.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ProviderStubcxx . . $ Tests/CPUInfo/ProviderStub#>()); |
| 56 | |
| 57 | ts.initializecxx . . $ CPUInfo#initialize(9f043417cf7016f2).(providers); |
| 58 | auto keys = ts.keyscxx . . $ CPUInfo#keys(491c255a7e496038).(); |
| 59 | |
| 60 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(keys.size() == 1); |
| 61 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(keys.front() == "info_key"); |
| 62 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.info("info_key") == "info"); |
| 63 | |
| 64 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.hasCapability("capability")); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | } // namespace Tests::CPUInfo |