build: meson support for unit tests

Add support for building and running existing unit tests
under meson.

Fix a few test case failures that might surface from running
as non-root or without a full OpenBMC set of applications.

Fixes: openbmc/phosphor-logging#11

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I588c0b7d8dcdc60b9a03fee0b5d373d0023b0530
diff --git a/log_manager.cpp b/log_manager.cpp
index 90cf1d4..83ad168 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -81,9 +81,16 @@
     return entryId;
 }
 
-void Manager::_commit(uint64_t transactionId, std::string&& errMsg,
-                      Entry::Level errLvl)
+void Manager::_commit(uint64_t transactionId [[maybe_unused]],
+                      std::string&& errMsg, Entry::Level errLvl)
 {
+    std::vector<std::string> additionalData{};
+
+    // When running as a test-case, the system may have a LOT of journal
+    // data and we may not have permissions to do some of the journal sync
+    // operations.  Just skip over them.
+#ifndef TESTCASE
+
     constexpr const auto transactionIdVar = "TRANSACTION_ID";
     // Length of 'TRANSACTION_ID' string.
     constexpr const auto transactionIdVarSize = std::strlen(transactionIdVar);
@@ -114,8 +121,6 @@
     // Add _PID field information in AdditionalData.
     metalist.insert("_PID");
 
-    std::vector<std::string> additionalData;
-
     // Read the journal from the end to get the most recent entry first.
     // The result from the sd_journal_get_data() is of the form VARIABLE=value.
     SD_JOURNAL_FOREACH_BACKWARDS(j)
@@ -186,6 +191,7 @@
 
     sd_journal_close(j);
 
+#endif
     createEntry(errMsg, errLvl, additionalData);
 }
 
@@ -251,6 +257,12 @@
 
 bool Manager::isQuiesceOnErrorEnabled()
 {
+    // When running under tests, the Logging.Settings service will not be
+    // present.  Assume false.
+#ifdef TESTCASE
+    return false;
+#endif
+
     std::variant<bool> property;
 
     auto method = this->busLog.new_method_call(
@@ -675,6 +687,7 @@
                 log<level::ERR>("Failed to kill journal service");
                 break;
             }
+
             continue;
         }