Get eraseMaxGeometry and eraseMinGeometry from dbus

Also, make findDevice return output parameters based on RVO.

With the change like in EntityManager JSON:
```
{
    "Name": "example_emmc",
    "Type": "EmmcDevice",
    "LocationCode": "location"
    "EraseMaxGeometry": 10000000000,
    "EraseMinGeometry": 5000000000,
}
```
and geometry values will be set to estoraged.

Tested:
- unit test pass:
```
5/7 util_test                        OK              0.05s
```

Change-Id: Ia8499af2168c7e740558978273fc80456eb29282
Signed-off-by: Tom Tung <shes050117@gmail.com>
diff --git a/src/test/util_test.cpp b/src/test/util_test.cpp
index 5f8dca5..708454d 100644
--- a/src/test/util_test.cpp
+++ b/src/test/util_test.cpp
@@ -1,3 +1,4 @@
+#include "estoraged_conf.hpp"
 #include "getConfig.hpp"
 
 #include <boost/container/flat_map.hpp>
@@ -131,15 +132,73 @@
     /* Look for the device file. */
     std::filesystem::path deviceFile, sysfsDir;
     std::string luksName, locationCode;
-    EXPECT_TRUE(estoraged::util::findDevice(data, std::filesystem::path("./"),
-                                            deviceFile, sysfsDir, luksName,
-                                            locationCode));
+    auto result = estoraged::util::findDevice(data,
+                                              std::filesystem::path("./"));
+    EXPECT_TRUE(result.has_value());
 
     /* Validate the results. */
-    EXPECT_EQ("/dev/mmcblk0", deviceFile.string());
-    EXPECT_EQ("./mmcblk0/device", sysfsDir.string());
-    EXPECT_EQ("luks-mmcblk0", luksName);
-    EXPECT_EQ("U102020", locationCode);
+    EXPECT_EQ("/dev/mmcblk0", result->deviceFile.string());
+    EXPECT_EQ("./mmcblk0/device", result->sysfsDir.string());
+    EXPECT_EQ("luks-mmcblk0", result->luksName);
+    EXPECT_EQ("U102020", result->locationCode);
+    EXPECT_EQ(ERASE_MAX_GEOMETRY, result->eraseMaxGeometry);
+    EXPECT_EQ(ERASE_MIN_GEOMETRY, result->eraseMinGeometry);
+
+    /* Delete the dummy files. */
+    EXPECT_EQ(3U, std::filesystem::remove_all("mmcblk0"));
+    EXPECT_EQ(3U, std::filesystem::remove_all("abc"));
+    EXPECT_EQ(2U, std::filesystem::remove_all("def"));
+}
+
+/* Test case where we successfully find the device file with updating the
+ * min/max geometry. */
+TEST(utilTest, findDeviceWithMaxAndMinGeometryPass)
+{
+    estoraged::StorageData data;
+
+    /* Set up the map of properties. */
+    data.emplace(std::string("Type"),
+                 estoraged::BasicVariantType("EmmcDevice"));
+    data.emplace(std::string("Name"), estoraged::BasicVariantType("emmc"));
+    data.emplace(std::string("LocationCode"),
+                 estoraged::BasicVariantType("U102020"));
+    data.emplace(std::string("EraseMaxGeometry"),
+                 estoraged::BasicVariantType((uint64_t)5566));
+    data.emplace(std::string("EraseMinGeometry"),
+                 estoraged::BasicVariantType((uint64_t)1234));
+
+    /* Create a dummy device. */
+    std::filesystem::create_directories("abc/device");
+    const std::string dummyTypeFileName("abc/device/type");
+    std::ofstream dummyTypeFile(dummyTypeFileName,
+                                std::ios::out | std::ios::trunc);
+    dummyTypeFile << "SSD";
+    dummyTypeFile.close();
+
+    /* Another device. */
+    std::filesystem::create_directories("def/device");
+
+    /* Create a dummy eMMC device. */
+    std::filesystem::create_directories("mmcblk0/device");
+    const std::string typeFileName("mmcblk0/device/type");
+    std::ofstream typeFile(typeFileName, std::ios::out | std::ios::trunc);
+    typeFile << "MMC";
+    typeFile.close();
+
+    /* Look for the device file. */
+    std::filesystem::path deviceFile, sysfsDir;
+    std::string luksName, locationCode;
+    auto result = estoraged::util::findDevice(data,
+                                              std::filesystem::path("./"));
+    EXPECT_TRUE(result.has_value());
+
+    /* Validate the results. */
+    EXPECT_EQ("/dev/mmcblk0", result->deviceFile.string());
+    EXPECT_EQ("./mmcblk0/device", result->sysfsDir.string());
+    EXPECT_EQ("luks-mmcblk0", result->luksName);
+    EXPECT_EQ("U102020", result->locationCode);
+    EXPECT_EQ(5566, result->eraseMaxGeometry);
+    EXPECT_EQ(1234, result->eraseMinGeometry);
 
     /* Delete the dummy files. */
     EXPECT_EQ(3U, std::filesystem::remove_all("mmcblk0"));
@@ -174,11 +233,9 @@
     typeFile.close();
 
     /* Look for the device file. */
-    std::filesystem::path deviceFile, sysfsDir;
-    std::string luksName, locationCode;
-    EXPECT_FALSE(estoraged::util::findDevice(data, std::filesystem::path("./"),
-                                             deviceFile, sysfsDir, luksName,
-                                             locationCode));
+    auto result = estoraged::util::findDevice(data,
+                                              std::filesystem::path("./"));
+    EXPECT_FALSE(result.has_value());
 
     /* Delete the dummy files. */
     EXPECT_EQ(3U, std::filesystem::remove_all("mmcblk0"));
@@ -215,11 +272,9 @@
     typeFile.close();
 
     /* Look for the device file. */
-    std::filesystem::path deviceFile, sysfsDir;
-    std::string luksName, locationCode;
-    EXPECT_FALSE(estoraged::util::findDevice(data, std::filesystem::path("./"),
-                                             deviceFile, sysfsDir, luksName,
-                                             locationCode));
+    auto result = estoraged::util::findDevice(data,
+                                              std::filesystem::path("./"));
+    EXPECT_FALSE(result.has_value());
 
     /* Delete the dummy files. */
     EXPECT_EQ(3U, std::filesystem::remove_all("mmcblk0"));
@@ -249,11 +304,9 @@
     std::filesystem::create_directories("def/device");
 
     /* Look for the device file. */
-    std::filesystem::path deviceFile, sysfsDir;
-    std::string luksName, locationCode;
-    EXPECT_FALSE(estoraged::util::findDevice(data, std::filesystem::path("./"),
-                                             deviceFile, sysfsDir, luksName,
-                                             locationCode));
+    auto result = estoraged::util::findDevice(data,
+                                              std::filesystem::path("./"));
+    EXPECT_FALSE(result.has_value());
 
     /* Delete the dummy files. */
     EXPECT_EQ(3U, std::filesystem::remove_all("abc"));