Debian Codegraph @

tests/src/test_amdodfanauto.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2023 Juan Palacios <[email protected]>
3
4 #include <catch2/catch_all.hpp>
5
6 #include "common/commandqueuestub.h"
7 #include "common/vectorstringdatasourcestub.h"
8 #include "core/components/controls/amd/fan/overdrive/auto/odfanauto.h"
9
10 namespace Tests::AMD::OdFanAuto {
11
12 class OdFanAutoTestAdapter : public ::AMD::OdFanAuto
13 {
14 public:
15 using ::AMD::OdFanAuto::OdFanAuto;
16
17 using ::AMD::OdFanAuto::cleanControl;
18 using ::AMD::OdFanAuto::syncControl;
19 };
20
21 TEST_CASE("AMD OdFanAuto tests", "[GPU][AMD][Fan][Overdrive][OdFanAuto]")
22 {
23 CommandQueueStub ctlCmds;
24 OdFanAutoTestAdapter ts(std::make_unique<VectorStringDataSourceStub>("path"));
25
26 SECTION("Has OdFanAuto ID")
27 {
28 REQUIRE(ts.ID() == ::AMD::OdFanAuto::ItemID);
29 }
30
31 SECTION("Is active by default")
32 {
33 REQUIRE(ts.active());
34 }
35
36 SECTION("Does not generate pre-init control commands")
37 {
38 ts.preInit(ctlCmds);
39
40 REQUIRE(ctlCmds.commands().empty());
41 }
42
43 SECTION("Does not generate post-init control commands")
44 {
45 ts.postInit(ctlCmds);
46
47 REQUIRE(ctlCmds.commands().empty());
48 }
49
50 SECTION("Does not generate clean control commands")
51 {
52 ts.cleanControl(ctlCmds);
53
54 REQUIRE(ctlCmds.commands().empty());
55 }
56
57 SECTION("Does generate sync control commands the first time is sync")
58 {
59 ts.syncControl(ctlCmds);
60
61 REQUIRE(ctlCmds.commands().size() == 2);
62 auto &[path0, value0] = ctlCmds.commands().at(0);
63 REQUIRE(path0 == "path");
64 REQUIRE(value0 == "r");
65 auto &[path1, value1] = ctlCmds.commands().at(1);
66 REQUIRE(path1 == "path");
67 REQUIRE(value1 == "c");
68 }
69
70 SECTION("Does not generate sync control commands when is already active")
71 {
72 ts.syncControl(ctlCmds);
73 ctlCmds.clear();
74
75 ts.syncControl(ctlCmds);
76
77 REQUIRE(ctlCmds.commands().empty());
78 }
79
80 SECTION("Does generate sync control commands when is reactivated")
81 {
82 ts.syncControl(ctlCmds);
83 ts.activate(false);
84 ts.clean(ctlCmds);
85 ts.activate(true);
86 ctlCmds.clear();
87
88 ts.syncControl(ctlCmds);
89
90 REQUIRE(ctlCmds.commands().size() == 2);
91 auto &[path0, value0] = ctlCmds.commands().at(0);
92 REQUIRE(path0 == "path");
93 REQUIRE(value0 == "r");
94 auto &[path1, value1] = ctlCmds.commands().at(1);
95 REQUIRE(path1 == "path");
96 REQUIRE(value1 == "c");
97 }
98 }
99
100 } // namespace Tests::AMD::OdFanAuto