Debian Codegraph @

tests/src/test_amdpmautolegacy.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include <catch2/catch_all.hpp>
5
6 #include "common/commandqueuestub.h"
7 #include "common/stringdatasourcestub.h"
8 #include "core/components/controls/amd/pm/auto/pmautolegacy.h"
9
10 namespace Tests::AMD::PMAutoLegacy {
11
12 class PMAutoLegacyTestAdapter : public ::AMD::PMAutoLegacy
13 {
14 public:
15 using ::AMD::PMAutoLegacy::PMAutoLegacy;
16
17 using ::AMD::PMAutoLegacy::cleanControl;
18 using ::AMD::PMAutoLegacy::syncControl;
19 };
20
21 TEST_CASE("AMD PMAutoLegacy tests", "[GPU][AMD][PM][PMAuto][Legacy]")
22 {
23 std::string const powerMethodPath{"power_method"};
24 std::string const powerProfilePath{"power_profile"};
25 CommandQueueStub ctlCmds;
26
27 SECTION("Does not generate clean control commands")
28 {
29 PMAutoLegacyTestAdapter ts(std::make_unique<StringDataSourceStub>(),
30 std::make_unique<StringDataSourceStub>());
31 ts.cleanControl(ctlCmds);
32
33 REQUIRE(ctlCmds.commands().empty());
34 }
35
36 SECTION("Does not generate sync control commands when is synced")
37 {
38 PMAutoLegacyTestAdapter ts(
39 std::make_unique<StringDataSourceStub>(powerMethodPath, "profile"),
40 std::make_unique<StringDataSourceStub>(powerProfilePath, "auto"));
41 ts.syncControl(ctlCmds);
42
43 REQUIRE(ctlCmds.commands().empty());
44 }
45
46 SECTION("Does generate sync control commands when...")
47 {
48 SECTION("power_method is out of sync")
49 {
50 PMAutoLegacyTestAdapter ts(
51 std::make_unique<StringDataSourceStub>(powerMethodPath, "_other_"),
52 std::make_unique<StringDataSourceStub>(powerProfilePath, "auto"));
53 ts.syncControl(ctlCmds);
54
55 REQUIRE(ctlCmds.commands().size() == 2);
56
57 auto &[cmd0Path, cmd0Value] = ctlCmds.commands().front();
58 REQUIRE(cmd0Path == powerMethodPath);
59 REQUIRE(cmd0Value == "profile");
60
61 auto &[cmd1Path, cmd1Value] = ctlCmds.commands().back();
62 REQUIRE(cmd1Path == powerProfilePath);
63 REQUIRE(cmd1Value == "auto");
64 }
65
66 SECTION("power_profile is out of sync")
67 {
68 PMAutoLegacyTestAdapter ts(
69 std::make_unique<StringDataSourceStub>(powerMethodPath, "profile"),
70 std::make_unique<StringDataSourceStub>(powerProfilePath, "_other_"));
71 ts.syncControl(ctlCmds);
72
73 REQUIRE(ctlCmds.commands().size() == 2);
74
75 auto &[cmd0Path, cmd0Value] = ctlCmds.commands().front();
76 REQUIRE(cmd0Path == powerMethodPath);
77 REQUIRE(cmd0Value == "profile");
78
79 auto &[cmd1Path, cmd1Value] = ctlCmds.commands().back();
80 REQUIRE(cmd1Path == powerProfilePath);
81 REQUIRE(cmd1Value == "auto");
82 }
83 }
84 }
85
86 } // namespace Tests::AMD::PMAutoLegacy