Multi-host support for GET routes in systems.hpp

Add support for multi-host GET request-handling under the
/redfish/v1/Systems/{computerSystemId}/ redfish resource.

All multi-host supported redfish URIs can be found in this listing [1].

Multi-host meson options needed:
-Dexperimental-redfish-multi-computer-system=enabled

Tested: Validator passes on single-host machine and yv4 qemu emulation.

[1] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/76118

Change-Id: I67c17c3dd7a354fa9a2ebbc56d4def7a7e788909
Signed-off-by: Oliver Brewka <oliver.brewka@9elements.com>
diff --git a/test/meson.build b/test/meson.build
index 09b29d3..f66bc52 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -42,6 +42,7 @@
     'redfish-core/include/utils/query_param_test.cpp',
     'redfish-core/include/utils/sensor_utils_test.cpp',
     'redfish-core/include/utils/stl_utils_test.cpp',
+    'redfish-core/include/utils/systems_utils_test.cpp',
     'redfish-core/include/utils/time_utils_test.cpp',
     'redfish-core/lib/chassis_test.cpp',
     'redfish-core/lib/ethernet_test.cpp',
diff --git a/test/redfish-core/include/utils/systems_utils_test.cpp b/test/redfish-core/include/utils/systems_utils_test.cpp
new file mode 100644
index 0000000..b2fceba
--- /dev/null
+++ b/test/redfish-core/include/utils/systems_utils_test.cpp
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright OpenBMC Authors
+
+#include "dbus_utility.hpp"
+#include "utils/systems_utils.hpp"
+
+#include <boost/beast/http/status.hpp>
+#include <boost/system/errc.hpp>
+#include <nlohmann/json.hpp>
+#include <sdbusplus/message.hpp>
+
+#include <string>
+
+#include <gtest/gtest.h>
+
+namespace redfish
+{
+namespace
+{
+
+TEST(SystemsUtils, IndexMatchingObjectPath)
+{
+    auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
+
+    std::string objectPath;
+    std::string service;
+
+    const dbus::utility::MapperGetSubTreeResponse subtree = {
+        {"/xyz/openbmc_project/control/host1",
+         {{"xyz.openbmc_project.Settings", {}}}},
+        {"/xyz/openbmc_project/control/host2/policy/TPMEnable",
+         {{"xyz.openbmc_project.Settings", {}}}},
+        {"/xyz/openbmc_project/control/host10/policy/TPMEnable",
+         {{"xyz.openbmc_project.Settings", {}}}},
+        {"/xyz/openbmc_project/control/host999/",
+         {{"xyz.openbmc_project.Settings", {}}}}};
+
+    EXPECT_TRUE(indexMatchingSubTreeMapObjectPath(asyncResp, 1, subtree,
+                                                  objectPath, service));
+    EXPECT_TRUE(indexMatchingSubTreeMapObjectPath(asyncResp, 2, subtree,
+                                                  objectPath, service));
+    EXPECT_TRUE(indexMatchingSubTreeMapObjectPath(asyncResp, 10, subtree,
+                                                  objectPath, service));
+    EXPECT_TRUE(indexMatchingSubTreeMapObjectPath(asyncResp, 999, subtree,
+                                                  objectPath, service));
+    EXPECT_FALSE(indexMatchingSubTreeMapObjectPath(asyncResp, 100, subtree,
+                                                   objectPath, service));
+    EXPECT_FALSE(indexMatchingSubTreeMapObjectPath(asyncResp, 11, subtree,
+                                                   objectPath, service));
+    EXPECT_FALSE(indexMatchingSubTreeMapObjectPath(asyncResp, 0, subtree,
+                                                   objectPath, service));
+
+    indexMatchingSubTreeMapObjectPath(asyncResp, 1, subtree, objectPath,
+                                      service);
+    EXPECT_EQ(objectPath, "/xyz/openbmc_project/control/host1");
+    EXPECT_EQ(service, "xyz.openbmc_project.Settings");
+
+    indexMatchingSubTreeMapObjectPath(asyncResp, 10, subtree, objectPath,
+                                      service);
+    EXPECT_EQ(objectPath,
+              "/xyz/openbmc_project/control/host10/policy/TPMEnable");
+
+    indexMatchingSubTreeMapObjectPath(asyncResp, 999, subtree, objectPath,
+                                      service);
+    EXPECT_EQ(objectPath, "/xyz/openbmc_project/control/host999/");
+}
+} // namespace
+} // namespace redfish