nvme: restore backward compatibility for mi_i2c without bus property

For NVMe devices configured with protocol "mi_i2c" and associated
with MCTP reactor configurations (isMctpReactorDevice), the "Bus"
property is optional because endpoint discovery and routing are
resolved dynamically via MCTP associations.

A recent commit enforced that both "mi_basic" and "mi_i2c" require
the "Bus" property upfront, which caused valid "mi_i2c" reactor
configurations lacking the "Bus" property to be skipped.

This change separates the protocol validation logic so that "mi_i2c"
only enforces the presence of "Bus" when the device is not an MCTP
reactor device, restoring backward compatibility.

Tested:
- Added a temporary unit test simulating NVMe configurations with
  Protocol "mi_i2c" and MctpReactorConfigPath without a "Bus" property,
  verifying that the NVMeSubsystem and NVMeDevice are created.
- Verified that direct "mi_i2c" (without MCTP reactor config) and
  "mi_basic" configurations without "Bus" continue to be rejected.

Google-Bug-Id: 546682451
Change-Id: I6db4c1a47860b6ac1e8ccf5393f3230ba85b8642
Signed-off-by: Hao Jiang <jianghao@google.com>
diff --git a/src/NVMeSensorMain.cpp b/src/NVMeSensorMain.cpp
index 3a71371..3d71f09 100644
--- a/src/NVMeSensorMain.cpp
+++ b/src/NVMeSensorMain.cpp
@@ -331,12 +331,18 @@
             nvmeProtocol.emplace("mi_basic");
         }
 
+        std::optional<std::string> mctpReactorConfigPath =
+            extractMctpReactorConfigPath(sensorConfig);
+
+        const bool isMctpReactorDevice = mctpReactorConfigPath.has_value() ||
+                                         *nvmeProtocol == "mi_mctp";
+
         std::optional<int> busNumber;
         std::optional<int> address;
         std::vector<BusInfo> busInfoList;
         std::string endpointPath;
 
-        if (*nvmeProtocol == "mi_basic" || *nvmeProtocol == "mi_i2c")
+        if (*nvmeProtocol == "mi_basic")
         {
             busNumber = extractBusNumber(nvmeObjectPath, sensorConfig);
             address = extractAddress(nvmeObjectPath, sensorConfig);
@@ -345,6 +351,15 @@
                 continue;
             }
         }
+        else if (*nvmeProtocol == "mi_i2c")
+        {
+            busNumber = extractBusNumber(nvmeObjectPath, sensorConfig);
+            address = extractAddress(nvmeObjectPath, sensorConfig);
+            if (!isMctpReactorDevice && !busNumber)
+            {
+                continue;
+            }
+        }
         else if (*nvmeProtocol == "mi_mctp")
         {
             busInfoList = extractNVMeBusInfo(configData);
@@ -379,9 +394,6 @@
 
         std::optional<std::string> sensorName = extractName(nvmeObjectPath,
                                                             sensorConfig);
-        std::optional<std::string> mctpReactorConfigPath =
-            extractMctpReactorConfigPath(sensorConfig);
-
         bool enableFeatureLockdown = hasLockdownFeature(nvmeObjectPath,
                                                         sensorConfig);
 
@@ -390,9 +402,6 @@
             continue;
         }
 
-        const bool isMctpReactorDevice = mctpReactorConfigPath.has_value() ||
-                                         *nvmeProtocol == "mi_mctp";
-
         if (busNumber && bannedBuses.contains(*busNumber))
         {
             lg2::info("Skip banned i2c bus: {BUS}", "BUS", *busNumber);
diff --git a/tests/setup.sh b/tests/setup.sh
index a593378..b394faa 100644
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -33,4 +33,3 @@
 
 sleep 1
 busctl $USER_FLAG tree xyz.openbmc_project.ObjectMapper
-busctl $USER_FLAG monitor xyz.openbmc_project.ObjectMapper > /tmp/mapper_monitor.log 2>&1 < /dev/null &