1 /**
2  * Copyright © 2019 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "extensions/openpower-pels/paths.hpp"
17 
18 #include <filesystem>
19 
20 namespace openpower
21 {
22 namespace pels
23 {
24 
25 // Use paths that work in unit tests.
26 
27 std::filesystem::path getPELIDFile()
28 {
29     static std::string idFile;
30 
31     if (idFile.empty())
32     {
33         char templ[] = "/tmp/logidtestXXXXXX";
34         std::filesystem::path dir = mkdtemp(templ);
35         idFile = dir / "logid";
36     }
37     return idFile;
38 }
39 
40 std::filesystem::path getPELRepoPath()
41 {
42     static std::string repoPath;
43 
44     if (repoPath.empty())
45     {
46         char templ[] = "/tmp/repopathtestXXXXXX";
47         std::filesystem::path dir = mkdtemp(templ);
48         repoPath = dir;
49     }
50     return repoPath;
51 }
52 
53 std::filesystem::path getPELReadOnlyDataPath()
54 {
55     static std::string dataPath;
56 
57     if (dataPath.empty())
58     {
59         char templ[] = "/tmp/pelrodatatestXXXXXX";
60         dataPath = mkdtemp(templ);
61     }
62 
63     return dataPath;
64 }
65 
66 size_t getPELRepoSize()
67 {
68     // 100KB
69     return 100 * 1024;
70 }
71 
72 size_t getMaxNumPELs()
73 {
74     return 100;
75 }
76 
77 } // namespace pels
78 } // namespace openpower
79