summaryrefslogtreecommitdiff
path: root/test/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-11-30 01:10:32 +0300
committerEd Tanous <ed@tanous.net>2023-01-03 19:33:15 +0300
commitc71d61258bd3cd8573166011b450a1eecce2c572 (patch)
tree63e81142716b06f1810d0c21ba4dfb5b4a89c364 /test/redfish-core
parent7f57f19593fc87da79caa9d7da77976622c933ae (diff)
downloadbmcweb-c71d61258bd3cd8573166011b450a1eecce2c572.tar.xz
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 <edtanous@google.com> Change-Id: I9aa8099a947a36b5ce914bc07ae60f1ebf0d209b
Diffstat (limited to 'test/redfish-core')
-rw-r--r--test/redfish-core/lib/sensors_test.cpp36
1 files changed, 36 insertions, 0 deletions
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 <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
+// IWYU pragma: no_include <gtest/gtest-matchers.h>
+
+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