log-manager: enable non-standard path for local tests
Enable the log-manager to be launched with a path other than
`/var/phosphor-logging` to allow it to be ran on a development system
for test purposes. This required some refactoring throughout as to
how paths were handled.
Tested:
After running tests, `/tmp/phosphor-logging` is populated with
entries. Launching `./builddir/phosphor-log-manager
/tmp/phosphor-logging`, the log-manager will have the entries on
dbus:
```
$ busctl --user tree xyz.openbmc_project.Logging
└─ /xyz
└─ /xyz/openbmc_project
└─ /xyz/openbmc_project/logging
├─ /xyz/openbmc_project/logging/entry
│ ├─ /xyz/openbmc_project/logging/entry/100
│ ├─ /xyz/openbmc_project/logging/entry/101
│ ├─ /xyz/openbmc_project/logging/entry/102
│ ├─ /xyz/openbmc_project/logging/entry/103
```
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I84968edeed0dcf73aaf8bb653060b6d3400b9b7b
diff --git a/test/elog_update_ts_test.cpp b/test/elog_update_ts_test.cpp
index 07d9613..e8ddc09 100644
--- a/test/elog_update_ts_test.cpp
+++ b/test/elog_update_ts_test.cpp
@@ -4,6 +4,7 @@
#include "elog_serialize.hpp"
#include "extensions.hpp"
#include "log_manager.hpp"
+#include "paths.hpp"
#include <filesystem>
#include <thread>
@@ -34,11 +35,11 @@
TEST(TestUpdateTS, testChangeResolved)
{
// Setting resolved will serialize, so need this directory.
- fs::create_directory(ERRLOG_PERSIST_PATH);
+ fs::create_directories(paths::error());
- if (!fs::exists(ERRLOG_PERSIST_PATH))
+ if (!fs::exists(paths::error()))
{
- ADD_FAILURE() << "Could not create " << ERRLOG_PERSIST_PATH << "\n";
+ ADD_FAILURE() << "Could not create " << paths::error() << "\n";
exit(1);
}
@@ -50,7 +51,7 @@
std::srand(std::time(nullptr));
uint32_t id = std::rand();
- if (fs::exists(fs::path{ERRLOG_PERSIST_PATH} / std::to_string(id)))
+ if (fs::exists(fs::path{paths::error()} / std::to_string(id)))
{
std::cerr << "Another testcase is using ID " << id << "\n";
id = std::rand();
@@ -96,7 +97,7 @@
EXPECT_EQ(updateTS, elog.updateTimestamp());
// Leave the directory in case other CI instances are running
- fs::remove(fs::path{ERRLOG_PERSIST_PATH} / std::to_string(id));
+ fs::remove(fs::path{paths::error()} / std::to_string(id));
}
TEST(TestResolveProhibited, testResolveFlagChange)