xref: /openbmc/phosphor-logging/test/openpower-pels/pel_paths.cpp (revision 40fb54935ce7367636a7156039396ee91cc4d5e2)
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: Copyright 2019 IBM Corporation
3 
4 #include "extensions/openpower-pels/paths.hpp"
5 
6 #include <filesystem>
7 
8 namespace openpower
9 {
10 namespace pels
11 {
12 
13 // Use paths that work in unit tests.
14 
getPELIDFile()15 std::filesystem::path getPELIDFile()
16 {
17     static std::string idFile;
18 
19     if (idFile.empty())
20     {
21         char templ[] = "/tmp/logidtestXXXXXX";
22         std::filesystem::path dir = mkdtemp(templ);
23         idFile = dir / "logid";
24     }
25     return idFile;
26 }
27 
getPELRepoPath()28 std::filesystem::path getPELRepoPath()
29 {
30     static std::string repoPath;
31 
32     if (repoPath.empty())
33     {
34         char templ[] = "/tmp/repopathtestXXXXXX";
35         std::filesystem::path dir = mkdtemp(templ);
36         repoPath = dir;
37     }
38     return repoPath;
39 }
40 
getPELReadOnlyDataPath()41 std::filesystem::path getPELReadOnlyDataPath()
42 {
43     static std::string dataPath;
44 
45     if (dataPath.empty())
46     {
47         char templ[] = "/tmp/pelrodatatestXXXXXX";
48         dataPath = mkdtemp(templ);
49     }
50 
51     return dataPath;
52 }
53 
getPELRepoSize()54 size_t getPELRepoSize()
55 {
56     // 100KB
57     return 100 * 1024;
58 }
59 
getMaxNumPELs()60 size_t getMaxNumPELs()
61 {
62     return 100;
63 }
64 
65 } // namespace pels
66 } // namespace openpower
67