Skip to content

Commit 78e030a

Browse files
committed
fix tests
1 parent bb91937 commit 78e030a

File tree

1 file changed

+49
-19
lines changed

1 file changed

+49
-19
lines changed

tests/unittests/PalTests.cpp

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,33 +147,63 @@ TEST_F(PalTests, SdkVersion)
147147
class LogInitTest : public Test
148148
{
149149
protected:
150-
const std::string validPath = "valid/path/";
150+
const std::string validPath = "valid/path/";
151151

152-
void SetUp() override
152+
void SetUp() override
153+
{
154+
// Create the valid path directory and any intermediate directories
155+
#if defined(_WIN32) || defined(_WIN64)
156+
if (CreateDirectoryA("valid", NULL) || GetLastError() == ERROR_ALREADY_EXISTS)
153157
{
154-
// Create the valid path directory
155-
#if defined(_WIN32) || defined(_WIN64)
156-
CreateDirectoryA(validPath.c_str(), NULL);
157-
#else
158-
mkdir(validPath.c_str(), 0777);
159-
#endif
158+
if (CreateDirectoryA(validPath.c_str(), NULL) || GetLastError() == ERROR_ALREADY_EXISTS)
159+
{
160+
std::cerr << "Directory created: " << validPath << std::endl;
161+
}
162+
else
163+
{
164+
std::cerr << "Error creating directory: " << validPath << std::endl;
165+
}
160166
}
161-
162-
void TearDown() override
167+
else
163168
{
164-
PAL::detail::log_done();
165-
if (!PAL::detail::getDebugLogPath().empty())
169+
std::cerr << "Error creating directory: valid" << std::endl;
170+
}
171+
#else
172+
if (mkdir("valid", 0777) == 0 || errno == EEXIST)
173+
{
174+
if (mkdir(validPath.c_str(), 0777) == 0 || errno == EEXIST)
175+
{
176+
std::cerr << "Directory created: " << validPath << std::endl;
177+
}
178+
else
166179
{
167-
std::remove(PAL::detail::getDebugLogPath().c_str());
180+
std::cerr << "Error creating directory: " << validPath << std::endl;
168181
}
182+
}
183+
else
184+
{
185+
std::cerr << "Error creating directory: valid" << std::endl;
186+
}
187+
#endif
188+
}
169189

170-
// Remove the valid path directory
171-
#if defined(_WIN32) || defined(_WIN64)
172-
RemoveDirectoryA(validPath.c_str());
173-
#else
174-
rmdir(validPath.c_str());
175-
#endif
190+
void TearDown() override
191+
{
192+
PAL::detail::log_done();
193+
if (!PAL::detail::getDebugLogPath().empty())
194+
{
195+
std::remove(PAL::detail::getDebugLogPath().c_str());
176196
}
197+
198+
// Remove the valid path directory
199+
#if defined(_WIN32) || defined(_WIN64)
200+
RemoveDirectoryA(validPath.c_str());
201+
RemoveDirectoryA("valid");
202+
#else
203+
rmdir(validPath.c_str());
204+
rmdir("valid");
205+
#endif
206+
}
177207
};
178208

179209
TEST_F(LogInitTest, LogInitDisabled)

0 commit comments

Comments
 (0)