Adjust current size of total dump files in dump directory

Symptom:
"Verify Maximum BMC Dump Creation" test item got failed sometimes.
This test item expect that dump space is enough to create a new BMC dump file.
But, dump manager doesn't think dump space is enough to create
according to current size of dump directory.

Root cause:
dump manager is using std::filesystem::file_size to calculate total size of
dump log files in dump directory. Then total size is divided by 1024
convert to KB. However, test item is using linux command "du -s" to calculate
total size of dump log files in dump directory.
The calculation result is different between dump manager and test item
then cause test got failed sometimes.

Solution:
calculate each dump file with std::ceil() and convert size to KB then
calculate total dump files size in dump directory. That's can reduce size
difference of total dump files between dump manager
and test item then avoid this test got failed.

Tested:
Run 3~4 times robot
Verify_Maximum_BMC_Dump_Creation redfish/managers/test_bmc_dumps.robot
Verify Maximum BMC Dump Creation :: Create maximum BMC dump and ve... | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed

Signed-off-by: Tim Lee <timlee660101@gmail.com>
Change-Id: Ic1a6d941d12516678ff21789355941653d319858
diff --git a/dump_manager_bmc.cpp b/dump_manager_bmc.cpp
index 931c0eb..f570181 100644
--- a/dump_manager_bmc.cpp
+++ b/dump_manager_bmc.cpp
@@ -13,6 +13,7 @@
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
 
+#include <cmath>
 #include <ctime>
 #include <regex>
 
@@ -249,13 +250,10 @@
     {
         if (!std::filesystem::is_directory(p))
         {
-            size += std::filesystem::file_size(p);
+            size += std::ceil(std::filesystem::file_size(p) / 1024.0);
         }
     }
 
-    // Convert size into KB
-    size = size / 1024;
-
     // Set the Dump size to Maximum  if the free space is greater than
     // Dump max size otherwise return the available size.