Fix unit test
Now that scale is gone, reading should match the value
written.
Change-Id: I63a3ec0dc50ee5eacc08b23d0669fa065961abd2
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/test/helpers.hpp b/test/helpers.hpp
index 6952c52..b95200c 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -32,11 +32,11 @@
* @param[in] path - the dbus path passed to the object
* @param[in] intf - the dbus interface
* @param[in] properties - an ordered list of expected property updates.
- * @param[in] index - a pointer to a valid integer in a surviving scope.
+ * @param[in] index - a pointer to a valid double in a surviving scope.
*/
void SetupDbusObject(sdbusplus::SdBusMock* sdbus_mock, bool defer,
const std::string& path, const std::string& intf,
- const std::vector<std::string>& properties, int* index)
+ const std::vector<std::string>& properties, double* index)
{
EXPECT_CALL(*sdbus_mock,
sd_bus_add_object_vtable(IsNull(), NotNull(), StrEq(path),
diff --git a/test/pid_zone_unittest.cpp b/test/pid_zone_unittest.cpp
index 5da10f8..121f44c 100644
--- a/test/pid_zone_unittest.cpp
+++ b/test/pid_zone_unittest.cpp
@@ -45,10 +45,10 @@
double minThermalOutput = 1000.0;
double failSafePercent = 0.75;
- int i;
+ double d;
std::vector<std::string> properties;
SetupDbusObject(&sdbus_mock_mode, defer, objPath, modeInterface, properties,
- &i);
+ &d);
PIDZone p(zone, minThermalOutput, failSafePercent, m, bus_mock_mode,
objPath, defer);
@@ -86,7 +86,7 @@
}
// unused
- int property_index;
+ double property_index;
std::vector<std::string> properties;
sdbusplus::SdBusMock sdbus_mock_passive;
diff --git a/test/sensor_host_unittest.cpp b/test/sensor_host_unittest.cpp
index 6851732..14c09f0 100644
--- a/test/sensor_host_unittest.cpp
+++ b/test/sensor_host_unittest.cpp
@@ -33,16 +33,12 @@
bool defer = false;
std::string interface = "xyz.openbmc_project.Sensor.Value";
- // Scale is the only property we change in the code. Also,
- // emit_object_added isn't called twice.
- // Temperature is the default for type, and everything, so those aren't
- // updated.
- std::vector<std::string> properties = {"Scale"};
- int i;
+ std::vector<std::string> properties = {};
+ double d;
// The createTemp updates all the properties, however, only Scale is set
// to non-default.
- SetupDbusObject(&sdbus_mock, defer, objPath, interface, properties, &i);
+ SetupDbusObject(&sdbus_mock, defer, objPath, interface, properties, &d);
// This is called during object destruction.
EXPECT_CALL(sdbus_mock,
@@ -66,14 +62,10 @@
bool defer = false;
std::string interface = "xyz.openbmc_project.Sensor.Value";
- // Scale is the only property we change in the code. Also,
- // emit_object_added isn't called twice.
- // Temperature is the default for type, and everything, so those aren't
- // updated.
- std::vector<std::string> properties = {"Scale"};
- int i;
+ std::vector<std::string> properties = {};
+ double d;
- SetupDbusObject(&sdbus_mock, defer, objPath, interface, properties, &i);
+ SetupDbusObject(&sdbus_mock, defer, objPath, interface, properties, &d);
EXPECT_CALL(sdbus_mock,
sd_bus_emit_object_removed(IsNull(), StrEq(objPath)))
@@ -84,7 +76,7 @@
// Value is updated from dbus calls only (normally).
HostSensor* hs = static_cast<HostSensor*>(s.get());
- int64_t new_value = 2;
+ double new_value = 2;
ReadReturn r = hs->read();
EXPECT_EQ(r.value, 0);
@@ -103,7 +95,7 @@
hs->value(new_value);
r = hs->read();
- EXPECT_EQ(r.value, new_value * 0.001);
+ EXPECT_EQ(r.value, new_value);
auto duration =
std::chrono::duration_cast<std::chrono::seconds>(t1 - r.updated)