presence: Fix and run fallbacktest
The fan presence tests didn't get enabled properly on the move to meson.
Fix that so they run, and then also fix the compile errors in the
testcase due to code that has changed since it had been disabled.
Tested:
Testcase now runs and passes.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I8cebbadc6061fd45fc6b3d6a33d0a4079f5de52d
diff --git a/presence/test/fallbacktest.cpp b/presence/test/fallbacktest.cpp
index de4a54d..5cbfbc7 100644
--- a/presence/test/fallbacktest.cpp
+++ b/presence/test/fallbacktest.cpp
@@ -51,6 +51,8 @@
++failed;
}
+ void logConflict(const std::string&) const override {}
+
bool _present = false;
size_t started = 0;
size_t stopped = 0;
@@ -80,13 +82,13 @@
ASSERT_EQ(ts.stopped, 0);
ASSERT_EQ(ts.started, 1);
- f.stateChanged(false);
+ f.stateChanged(false, ts);
ASSERT_EQ(pstate, 0);
ASSERT_EQ(ts.failed, 0);
ASSERT_EQ(ts.stopped, 0);
ASSERT_EQ(ts.started, 1);
- f.stateChanged(true);
+ f.stateChanged(true, ts);
ASSERT_EQ(pstate, 1);
ASSERT_EQ(ts.failed, 0);
ASSERT_EQ(ts.stopped, 0);
@@ -118,7 +120,7 @@
ts1._present = false;
ts2._present = false;
- f.stateChanged(false);
+ f.stateChanged(false, ts1);
ASSERT_EQ(pstate, 0);
ASSERT_EQ(ts1.failed, 0);
ASSERT_EQ(ts1.stopped, 0);
@@ -129,7 +131,7 @@
ts1._present = true;
ts2._present = true;
- f.stateChanged(true);
+ f.stateChanged(true, ts1);
ASSERT_EQ(pstate, 1);
ASSERT_EQ(ts1.failed, 0);
ASSERT_EQ(ts1.stopped, 0);
@@ -145,7 +147,7 @@
// Validate first sensor on->off.
pstate = -1;
- Fan fan{"/path", "name"};
+ Fan fan{"/path", "name", std::nullopt};
TestSensor ts1, ts2;
ts1._present = true;
ts2._present = true;
@@ -156,7 +158,7 @@
f.monitor();
ASSERT_EQ(pstate, 1);
ts1._present = false;
- f.stateChanged(false);
+ f.stateChanged(false, ts1);
ASSERT_EQ(pstate, 1);
ASSERT_EQ(ts1.failed, 1);
ASSERT_EQ(ts1.stopped, 1);
@@ -168,7 +170,7 @@
// Flip the state of both sensors.
ts1._present = true;
ts2._present = false;
- f.stateChanged(false);
+ f.stateChanged(false, ts1);
ASSERT_EQ(pstate, 0);
ASSERT_EQ(ts1.failed, 1);
ASSERT_EQ(ts1.stopped, 1);
@@ -184,7 +186,7 @@
// Validate first in bad state.
pstate = -1;
- Fan fan{"/path", "name"};
+ Fan fan{"/path", "name", std::nullopt};
TestSensor ts1, ts2;
ts1._present = false;
ts2._present = true;
@@ -201,7 +203,7 @@
ASSERT_EQ(ts2.stopped, 0);
ASSERT_EQ(ts2.started, 1);
- f.stateChanged(false);
+ f.stateChanged(false, ts1);
ASSERT_EQ(pstate, 0);
ASSERT_EQ(ts1.failed, 1);
ASSERT_EQ(ts1.stopped, 0);
@@ -217,7 +219,7 @@
// Validate both in bad state.
pstate = -1;
- Fan fan{"/path", "name"};
+ Fan fan{"/path", "name", std::nullopt};
TestSensor ts1, ts2;
ts1._present = false;
ts2._present = false;