Skip to content

Commit 8ef9b54

Browse files
committed
utl: update the TestCFileUtils to the new tmp_file_name generation
Signed-off-by: osamahammad21 <[email protected]>
1 parent 0bb5531 commit 8ef9b54

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/utl/test/cpp/TestCFileUtils.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ TEST(Utl, stream_handler_write_and_read_gzip)
161161
TEST(Utl, stream_handler_temp_file_handling)
162162
{
163163
const char* filename = "test_temp_file_handling.txt";
164-
std::string tmp_filename = std::string(filename) + ".1";
164+
const auto pid = static_cast<unsigned int>(::getpid());
165+
std::string tmp_filename
166+
= std::string(filename) + "." + std::to_string(pid) + ".1";
165167

166168
// Check that the temp file is created
167169
{
@@ -184,7 +186,9 @@ TEST(Utl, stream_handler_exception_handling)
184186
OutStreamHandler sh(filename);
185187
throw std::runtime_error("Simulated exception");
186188
} catch (...) {
187-
std::string tmp_filename = std::string(filename) + ".1";
189+
auto pid = static_cast<unsigned int>(::getpid());
190+
std::string tmp_filename
191+
= std::string(filename) + "." + std::to_string(pid) + ".1";
188192
// Ensure temporary file is cleaned up
189193
EXPECT_TRUE(!std::filesystem::exists(tmp_filename));
190194
// Original file should exist
@@ -214,7 +218,9 @@ TEST(Utl, file_handler_write_and_read)
214218
TEST(Utl, file_handler_temp_file_handling)
215219
{
216220
const char* filename = "test_temp_file_handling_file.txt";
217-
std::string tmp_filename = std::string(filename) + ".1";
221+
const auto pid = static_cast<unsigned int>(::getpid());
222+
std::string tmp_filename
223+
= std::string(filename) + "." + std::to_string(pid) + ".1";
218224

219225
// Check that the temp file is created
220226
{

0 commit comments

Comments
 (0)