@@ -147,63 +147,37 @@ TEST_F(PalTests, SdkVersion)
147147class 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
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)
157- {
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- }
166- }
167- else
152+ void SetUp () override
168153 {
169- std::cerr << " Error creating directory: valid" << std::endl;
154+ // Create the valid path directory and any intermediate directories
155+ #if defined(_WIN32) || defined(_WIN64)
156+ CreateDirectoryA (" valid" , NULL );
157+ CreateDirectoryA (validPath.c_str (), NULL );
158+ #else
159+ mkdir (" valid" , 0777 );
160+ mkdir (validPath.c_str (), 0777 );
161+ #endif
170162 }
171- # else
172- if ( mkdir ( " valid " , 0777 ) == 0 || errno == EEXIST)
163+
164+ void TearDown () override
173165 {
174- if (mkdir (validPath.c_str (), 0777 ) == 0 || errno == EEXIST)
175- {
176- std::cerr << " Directory created: " << validPath << std::endl;
177- }
178- else
166+ PAL::detail::log_done ();
167+ if (!PAL::detail::getDebugLogPath ().empty ())
179168 {
180- std::cerr << " Error creating directory: " << validPath << std::endl ;
169+ std::remove ( PAL::detail::getDebugLogPath (). c_str ()) ;
181170 }
182- }
183- else
184- {
185- std::cerr << " Error creating directory: valid" << std::endl;
186- }
187- #endif
188- }
189171
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 ());
172+ // Remove the valid path directory
173+ #if defined(_WIN32) || defined(_WIN64)
174+ RemoveDirectoryA (validPath.c_str ());
175+ RemoveDirectoryA (" valid" );
176+ #else
177+ rmdir (validPath.c_str ());
178+ rmdir (" valid" );
179+ #endif
196180 }
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- }
207181};
208182
209183TEST_F (LogInitTest, LogInitDisabled)
@@ -243,8 +217,13 @@ TEST_F(LogInitTest, LogInitPathWithoutTrailingSlash)
243217
244218TEST_F (LogInitTest, LogInitPathWithoutTrailingBackslash)
245219{
220+ #if defined(_WIN32) || defined(_WIN64)
246221 std::string pathWithoutBackslash = " valid\\ path" ;
222+ #else
223+ std::string pathWithoutBackslash = " valid//path" ;
224+ #endif
247225 EXPECT_TRUE (PAL::detail::log_init (true , pathWithoutBackslash));
248226 EXPECT_TRUE (PAL::detail::getDebugLogStream ()->is_open ());
249227}
228+
250229#endif
0 commit comments