Debian Codegraph @

tests/src/test_amdppdpmhandler.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/tests/src/test_amdppdpmhandler.cpp`/
2 // Copyright 2019 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 "common/vectorstringdatasourcestub.h"cxx . . $ `<file>/tests/src/common/vectorstringdatasourcestub.h`/
9 #include "core/components/controls/amd/pm/handlers/ppdpmhandler.h"cxx . . $ `<file>/src/core/components/controls/amd/pm/handlers/ppdpmhandler.h`/
10
11 namespace Testscxx . . $ Tests/::AMDcxx . . $ Tests/AMD/::PpDpmHandlercxx . . $ Tests/AMD/PpDpmHandler/ {
12
13 TEST_CASEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:144:11`!("AMD PpDpmHandler tests",
14 "[GPU][AMD][PM][DataSourceHandler][PpDpmHandler]")
15 {
16 CommandQueueStubcxx . . $ CommandQueueStub# ctlCmds;
17
18 stdcxx . . $ std/::vectorcxx . . $ std/vector#<unsigned int> defaultActiveStatescxx . . $ std/vector#vector(9619226211e5a241).{0, 1};
19 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> ppDpmDatacxx . . $ std/vector#vector(9619226211e5a241).{"0: 300Mhz *", "1: 2000Mhz"};
20
21 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Initializes states from data source on construction")
22 {
23 ::AMDcxx . . $ AMD/::PpDpmHandlercxx . . $ AMD/PpDpmHandler# tscxx . . $ AMD/PpDpmHandler#PpDpmHandler(bd8974f6c315ae39).(
24 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(
25 "power_dpm_force_performance_level", "manual"),
26 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<VectorStringDataSourceStubcxx . . $ VectorStringDataSourceStub#>("pp_dpm_sclk", ppDpmData));
27
28 auto states = tscxx . . $ std/vector#vector(a1201200cf0efa42)..statescxx . . $ AMD/PpDpmHandler#states(c0b4149a89fc03d1).();
29 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(states.size() == 2);
30 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(states.front() ==
31 std::make_pair(0u, units::frequency::megahertz_t(300)));
32 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(states.back() ==
33 std::make_pair(1u, units::frequency::megahertz_t(2000)));
34
35 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has all states active by default")
36 {
37 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.active() == defaultActiveStates);
38 }
39
40 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Activate...")
41 {
42 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Works with known states")
43 {
44 ts.activatecxx . . $ AMD/PpDpmHandler#activate(43b01311a8536f06).({cxx . . $ std/vector#vector(9619226211e5a241).1});
45 auto &activeStates = ts.activecxx . . $ AMD/PpDpmHandler#active(e55ca9a8cd0b22bf).();
46 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(activeStates.size() == 1);
47 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(activeStates.front() == 1);
48 }
49
50 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Ignores unknown states")
51 {
52 ts.activatecxx . . $ AMD/PpDpmHandler#activate(43b01311a8536f06).({cxx . . $ std/vector#vector(9619226211e5a241).2, 3});
53 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.active() == defaultActiveStates);
54 }
55
56 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Cannot deactivate all states")
57 {
58 ts.activatecxx . . $ AMD/PpDpmHandler#activate(43b01311a8536f06).({cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).});
59 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.active() == defaultActiveStates);
60 }
61 }
62 }
63
64 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Saving and restoring data source state are not supported")
65 {
66 ::AMDcxx . . $ AMD/::PpDpmHandlercxx . . $ AMD/PpDpmHandler# tscxx . . $ AMD/PpDpmHandler#PpDpmHandler(bd8974f6c315ae39).(
67 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(
68 "power_dpm_force_performance_level", "manual"),
69 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<VectorStringDataSourceStubcxx . . $ VectorStringDataSourceStub#>("pp_dpm_sclk", ppDpmData));
70
71 ts.saveStatecxx . . $ AMD/PpDpmHandler#saveState(49f6e7a06ebc5aa8).();
72 ts.restoreStatecxx . . $ AMD/PpDpmHandler#restoreState(151e9138769f295e).(ctlCmds);
73 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().empty());
74 }
75
76 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Generates reset control commands unconditionally...")
77 {
78 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Including performance level command when its value is not manual")
79 {
80 ::AMDcxx . . $ AMD/::PpDpmHandlercxx . . $ AMD/PpDpmHandler# tscxx . . $ AMD/PpDpmHandler#PpDpmHandler(bd8974f6c315ae39).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(
81 "power_dpm_force_performance_level", "auto"),
82 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<VectorStringDataSourceStubcxx . . $ VectorStringDataSourceStub#>(
83 "pp_dpm_sclk", ppDpmData));
84
85 ts.resetcxx . . $ AMD/PpDpmHandler#reset(151e9138769f295e).(ctlCmds);
86
87 auto &commands = ctlCmds.commandscxx . . $ CommandQueueStub#commands(f070559094366392).();
88 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands.size() == 2);
89 auto &[cmd0Path, cmd0Value] = commands.atcxx . . $ std/vector#at(b61e45a10b63f40a).(0);
90 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Path == "power_dpm_force_performance_level");
91 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Value == "manual");
92 auto &[cmd1Path, cmd1Value] = commands.atcxx . . $ std/vector#at(b61e45a10b63f40a).(1);
93 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd1Path == "pp_dpm_sclk");
94 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd1Value == "0 1");
95 }
96
97 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Excluding performance level command when its value is not manual")
98 {
99 ::AMDcxx . . $ AMD/::PpDpmHandlercxx . . $ AMD/PpDpmHandler# tscxx . . $ AMD/PpDpmHandler#PpDpmHandler(bd8974f6c315ae39).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(
100 "power_dpm_force_performance_level", "manual"),
101 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<VectorStringDataSourceStubcxx . . $ VectorStringDataSourceStub#>(
102 "pp_dpm_sclk", ppDpmData));
103
104 ts.resetcxx . . $ AMD/PpDpmHandler#reset(151e9138769f295e).(ctlCmds);
105
106 auto &commands = ctlCmds.commandscxx . . $ CommandQueueStub#commands(f070559094366392).();
107 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands.size() == 1);
108 auto &[cmd0Path, cmd0Value] = commands.atcxx . . $ std/vector#at(b61e45a10b63f40a).(0);
109 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Path == "pp_dpm_sclk");
110 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Value == "0 1");
111 }
112 }
113
114 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Does not generate sync control commands when is synced")
115 {
116 ::AMDcxx . . $ AMD/::PpDpmHandlercxx . . $ AMD/PpDpmHandler# tscxx . . $ AMD/PpDpmHandler#PpDpmHandler(bd8974f6c315ae39).(
117 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(
118 "power_dpm_force_performance_level", "manual"),
119 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<VectorStringDataSourceStubcxx . . $ VectorStringDataSourceStub#>("pp_dpm_sclk", ppDpmData));
120
121 // skip initial sync commands
122 ts.synccxx . . $ AMD/PpDpmHandler#sync(151e9138769f295e).(ctlCmds);
123 ctlCmds.clearcxx . . $ CommandQueueStub#clear(49f6e7a06ebc5aa8).();
124
125 ts.synccxx . . $ AMD/PpDpmHandler#sync(151e9138769f295e).(ctlCmds);
126
127 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().empty());
128 }
129
130 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Generates sync control commands when...")
131 {
132 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Performance level is not manual")
133 {
134 ::AMDcxx . . $ AMD/::PpDpmHandlercxx . . $ AMD/PpDpmHandler# tscxx . . $ AMD/PpDpmHandler#PpDpmHandler(bd8974f6c315ae39).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(
135 "power_dpm_force_performance_level", "auto"),
136 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<VectorStringDataSourceStubcxx . . $ VectorStringDataSourceStub#>(
137 "pp_dpm_sclk", ppDpmData));
138
139 ts.synccxx . . $ AMD/PpDpmHandler#sync(151e9138769f295e).(ctlCmds);
140
141 auto &commands = ctlCmds.commandscxx . . $ CommandQueueStub#commands(f070559094366392).();
142 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands.size() == 2);
143 auto &[cmd0Path, cmd0Value] = commands.atcxx . . $ std/vector#at(b61e45a10b63f40a).(0);
144 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Path == "power_dpm_force_performance_level");
145 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Value == "manual");
146 auto &[cmd1Path, cmd1Value] = commands.atcxx . . $ std/vector#at(b61e45a10b63f40a).(1);
147 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd1Path == "pp_dpm_sclk");
148 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd1Value == "0 1");
149 }
150
151 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Active states were changed")
152 {
153 ::AMDcxx . . $ AMD/::PpDpmHandlercxx . . $ AMD/PpDpmHandler# tscxx . . $ AMD/PpDpmHandler#PpDpmHandler(bd8974f6c315ae39).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(
154 "power_dpm_force_performance_level", "manual"),
155 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<VectorStringDataSourceStubcxx . . $ VectorStringDataSourceStub#>(
156 "pp_dpm_sclk", ppDpmData));
157
158 ts.activatecxx . . $ AMD/PpDpmHandler#activate(43b01311a8536f06).({cxx . . $ std/vector#vector(9619226211e5a241).0});
159 ts.synccxx . . $ AMD/PpDpmHandler#sync(151e9138769f295e).(ctlCmds);
160
161 auto &commands = ctlCmds.commandscxx . . $ CommandQueueStub#commands(f070559094366392).();
162 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands.size() == 1);
163 auto &[cmd0Path, cmd0Value] = commands.atcxx . . $ std/vector#at(b61e45a10b63f40a).(0);
164 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Path == "pp_dpm_sclk");
165 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Value == "0");
166 }
167
168 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Current index is not an active index")
169 {
170 ::AMDcxx . . $ AMD/::PpDpmHandlercxx . . $ AMD/PpDpmHandler# tscxx . . $ AMD/PpDpmHandler#PpDpmHandler(bd8974f6c315ae39).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(
171 "power_dpm_force_performance_level", "manual"),
172 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<VectorStringDataSourceStubcxx . . $ VectorStringDataSourceStub#>(
173 "pp_dpm_sclk", ppDpmData));
174
175 ts.activatecxx . . $ AMD/PpDpmHandler#activate(43b01311a8536f06).({cxx . . $ std/vector#vector(9619226211e5a241).1});
176 ts.synccxx . . $ AMD/PpDpmHandler#sync(151e9138769f295e).(ctlCmds);
177 ctlCmds.clearcxx . . $ CommandQueueStub#clear(49f6e7a06ebc5aa8).();
178
179 ts.synccxx . . $ AMD/PpDpmHandler#sync(151e9138769f295e).(ctlCmds);
180
181 auto &commands = ctlCmds.commandscxx . . $ CommandQueueStub#commands(f070559094366392).();
182 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(commands.size() == 1);
183 auto &[cmd0Path, cmd0Value] = commands.atcxx . . $ std/vector#at(b61e45a10b63f40a).(0);
184 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Path == "pp_dpm_sclk");
185 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(cmd0Value == "1");
186 }
187 }
188 }
189
190 } // namespace Tests::AMD::PpDpmHandler