From c71d61258bd3cd8573166011b450a1eecce2c572 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Tue, 29 Nov 2022 14:10:32 -0800 Subject: Fix sensor override c1d019a6056a2a0ef50e577b3139ab5a8dc49355 Sensor Optimization Recently changed the way Ids were calculated in the sensor subsystem. Unfortunately, it wasn't clear to the author that this would effect the sensor override system, which relies on matching up a member ID with a dbus path, and was broken by this change. This commit breaks out the code to calculate the type and name from a given URI segment into a helper method. Tested: Inspection only. Very few systems support this feature. Code appears more correct than previously, which is known broken, so the lack of testing here seems reasonable. Signed-off-by: Ed Tanous Change-Id: I9aa8099a947a36b5ce914bc07ae60f1ebf0d209b --- test/redfish-core/lib/sensors_test.cpp | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/redfish-core/lib/sensors_test.cpp (limited to 'test/redfish-core') diff --git a/test/redfish-core/lib/sensors_test.cpp b/test/redfish-core/lib/sensors_test.cpp new file mode 100644 index 0000000000..591b911690 --- /dev/null +++ b/test/redfish-core/lib/sensors_test.cpp @@ -0,0 +1,36 @@ +#include "sensors.hpp" + +#include // IWYU pragma: keep +#include // IWYU pragma: keep + +// IWYU pragma: no_include +// IWYU pragma: no_include +// IWYU pragma: no_include "gtest/gtest_pred_impl.h" +// IWYU pragma: no_include +// IWYU pragma: no_include + +namespace redfish +{ +namespace +{ + +TEST(SplitSensorNameAndType, Type) +{ + EXPECT_EQ(splitSensorNameAndType("fantach_foo_1").first, "fan_tach"); + EXPECT_EQ(splitSensorNameAndType("temperature_foo2").first, "temperature"); +} + +TEST(SplitSensorNameAndType, Name) +{ + EXPECT_EQ(splitSensorNameAndType("fantach_foo_1").second, "foo_1"); + EXPECT_EQ(splitSensorNameAndType("temperature_foo2").second, "foo2"); +} + +TEST(SplitSensorNameAndType, Error) +{ + EXPECT_TRUE(splitSensorNameAndType("fantach").first.empty()); + EXPECT_TRUE(splitSensorNameAndType("temperature").second.empty()); +} + +} // namespace +} // namespace redfish -- cgit v1.2.3