Debian Codegraph @

tests/src/test_amdfancurve.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 #include <catch2/trompeloeil.hpp>
6
7 #include "common/commandqueuestub.h"
8 #include "common/uintdatasourcestub.h"
9 #include "core/components/controls/amd/fan/curve/fancurve.h"
10
11 extern template struct trompeloeil::reporter<trompeloeil::specialized>;
12
13 namespace Tests::AMD::FanCurve {
14
15 class FanCurveTestAdapter : public ::AMD::FanCurve
16 {
17 public:
18 using ::AMD::FanCurve::FanCurve;
19
20 using ::AMD::FanCurve::cleanControl;
21 using ::AMD::FanCurve::curve;
22 using ::AMD::FanCurve::evaluatePwm;
23 using ::AMD::FanCurve::evaluateTemp;
24 using ::AMD::FanCurve::exportControl;
25 using ::AMD::FanCurve::fanStartValue;
26 using ::AMD::FanCurve::fanStop;
27 using ::AMD::FanCurve::hysteresis;
28 using ::AMD::FanCurve::importControl;
29 using ::AMD::FanCurve::lerpFromPwm;
30 using ::AMD::FanCurve::lerpFromTemp;
31 using ::AMD::FanCurve::syncControl;
32 };
33
34 class FanCurveImporterStub : public ::AMD::FanCurve::Importer
35 {
36 public:
37 FanCurveImporterStub(std::vector<::AMD::FanCurve::Point> const &curve)
38 : curve_(curve)
39 , fanStartValue_(0)
40 , fanStop_(false)
41 {
42 }
43
44 std::optional<std::reference_wrapper<Importable::Importer>>
45 provideImporter(Item const &) override
46 {
47 return *this;
48 }
49
50 bool provideActive() const override
51 {
52 return false;
53 }
54
55 std::vector<::AMD::FanCurve::Point> const &provideFanCurvePoints() const override
56 {
57 return curve_;
58 }
59
60 bool provideFanCurveFanStop() const override
61 {
62 return fanStop_;
63 }
64
65 units::concentration::percent_t provideFanCurveFanStartValue() const override
66 {
67 return fanStartValue_;
68 }
69
70 void fanStop(bool enabled)
71 {
72 fanStop_ = enabled;
73 }
74
75 void fanStartValue(units::concentration::percent_t value)
76 {
77 fanStartValue_ = value;
78 }
79
80 private:
81 std::vector<::AMD::FanCurve::Point> const curve_;
82 units::concentration::percent_t fanStartValue_;
83 bool fanStop_;
84 };
85
86 class FanCurveExporterMock : public ::AMD::FanCurve::Exporter
87 {
88 public:
89 MAKE_MOCK1(takeFanCurvePoints,
90 void(std::vector<::AMD::FanCurve::Point> const &), override);
91 MAKE_MOCK1(takeFanCurveFanStop, void(bool), override);
92 MAKE_MOCK1(takeFanCurveFanStartValue, void(units::concentration::percent_t),
93 override);
94 MAKE_MOCK2(takeFanCurveTemperatureRange,
95 void(units::temperature::celsius_t, units::temperature::celsius_t),
96 override);
97 MAKE_MOCK1(takeActive, void(bool), override);
98 MAKE_MOCK1(
99 provideExporter,
100 std::optional<std::reference_wrapper<Exportable::Exporter>>(Item const &),
101 override);
102 };
103
104 class IntDataSourceStub : public IDataSource<int>
105 {
106 public:
107 IntDataSourceStub(std::string_view source = "", int data = 0,
108 bool success = true) noexcept
109 : source_(source)
110 , data_(data)
111 , success_(success)
112 {
113 }
114
115 std::string source() const override
116 {
117 return source_;
118 }
119
120 bool read(int &data) override
121 {
122 data = data_;
123 return success_;
124 }
125
126 void data(int data)
127 {
128 data_ = data;
129 }
130
131 std::string const source_;
132 int data_;
133 bool success_;
134 };
135
136 TEST_CASE("AMD FanCurve tests", "[GPU][AMD][Fan][FanCurve]")
137 {
138 CommandQueueStub ctlCmds;
139
140 SECTION("Pwm curve evaluation")
141 {
142 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
143 std::make_unique<UIntDataSourceStub>(),
144 std::make_unique<IntDataSourceStub>(),
145 units::temperature::celsius_t(0),
146 units::temperature::celsius_t(100));
147
148 auto p1 = std::make_pair(units::temperature::celsius_t(0),
149 units::concentration::percent_t(0));
150 auto p2 = std::make_pair(units::temperature::celsius_t(100),
151 units::concentration::percent_t(100));
152
153 REQUIRE(ts.lerpFromPwm(units::concentration::percent_t(50), p1, p2) == 50);
154
155 // out of line input
156 REQUIRE(ts.lerpFromPwm(units::concentration::percent_t(-50), p1, p2) == 0);
157 REQUIRE(ts.lerpFromPwm(units::concentration::percent_t(150), p1, p2) == 100);
158
159 std::vector<std::pair<units::temperature::celsius_t, units::concentration::percent_t>>
160 curve;
161 curve.push_back(p1);
162 curve.push_back(p2);
163 ts.curve(curve);
164
165 REQUIRE(ts.evaluatePwm(units::concentration::percent_t(50)) == 50);
166
167 // out of curve pwm
168 REQUIRE(ts.evaluatePwm(units::concentration::percent_t(-50)) == 0);
169 REQUIRE(ts.evaluatePwm(units::concentration::percent_t(150)) == 100);
170 }
171
172 SECTION("Temperature curve evaluation")
173 {
174 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
175 std::make_unique<UIntDataSourceStub>(),
176 std::make_unique<IntDataSourceStub>(),
177 units::temperature::celsius_t(0),
178 units::temperature::celsius_t(100));
179
180 auto p1 = std::make_pair(units::temperature::celsius_t(0),
181 units::concentration::percent_t(0));
182 auto p2 = std::make_pair(units::temperature::celsius_t(100),
183 units::concentration::percent_t(100));
184
185 REQUIRE(ts.lerpFromTemp(units::temperature::celsius_t(50), p1, p2) == 128);
186
187 // out of line input
188 REQUIRE(ts.lerpFromTemp(units::temperature::celsius_t(-50), p1, p2) == 0);
189 REQUIRE(ts.lerpFromTemp(units::temperature::celsius_t(150), p1, p2) == 255);
190
191 std::vector<std::pair<units::temperature::celsius_t, units::concentration::percent_t>>
192 curve;
193 curve.push_back(p1);
194 curve.push_back(p2);
195 ts.curve(curve);
196
197 REQUIRE(ts.evaluateTemp(units::temperature::celsius_t(50)) == 128);
198
199 // out of curve temperatures
200 REQUIRE(ts.evaluateTemp(units::temperature::celsius_t(-50)) == 0);
201 REQUIRE(ts.evaluateTemp(units::temperature::celsius_t(150)) == 255);
202 }
203
204 SECTION("Has FanCurve ID")
205 {
206 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
207 std::make_unique<UIntDataSourceStub>(),
208 std::make_unique<IntDataSourceStub>(),
209 units::temperature::celsius_t(0),
210 units::temperature::celsius_t(100));
211
212 REQUIRE(ts.ID() == ::AMD::FanCurve::ItemID);
213 }
214
215 SECTION("Is not active by default")
216 {
217 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
218 std::make_unique<UIntDataSourceStub>(),
219 std::make_unique<IntDataSourceStub>(),
220 units::temperature::celsius_t(0),
221 units::temperature::celsius_t(100));
222
223 REQUIRE_FALSE(ts.active());
224 }
225
226 SECTION("Has a default curve")
227 {
228 auto tempRange = std::make_pair(units::temperature::celsius_t(0),
229 units::temperature::celsius_t(50));
230
231 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
232 std::make_unique<UIntDataSourceStub>(),
233 std::make_unique<IntDataSourceStub>(),
234 tempRange.first, tempRange.second);
235
236 REQUIRE(ts.curve().size() > 2);
237
238 SECTION("Default curve points are normalized into temperature range")
239 {
240 REQUIRE_FALSE(std::any_of(ts.curve().cbegin(), ts.curve().cend(),
241 [&](auto const &point) {
242 return point.first < tempRange.first ||
243 point.first > tempRange.second;
244 }));
245 }
246 }
247
248 SECTION("Computed pwm1 value is clampled in [0, 255] range")
249 {
250 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
251 std::make_unique<UIntDataSourceStub>(),
252 std::make_unique<IntDataSourceStub>(),
253 units::temperature::celsius_t(0),
254 units::temperature::celsius_t(100));
255
256 auto p1 = std::make_pair(units::temperature::celsius_t(0),
257 units::concentration::percent_t(0));
258 auto p2 = std::make_pair(units::temperature::celsius_t(100),
259 units::concentration::percent_t(100));
260
261 REQUIRE(ts.lerpFromTemp(units::temperature::celsius_t(-50), p1, p2) == 0);
262 REQUIRE(ts.lerpFromTemp(units::temperature::celsius_t(50), p1, p2) == 128);
263 REQUIRE(ts.lerpFromTemp(units::temperature::celsius_t(150), p1, p2) == 255);
264 }
265
266 SECTION("Has fan stop disabled by default")
267 {
268 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
269 std::make_unique<UIntDataSourceStub>(),
270 std::make_unique<IntDataSourceStub>(),
271 units::temperature::celsius_t(0),
272 units::temperature::celsius_t(100));
273
274 REQUIRE_FALSE(ts.fanStop());
275 }
276
277 SECTION("Has hysteresis > 0")
278 {
279 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
280 std::make_unique<UIntDataSourceStub>(),
281 std::make_unique<IntDataSourceStub>(),
282 units::temperature::celsius_t(0),
283 units::temperature::celsius_t(100));
284
285 REQUIRE(ts.hysteresis() > 0);
286 }
287
288 SECTION("Has fan start value == 54 (21%) by default")
289 {
290 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
291 std::make_unique<UIntDataSourceStub>(),
292 std::make_unique<IntDataSourceStub>(),
293 units::temperature::celsius_t(0),
294 units::temperature::celsius_t(100));
295
296 REQUIRE(ts.fanStartValue() == 54);
297 }
298
299 SECTION("Clamp its fan start value in [0, 255] range")
300 {
301 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
302 std::make_unique<UIntDataSourceStub>(),
303 std::make_unique<IntDataSourceStub>(),
304 units::temperature::celsius_t(0),
305 units::temperature::celsius_t(100));
306
307 ts.fanStartValue(300);
308 REQUIRE(ts.fanStartValue() == 255);
309 }
310
311 SECTION("Does not generate pre-init control commands")
312 {
313 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
314 std::make_unique<UIntDataSourceStub>(),
315 std::make_unique<IntDataSourceStub>(),
316 units::temperature::celsius_t(0),
317 units::temperature::celsius_t(100));
318 ts.preInit(ctlCmds);
319
320 REQUIRE(ctlCmds.commands().empty());
321 }
322
323 SECTION("Does not generate post-init control commands")
324 {
325 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
326 std::make_unique<UIntDataSourceStub>(),
327 std::make_unique<IntDataSourceStub>(),
328 units::temperature::celsius_t(0),
329 units::temperature::celsius_t(100));
330 ts.postInit(ctlCmds);
331
332 REQUIRE(ctlCmds.commands().empty());
333 }
334
335 SECTION("Imports its state")
336 {
337 auto p1 = std::make_pair(units::temperature::celsius_t(0),
338 units::concentration::percent_t(0));
339 auto p2 = std::make_pair(units::temperature::celsius_t(200), // out of range
340 units::concentration::percent_t(200)); // out of range
341 std::vector<std::pair<units::temperature::celsius_t, units::concentration::percent_t>>
342 curve;
343 curve.push_back(p1);
344 curve.push_back(p2);
345
346 FanCurveImporterStub i(curve);
347 i.fanStartValue(50);
348 i.fanStop(true);
349
350 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
351 std::make_unique<UIntDataSourceStub>(),
352 std::make_unique<IntDataSourceStub>(),
353 units::temperature::celsius_t(0),
354 units::temperature::celsius_t(100));
355
356 ts.importControl(i);
357
358 auto normalizedCurve = curve;
359 auto &lastPoint = normalizedCurve.back();
360 lastPoint.first = units::temperature::celsius_t(100);
361 lastPoint.second = units::concentration::percent_t(100);
362
363 REQUIRE_FALSE(ts.curve().empty());
364 REQUIRE(ts.curve() == normalizedCurve);
365 REQUIRE(ts.fanStartValue() == 128);
366 REQUIRE(ts.fanStop());
367 }
368
369 SECTION("Export its state")
370 {
371 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
372 std::make_unique<UIntDataSourceStub>(),
373 std::make_unique<IntDataSourceStub>(),
374 units::temperature::celsius_t(0),
375 units::temperature::celsius_t(100));
376 auto p1 = std::make_pair(units::temperature::celsius_t(0),
377 units::concentration::percent_t(0));
378 auto p2 = std::make_pair(units::temperature::celsius_t(100),
379 units::concentration::percent_t(100));
380 std::vector<std::pair<units::temperature::celsius_t, units::concentration::percent_t>>
381 curve;
382 curve.push_back(p1);
383 curve.push_back(p2);
384 ts.curve(curve);
385 ts.fanStop(true);
386 ts.fanStartValue(128);
387
388 trompeloeil::sequence seq;
389 FanCurveExporterMock e;
390 REQUIRE_CALL(e, takeFanCurveTemperatureRange(trompeloeil::_, trompeloeil::_))
391 .WITH(_1 == units::temperature::celsius_t(0))
392 .WITH(_2 == units::temperature::celsius_t(100))
393 .IN_SEQUENCE(seq);
394 REQUIRE_CALL(e, takeFanCurvePoints(trompeloeil::_))
395 .LR_WITH(_1 == curve)
396 .IN_SEQUENCE(seq);
397 REQUIRE_CALL(e, takeFanCurveFanStop(true)).IN_SEQUENCE(seq);
398 REQUIRE_CALL(e, takeFanCurveFanStartValue(trompeloeil::_))
399 .WITH(_1 == units::concentration::percent_t(50))
400 .IN_SEQUENCE(seq);
401
402 ts.exportControl(e);
403 }
404
405 SECTION("Does not generate clean control commands")
406 {
407 FanCurveTestAdapter ts(std::make_unique<UIntDataSourceStub>(),
408 std::make_unique<UIntDataSourceStub>(),
409 std::make_unique<IntDataSourceStub>(),
410 units::temperature::celsius_t(0),
411 units::temperature::celsius_t(100));
412 ts.cleanControl(ctlCmds);
413
414 REQUIRE(ctlCmds.commands().empty());
415 }
416
417 SECTION("Does not generate sync control commands when...")
418 {
419 SECTION("is synced")
420 {
421 FanCurveTestAdapter ts(
422 std::make_unique<UIntDataSourceStub>("pwm1_enabled", 1),
423 std::make_unique<UIntDataSourceStub>("pwm1", 128),
424 std::make_unique<IntDataSourceStub>("temp1_input", 50),
425 units::temperature::celsius_t(0), units::temperature::celsius_t(100));
426 auto p1 = std::make_pair(units::temperature::celsius_t(0),
427 units::concentration::percent_t(0));
428 auto p2 = std::make_pair(units::temperature::celsius_t(100),
429 units::concentration::percent_t(100));
430 std::vector<std::pair<units::temperature::celsius_t, units::concentration::percent_t>>
431 curve;
432 curve.push_back(p1);
433 curve.push_back(p2);
434 ts.curve(curve);
435
436 ts.syncControl(ctlCmds);
437
438 REQUIRE(ctlCmds.commands().empty());
439 }
440 }
441
442 SECTION("Does generate sync control commands when...")
443 {
444 auto p1 = std::make_pair(units::temperature::celsius_t(0),
445 units::concentration::percent_t(0));
446 auto p2 = std::make_pair(units::temperature::celsius_t(100),
447 units::concentration::percent_t(100));
448 std::vector<std::pair<units::temperature::celsius_t, units::concentration::percent_t>>
449 curve;
450 curve.push_back(p1);
451 curve.push_back(p2);
452
453 SECTION("pwm1_enabled is out of sync")
454 {
455 FanCurveTestAdapter ts(
456 std::make_unique<UIntDataSourceStub>("pwm1_enabled", 0),
457 std::make_unique<UIntDataSourceStub>("pwm1", 128),
458 std::make_unique<IntDataSourceStub>("temp1_input", 50),
459 units::temperature::celsius_t(0), units::temperature::celsius_t(100));
460 ts.curve(curve);
461
462 ts.syncControl(ctlCmds);
463
464 REQUIRE(ctlCmds.commands().size() == 2);
465
466 auto &[cmd0Path, cmd0Value] = ctlCmds.commands().front();
467 REQUIRE(cmd0Path == "pwm1_enabled");
468 REQUIRE(cmd0Value == "1");
469
470 auto &[cmd1Path, cmd1Value] = ctlCmds.commands().back();
471 REQUIRE(cmd1Path == "pwm1");
472 REQUIRE(cmd1Value == "128");
473 }
474
475 SECTION("pwm1_enabled and pwm1 are out of sync")
476 {
477 FanCurveTestAdapter ts(
478 std::make_unique<UIntDataSourceStub>("pwm1_enabled", 0),
479 std::make_unique<UIntDataSourceStub>("pwm1", 12),
480 std::make_unique<IntDataSourceStub>("temp1_input", 50),
481 units::temperature::celsius_t(0), units::temperature::celsius_t(100));
482 ts.curve(curve);
483
484 ts.syncControl(ctlCmds);
485
486 REQUIRE(ctlCmds.commands().size() == 2);
487
488 auto &[cmd0Path, cmd0Value] = ctlCmds.commands().front();
489 REQUIRE(cmd0Path == "pwm1_enabled");
490 REQUIRE(cmd0Value == "1");
491
492 auto &[cmd1Path, cmd1Value] = ctlCmds.commands().back();
493 REQUIRE(cmd1Path == "pwm1");
494 REQUIRE(cmd1Value == "128");
495 }
496
497 SECTION("fan stop is disabled and pwm1 is out of sync")
498 {
499 FanCurveTestAdapter ts(
500 std::make_unique<UIntDataSourceStub>("pwm1_enabled", 1),
501 std::make_unique<UIntDataSourceStub>("pwm1", 12),
502 std::make_unique<IntDataSourceStub>("temp1_input", 50),
503 units::temperature::celsius_t(0), units::temperature::celsius_t(100));
504 ts.curve(curve);
505
506 ts.syncControl(ctlCmds);
507
508 REQUIRE(ctlCmds.commands().size() == 1);
509
510 auto &[cmdPath, cmdValue] = ctlCmds.commands().front();
511 REQUIRE(cmdPath == "pwm1");
512 REQUIRE(cmdValue == "128");
513 }
514
515 SECTION("fan stop is enabled and...")
516 {
517 SECTION("temperature is >= fan start temperature and pwm1 is out of sync")
518 {
519 auto tempDataSourcePtr = std::make_unique<IntDataSourceStub>(
520 "temp1_input", 0);
521 auto &tempDataSource = *tempDataSourcePtr;
522 FanCurveTestAdapter ts(
523 std::make_unique<UIntDataSourceStub>("pwm1_enabled", 1),
524 std::make_unique<UIntDataSourceStub>("pwm1", 40),
525 std::move(tempDataSourcePtr), units::temperature::celsius_t(0),
526 units::temperature::celsius_t(100));
527 ts.curve(curve);
528 ts.fanStop(true);
529 ts.fanStartValue(128); // 50% -> start temperature = 50 degrees C
530
531 tempDataSource.data(50);
532 ts.syncControl(ctlCmds);
533
534 REQUIRE(ctlCmds.commands().size() == 1);
535 auto &[cmdPath, cmdValue] = ctlCmds.commands().front();
536 REQUIRE(cmdPath == "pwm1");
537 REQUIRE(cmdValue == "128");
538 }
539
540 SECTION("temperature is fanStartTemp - hyst and pwm1 > 0 but out of sync")
541 {
542 auto tempDataSourcePtr = std::make_unique<IntDataSourceStub>(
543 "temp1_input", 0);
544 auto &tempDataSource = *tempDataSourcePtr;
545 FanCurveTestAdapter ts(
546 std::make_unique<UIntDataSourceStub>("pwm1_enabled", 1),
547 std::make_unique<UIntDataSourceStub>("pwm1", 154),
548 std::move(tempDataSourcePtr), units::temperature::celsius_t(0),
549 units::temperature::celsius_t(100));
550 ts.curve(curve);
551 ts.fanStop(true);
552 ts.fanStartValue(128); // 50% -> start temperature = 50 degrees C
553
554 // temperature equals to fan start - hysteresis
555 tempDataSource.data(50 - ts.hysteresis());
556 ts.syncControl(ctlCmds);
557
558 REQUIRE(ctlCmds.commands().size() == 1);
559 auto &[cmdPath, cmdValue] = ctlCmds.commands().front();
560 REQUIRE(cmdPath == "pwm1");
561 REQUIRE(cmdValue == "128"); // value of fan start temperature
562 }
563
564 SECTION("temperature is in (fanStartTemp - hyst, fanStartTemp) range "
565 "and pwm1 > 0 but out of sync")
566 {
567 auto tempDataSourcePtr = std::make_unique<IntDataSourceStub>(
568 "temp1_input", 0);
569 auto &tempDataSource = *tempDataSourcePtr;
570 FanCurveTestAdapter ts(
571 std::make_unique<UIntDataSourceStub>("pwm1_enabled", 1),
572 std::make_unique<UIntDataSourceStub>("pwm1", 154),
573 std::move(tempDataSourcePtr), units::temperature::celsius_t(0),
574 units::temperature::celsius_t(100));
575 ts.curve(curve);
576 ts.fanStop(true);
577 ts.fanStartValue(128); // 50% -> start temperature = 50 degrees C
578
579 // temperature in (fan start - hysteresis, fan start) range
580 tempDataSource.data(49);
581 ts.syncControl(ctlCmds);
582
583 REQUIRE(ctlCmds.commands().size() == 1);
584 auto &[cmdPath, cmdValue] = ctlCmds.commands().front();
585 REQUIRE(cmdPath == "pwm1");
586 REQUIRE(cmdValue == "128"); // value of fan start temperature
587 }
588
589 SECTION("temperature is < fanStartTemp - hyst and pwm1 > 0")
590 {
591 auto tempDataSourcePtr = std::make_unique<IntDataSourceStub>(
592 "temp1_input", 0);
593 auto &tempDataSource = *tempDataSourcePtr;
594 FanCurveTestAdapter ts(
595 std::make_unique<UIntDataSourceStub>("pwm1_enabled", 1),
596 std::make_unique<UIntDataSourceStub>("pwm1", 128),
597 std::move(tempDataSourcePtr), units::temperature::celsius_t(0),
598 units::temperature::celsius_t(100));
599 ts.curve(curve);
600 ts.fanStop(true);
601 ts.fanStartValue(128); // 50% -> start temperature = 50 degrees C
602
603 // temperature lower than fan start - hysteresis
604 tempDataSource.data(50 - ts.hysteresis() - 1);
605 ts.syncControl(ctlCmds);
606
607 REQUIRE(ctlCmds.commands().size() == 1);
608 auto &[cmdPath, cmdValue] = ctlCmds.commands().front();
609 REQUIRE(cmdPath == "pwm1");
610 REQUIRE(cmdValue == "0"); // turns off fan
611 }
612
613 SECTION("fan stop was enabled and then disabled")
614 {
615 FanCurveTestAdapter ts(
616 std::make_unique<UIntDataSourceStub>("pwm1_enabled", 1),
617 std::make_unique<UIntDataSourceStub>("pwm1", 0),
618 std::make_unique<IntDataSourceStub>("temp1_input", 50),
619 units::temperature::celsius_t(0),
620 units::temperature::celsius_t(100));
621 ts.curve(curve);
622 ts.fanStop(true);
623
624 ts.syncControl(ctlCmds);
625 ctlCmds = {};
626
627 ts.fanStop(false);
628 ts.syncControl(ctlCmds);
629
630 REQUIRE(ctlCmds.commands().size() == 1);
631 auto &[cmdPath, cmdValue] = ctlCmds.commands().front();
632 REQUIRE(cmdPath == "pwm1");
633 REQUIRE(cmdValue != "0");
634 }
635 }
636 }
637 }
638
639 } // namespace Tests::AMD::FanCurve