| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/tests/src/test_cpuepphandler.cpp`/ |
| 2 | // Copyright 2024 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include <catch2/catch_all.hpp> |
| 5 | |
| 6 | #include "common/commandqueuestub.h"cxx . . $ `<file>/tests/src/common/commandqueuestub.h`/ |
| 7 | #include "common/stringdatasourcestub.h"cxx . . $ `<file>/tests/src/common/stringdatasourcestub.h`/ |
| 8 | #include "core/components/controls/cpu/handlers/epphandler.h"cxx . . $ `<file>/src/core/components/controls/cpu/handlers/epphandler.h`/ |
| 9 | |
| 10 | namespace Testscxx . . $ Tests/::CPUcxx . . $ Tests/CPU/::EPPHandlercxx . . $ Tests/CPU/EPPHandler/ { |
| 11 | |
| 12 | TEST_CASEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:144:11`!("AMD PpDpmHandler tests", "[CPU][DataSourceHandler][EPPHandler]") |
| 13 | { |
| 14 | CommandQueueStubcxx . . $ CommandQueueStub# ctlCmds; |
| 15 | |
| 16 | stdcxx . . $ std/::stringcxx . . $ std/string# defaultHintcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).{"default"}; |
| 17 | |
| 18 | auto availableEPPHintsDataSource = stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>( |
| 19 | "energy_performance_available_preferences", "default power"); |
| 20 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IDataSourcecxx . . $ IDataSource#<stdcxx . . $ std/::stringcxx . . $ std/string#>>> eppHintDataSourcecxx . . $ std/vector#vector(49f6e7a06ebc5aa8).{}; |
| 21 | eppHintDataSource.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>( |
| 22 | "energy_performance_preference", "default")); |
| 23 | |
| 24 | ::EPPHandlercxx . . $ EPPHandler# tscxx . . $ EPPHandler#EPPHandler(57813437e0a511f6).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::movecxx . . $ std/move(e35c19a1ba7baa26).(availableEPPHintsDataSource), |
| 25 | stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(eppHintDataSource)); |
| 26 | ts.initcxx . . $ EPPHandler#init(49f6e7a06ebc5aa8).(); |
| 27 | |
| 28 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Initialize the available EPP hints from its data source") |
| 29 | { |
| 30 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> eppHints = {cxx . . $ std/vector#vector(9619226211e5a241)."default", "power"}; |
| 31 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(ts.hints(), Catch::Matchers::Equals(eppHints)); |
| 32 | } |
| 33 | |
| 34 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has 'default' as the active hint by default when available") |
| 35 | { |
| 36 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.hint() == defaultHint); |
| 37 | } |
| 38 | |
| 39 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Setting a hint...") |
| 40 | { |
| 41 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Works with known hints") |
| 42 | { |
| 43 | ts.hintcxx . . $ EPPHandler#hint(9c546c94e5fcce4e).("power"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 44 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.hint() == "power"); |
| 45 | } |
| 46 | |
| 47 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Ignores unknown hints") |
| 48 | { |
| 49 | ts.hintcxx . . $ EPPHandler#hint(9c546c94e5fcce4e).("unknown"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 50 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.hint() == defaultHint); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Does not save and restore CPU data source state") |
| 55 | { |
| 56 | ts.saveStatecxx . . $ EPPHandler#saveState(49f6e7a06ebc5aa8).(); |
| 57 | ts.restoreStatecxx . . $ EPPHandler#restoreState(151e9138769f295e).(ctlCmds); |
| 58 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().empty()); |
| 59 | } |
| 60 | |
| 61 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Does not generate reset control commands") |
| 62 | { |
| 63 | ts.resetcxx . . $ EPPHandler#reset(151e9138769f295e).(ctlCmds); |
| 64 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().empty()); |
| 65 | } |
| 66 | |
| 67 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Does not generate sync control commands when is synced") |
| 68 | { |
| 69 | ts.synccxx . . $ EPPHandler#sync(151e9138769f295e).(ctlCmds); |
| 70 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().empty()); |
| 71 | } |
| 72 | |
| 73 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Generates sync control commands when CPU hint is out of sync") |
| 74 | { |
| 75 | ts.hintcxx . . $ EPPHandler#hint(9c546c94e5fcce4e).("power"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 76 | ts.synccxx . . $ EPPHandler#sync(151e9138769f295e).(ctlCmds); |
| 77 | |
| 78 | auto &commands = ctlCmds.commandscxx . . $ CommandQueueStub#commands(f070559094366392).(); |
| 79 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands.size() == 1); |
| 80 | auto &[cmdPath, cmdValue] = commands.atcxx . . $ std/vector#at(b61e45a10b63f40a).(0); |
| 81 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmdPath == "energy_performance_preference"); |
| 82 | REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmdValue == "power"); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | } // namespace Tests::CPU::EPPHandler |