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