Debian Codegraph @

tests/src/test_amdpmfixedr600.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/fixed/pmfixedr600.h"
9
10 namespace Tests::AMD::PMFixedR600 {
11
12 class PMFixedR600TestAdapter : public ::AMD::PMFixedR600
13 {
14 public:
15 using ::AMD::PMFixedR600::PMFixedR600;
16
17 using ::AMD::PMFixedR600::cleanControl;
18 using ::AMD::PMFixedR600::mode;
19 using ::AMD::PMFixedR600::modes;
20 using ::AMD::PMFixedR600::syncControl;
21 };
22
23 TEST_CASE("AMD PMFixedR600 tests", "[GPU][AMD][PM][PMFixed][R600]")
24 {
25 std::string const perfLevelPath{"power_dpm_force_performance_level"};
26 CommandQueueStub ctlCmds;
27
28 SECTION("Has 'low' mode selected by default")
29 {
30 PMFixedR600TestAdapter ts(std::make_unique<StringDataSourceStub>());
31
32 REQUIRE(ts.mode() == "low");
33 }
34
35 SECTION("Has [low, high] modes")
36 {
37 std::vector<std::string> const perfLevels{"low", "high"};
38 PMFixedR600TestAdapter ts(std::make_unique<StringDataSourceStub>());
39
40 REQUIRE(ts.modes() == perfLevels);
41 }
42
43 SECTION("Does generate clean control commands")
44 {
45 PMFixedR600TestAdapter ts(
46 std::make_unique<StringDataSourceStub>(perfLevelPath, "low"));
47 ts.cleanControl(ctlCmds);
48
49 REQUIRE(ctlCmds.commands().size() == 1);
50
51 auto &[path, value] = ctlCmds.commands().front();
52 REQUIRE(path == perfLevelPath);
53 REQUIRE(value == "auto");
54 }
55
56 SECTION("Does not generate sync control commands when is synced")
57 {
58 PMFixedR600TestAdapter ts(
59 std::make_unique<StringDataSourceStub>(perfLevelPath, "low"));
60 ts.syncControl(ctlCmds);
61
62 REQUIRE(ctlCmds.commands().empty());
63 }
64
65 SECTION("Does generate sync control commands when is out of sync")
66 {
67 PMFixedR600TestAdapter ts(
68 std::make_unique<StringDataSourceStub>(perfLevelPath, "_other_"));
69 ts.syncControl(ctlCmds);
70
71 REQUIRE(ctlCmds.commands().size() == 1);
72
73 auto &[path, value] = ctlCmds.commands().front();
74 REQUIRE(path == perfLevelPath);
75 REQUIRE(value == "low");
76 }
77 }
78
79 } // namespace Tests::AMD::PMFixedR600