Debian Codegraph @

tests/src/test_amdpmpowerstate.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/tests/src/test_amdpmpowerstate.cpp`/
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include <catch2/catch_all.hpp>
5 #include <catch2/trompeloeil.hpp>
6
7 #include "common/commandqueuestub.h"cxx . . $ `<file>/tests/src/common/commandqueuestub.h`/
8 #include "common/stringdatasourcestub.h"cxx . . $ `<file>/tests/src/common/stringdatasourcestub.h`/
9 #include "core/components/controls/amd/pm/powerstate/pmpowerstate.h"cxx . . $ `<file>/src/core/components/controls/amd/pm/powerstate/pmpowerstate.h`/
10
11 extern template struct trompeloeil::reportercxx . . $ trompeloeil/reporter#<trompeloeilcxx . . $ trompeloeil/::specializedcxx . . $ trompeloeil/specialized#>;
12
13 namespace Testscxx . . $ Tests/::AMDcxx . . $ Tests/AMD/::PMPowerStatecxx . . $ Tests/AMD/PMPowerState/ {
14
15 class PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# : public ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#
16 {
17 public:
18 using ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#::PMPowerStatecxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter#PMPowerStateTestAdapter(ce24b1149b52833b).;
19
20 using ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#::cleanControlcxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter#cleanControl(151e9138769f295e).;
21 using ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#::exportControlcxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter#exportControl(40299682ab9c8676).;
22 using ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#::importControlcxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter#importControl(4f796e3ecd5dcd94).;
23 using ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#::modecxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter#mode(9c546c94e5fcce4e).;
24 using ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#::modescxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter#modes(f5f2959be38ccc08).;
25 using ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#::syncControlcxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter#syncControl(151e9138769f295e).;
26 };
27
28 class PMPowerStateImporterStubcxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub# : public ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#::Importercxx . . $ AMD/PMPowerState#Importer#
29 {
30 public:
31 PMPowerStateImporterStubcxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub#PMPowerStateImporterStub(c8024318075daf50).(stdcxx . . $ std/::string_viewcxx . . $ std/string_view# mode)
32 : mode_cxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub#mode_.(mode)
33 {
34 }
35
36 stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Importablecxx . . $ Importable#::Importercxx . . $ Importable#Importer#>>
37 provideImportercxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub#provideImporter(c13a3bcac0db4745).(Itemcxx . . $ Item# const &) override
38 {
39 return {cxx . . $ std/optional#optional(ced63f7c635d850d).};
40 }
41
42 bool provideActivecxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub#provideActive(50ce9a9e25b4a850).() const override
43 {
44 return false;
45 }
46
47 stdcxx . . $ std/::stringcxx . . $ std/string# const &providePMPowerStateModecxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub#providePMPowerStateMode(f4fff0029955a25f).() const override
48 {
49 return mode_cxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub#mode_.;
50 }
51
52 private:
53 stdcxx . . $ std/::stringcxx . . $ std/string# mode_cxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub#mode_.;
54 };
55
56 class PMPowerStateExporterMockcxx . . $ Tests/AMD/PMPowerState/PMPowerStateExporterMock# : public ::AMDcxx . . $ AMD/::PMPowerStatecxx . . $ AMD/PMPowerState#::Exportercxx . . $ AMD/PMPowerState#Exporter#
57 {
58 public:
59 MAKE_MOCK1cxx . . $ `<external>/1068432606165018960/mock.hpp:4223:9`!(takePMPowerStateMode, void(std::string const &), override);
60 MAKE_MOCK1cxx . . $ `<external>/1068432606165018960/mock.hpp:4223:9`!(takePMPowerStateModes, void(std::vector<std::string> const &),
61 override);
62 MAKE_MOCK1cxx . . $ `<external>/1068432606165018960/mock.hpp:4223:9`!(takeActive, void(bool), override);
63 MAKE_MOCK1cxx . . $ `<external>/1068432606165018960/mock.hpp:4223:9`!(
64 provideExporter,
65 std::optional<std::reference_wrapper<Exportable::Exporter>>(Item const &),
66 override);
67 };
68
69 TEST_CASEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:144:11`!("AMD PMPowerState tests", "[GPU][AMD][PM][PMPowerState]")
70 {
71 stdcxx . . $ std/::stringcxx . . $ std/string# const powerDpmStatePathcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).{"power_dpm_state"};
72 CommandQueueStubcxx . . $ CommandQueueStub# ctlCmds;
73
74 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has PMPowerState ID")
75 {
76 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
77
78 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.ID() == ::AMD::PMPowerState::ItemID);
79 }
80
81 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Is active by default")
82 {
83 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
84
85 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.active());
86 }
87
88 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has 'balanced' mode selected by default")
89 {
90 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
91
92 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.mode() == "balanced");
93 }
94
95 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Has [battery, balanced, performance] modes")
96 {
97 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> const modescxx . . $ std/vector#vector(9619226211e5a241).{stdcxx . . $ std/::stringcxx . . $ std/string#("battery"),
98 stdcxx . . $ std/::stringcxx . . $ std/string#("balanced"),
99 stdcxx . . $ std/::stringcxx . . $ std/string#("performance")};
100 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
101
102 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.modes() == modes);
103 }
104
105 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("mode only sets known modes")
106 {
107 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
108
109 ts.modecxx . . $ AMD/PMPowerState#mode(9c546c94e5fcce4e).("performance"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
110 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.mode() == "performance");
111
112 ts.modecxx . . $ AMD/PMPowerState#mode(9c546c94e5fcce4e).("unkown"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
113 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.mode() == "performance");
114 }
115
116 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Does not generate pre-init control commands")
117 {
118 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
119
120 ts.preInitcxx . . $ AMD/PMPowerState#preInit(151e9138769f295e).(ctlCmds);
121
122 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().empty());
123 }
124
125 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Does not generate post-init control commands")
126 {
127 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
128
129 ts.postInitcxx . . $ AMD/PMPowerState#postInit(151e9138769f295e).(ctlCmds);
130
131 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().empty());
132 }
133
134 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Imports its mode")
135 {
136 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
137 PMPowerStateImporterStubcxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub# icxx . . $ Tests/AMD/PMPowerState/PMPowerStateImporterStub#PMPowerStateImporterStub(c8024318075daf50).("performance"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).);
138 ts.importControlcxx . . $ AMD/PMPowerState#importControl(4f796e3ecd5dcd94).(i);
139
140 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ts.mode() == "performance");
141 }
142
143 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Export its mode and available modes")
144 {
145 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
146 PMPowerStateExporterMockcxx . . $ Tests/AMD/PMPowerState/PMPowerStateExporterMock# e;
147
148 trompeloeilcxx . . $ trompeloeil/::sequencecxx . . $ trompeloeil/sequence# seq;
149 REQUIRE_CALLcxx . . $ `<external>/1068432606165018960/mock.hpp:4335:9`!(e, takePMPowerStateModes(trompeloeil::_)).IN_SEQUENCEcxx . . $ `<external>/3750106516996543135/sequence.hpp:394:9`!(seq);
150 REQUIRE_CALLcxx . . $ `<external>/1068432606165018960/mock.hpp:4335:9`!(e, takePMPowerStateMode(trompeloeil::eq("balanced")))
151 .IN_SEQUENCEcxx . . $ `<external>/3750106516996543135/sequence.hpp:394:9`!(seq);
152
153 ts.exportControlcxx . . $ AMD/PMPowerState#exportControl(40299682ab9c8676).(e);
154 }
155
156 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Does not generate clean control commands")
157 {
158 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>());
159 ts.cleanControlcxx . . $ AMD/PMPowerState#cleanControl(151e9138769f295e).(ctlCmds);
160
161 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().empty());
162 }
163
164 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Does not generate sync control commands when is synced")
165 {
166 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(
167 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(powerDpmStatePath, "balanced"));
168 ts.syncControlcxx . . $ AMD/PMPowerState#syncControl(151e9138769f295e).(ctlCmds);
169
170 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().empty());
171 }
172
173 SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("Does generate sync control commands when is out of sync")
174 {
175 PMPowerStateTestAdaptercxx . . $ Tests/AMD/PMPowerState/PMPowerStateTestAdapter# ts(
176 stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<StringDataSourceStubcxx . . $ StringDataSourceStub#>(powerDpmStatePath, "_other_"));
177 ts.syncControlcxx . . $ AMD/PMPowerState#syncControl(151e9138769f295e).(ctlCmds);
178
179 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(ctlCmds.commands().size() == 1);
180
181 auto &[path, value] = ctlCmds.commandscxx . . $ CommandQueueStub#commands(f070559094366392).().frontcxx . . $ std/vector#front(af0004c3ce7cab93).();
182 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(path == powerDpmStatePath);
183 REQUIREcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:127:11`!(value == "balanced");
184 }
185 }
186
187 } // namespace Tests::AMD::PMPowerState