main: Fix getSubTree & getSubTreePaths partial match

Due to us popping out the trailing "/" in our "reqPath", partial matches
satisfied the "boost::starts_with(" searches for paths - leading to
"core1X" for example, matching a reqPath of "core1" or "core1/".

Since we do not want to return the base reqPath anyway, add a trailing
"/" in the reqPath for the match to ensure complete match.

Tested:
dbus-send --system --print-reply --dest=xyz.openbmc_project.ObjectMapper /xyz/openbmc_project/object_mapper xyz.openbmc_project.ObjectMapper.GetSubTreePaths string:"/xyz/openbmc_oject/inventory/system/chassis/motherboard/cpu0/core1" int32:0 array:string:"xyz.openbmc_project.Inventory.Item.CpuThread"

Without the fix:
   array [
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core1/thread0"
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core11/thread0"
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core12/thread0"
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core13/thread0"
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core14/thread0"
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core15/thread0"
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core16/thread0"
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core17/thread0"
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core18/thread0"
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core19/thread0"
   ]

With the fix:
   array [
      string "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core1/thread0"
   ]

Similar results with GetSubTree, results not pasted as it's too long:
dbus-send --system --print-reply --dest=xyz.openbmc_project.ObjectMapper /xyz/openbmc_project/object_mapper xyz.openbmc_project.ObjectMapper.GetSubTree string:"/xyz/openbmc_proje/inventory/system/chassis/motherboard/cpu0/core1" int32:0 array:string:"xyz.openbmc_project.Inventory.Item.CpuThread"

-------------
Also verified that "depth" remained the same using print outs:

Before change:
mapperx[12580]: thisPath: /xyz/openbmc_project/sensors/power
mapperx[12580]: reqPath:
mapperx[12580]: thisDepth: 4

mapperx[12580]: thisPath: /xyz/openbmc_project/sensors/temperature
mapperx[12580]: reqPath: /xyz/openbmc_project
mapperx[12580]: thisDepth: 2

After:
mapperx[30959]: thisPath: /xyz/openbmc_project/network
mapperx[30959]: reqPath: /
mapperx[30959]: thisDepth: 3

mapperx[30959]: thisPath: /xyz/openbmc_project/inventory/system/board
mapperx[30959]: reqPath: /xyz/openbmc_project/inventory/system/
mapperx[30959]: thisDepth: 1

Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: If488402a3839de21c50b4585e51fa156016e768d
1 file changed
tree: 37f71570c675589b60d0868311c46b9d9e6a3f3a
  1. fail-monitor/
  2. libmapper/
  3. src/
  4. subprojects/
  5. .clang-format
  6. .gitignore
  7. LICENSE
  8. meson.build
  9. meson_options.txt
  10. OWNERS
  11. README.md
README.md

Prerequisites

Non-OpenBMC build dependencies are:

  • meson/ninja
  • boost
  • libsystemd
  • systemd
  • tinyxml2

Build

meson build && ninja -C build

Run Unit Tests

meson build && ninja -C build test

Clean the repository

rm -rf build