Skip to content

Commit

Permalink
Check status code for removeFile() across unit tests; remove errno de…
Browse files Browse the repository at this point in the history
…bugging
  • Loading branch information
bmhan12 committed Sep 25, 2024
1 parent 1964ae6 commit b06225f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/axom/mint/tests/mint_su2_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ TEST(mint_su2_io, write_read_mixed_cell_topology_mesh)

// cleanup
delete test_mesh;
axom::utilities::filesystem::removeFile(su2File);
EXPECT_EQ(axom::utilities::filesystem::removeFile(su2File), 0);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -212,7 +212,7 @@ TEST(mint_su2_io, write_read_single_cell_topology_mesh)

// cleanup
delete test_mesh;
axom::utilities::filesystem::removeFile(su2File);
EXPECT_EQ(axom::utilities::filesystem::removeFile(su2File), 0);
}

//------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/axom/mint/tests/mint_util_write_vtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ void test_mesh(MeshType* mesh, const std::string& path)
file.close();
delete mesh;
#if DELETE_VTK_FILES
axom::utilities::filesystem::removeFile(path);
EXPECT_EQ(axom::utilities::filesystem::removeFile(path), 0);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/axom/quest/tests/quest_intersection_shaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void IntersectionWithErrorTolerances(const std::string &filebase,
// Clean up files.
for(const auto &filename : filenames)
{
axom::utilities::filesystem::removeFile(filename);
EXPECT_EQ(axom::utilities::filesystem::removeFile(filename), 0);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/axom/quest/tests/quest_pro_e_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ TEST(quest_pro_e_reader, read_to_invalid_mesh)
EXPECT_DEATH_IF_SUPPORTED(reader.getMesh(&hexmesh), IGNORE_OUTPUT);

// STEP 4: remove Pro/E file
axom::utilities::filesystem::removeFile(filename);
EXPECT_EQ(axom::utilities::filesystem::removeFile(filename), 0);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -143,7 +143,7 @@ TEST(quest_pro_e_reader, read_pro_e)
} // END for all nodes

// STEP 4: remove temporary Pro/E file
axom::utilities::filesystem::removeFile(filename);
EXPECT_EQ(axom::utilities::filesystem::removeFile(filename), 0);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -197,7 +197,7 @@ TEST(quest_pro_e_reader, read_pro_e_invbbox)
} // END for all nodes

// STEP 4: remove temporary Pro/E file
axom::utilities::filesystem::removeFile(filename);
EXPECT_EQ(axom::utilities::filesystem::removeFile(filename), 0);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -253,7 +253,7 @@ TEST(quest_pro_e_reader, read_pro_e_bbox_all)
} // END for all nodes

// STEP 4: remove temporary Pro/E file
axom::utilities::filesystem::removeFile(filename);
EXPECT_EQ(axom::utilities::filesystem::removeFile(filename), 0);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -310,7 +310,7 @@ TEST(quest_pro_e_reader, read_pro_e_bbox_some)
} // END for all nodes

// STEP 4: remove temporary Pro/E file
axom::utilities::filesystem::removeFile(filename);
EXPECT_EQ(axom::utilities::filesystem::removeFile(filename), 0);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -367,7 +367,7 @@ TEST(quest_pro_e_reader, read_pro_e_bbox_some_incl)
} // END for all nodes

// STEP 4: remove temporary Pro/E file
axom::utilities::filesystem::removeFile(filename);
EXPECT_EQ(axom::utilities::filesystem::removeFile(filename), 0);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -426,7 +426,7 @@ TEST(quest_pro_e_reader, read_pro_e_external)
} // END for all nodes

// STEP 4: remove temporary Pro/E file
axom::utilities::filesystem::removeFile(filename);
EXPECT_EQ(axom::utilities::filesystem::removeFile(filename), 0);
}

#ifdef AXOM_DATA_DIR
Expand Down
2 changes: 1 addition & 1 deletion src/axom/quest/tests/quest_sampling_shaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ScopedTemporaryFile

~ScopedTemporaryFile()
{
axom::utilities::filesystem::removeFile(m_filename);
EXPECT_EQ(axom::utilities::filesystem::removeFile(m_filename), 0);
}

const std::string& getFileName() const { return m_filename; }
Expand Down
4 changes: 2 additions & 2 deletions src/axom/quest/tests/quest_signed_distance_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void check_analytic_plane(bool use_shared = false)
EXPECT_FALSE(quest::signed_distance_initialized());

#ifdef REMOVE_FILES
axom::utilities::filesystem::removeFile(file);
EXPECT_EQ(axom::utilities::filesystem::removeFile(file), 0);
#endif
}

Expand Down Expand Up @@ -373,7 +373,7 @@ TEST(quest_signed_distance_interface, initialize)

// remove temp STL file
#ifdef REMOVE_FILES
axom::utilities::filesystem::removeFile(fileName);
EXPECT_EQ(axom::utilities::filesystem::removeFile(fileName), 0);
#endif
}

Expand Down
16 changes: 1 addition & 15 deletions src/axom/quest/tests/quest_stl_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include <string>
#include <fstream>

#include <errno.h>

// namespace aliases
namespace mint = axom::mint;
namespace quest = axom::quest;
Expand Down Expand Up @@ -84,19 +82,7 @@ TEST(quest_stl_reader_DeathTest, read_to_invalid_mesh)
EXPECT_DEATH_IF_SUPPORTED(reader.getMesh(&hexmesh), IGNORE_OUTPUT);

// STEP 4: remove STL file
int return_code = axom::utilities::filesystem::removeFile(filename);
if(return_code == -1)
{
SLIC_INFO(
"########################### quest_stl_reader.cpp errno value is: "
<< strerror(errno) << " ###############################");
}
else
{
SLIC_INFO(
"########################### quest_stl_reader.cpp removeFile succeeded! "
<< " ###############################");
}
EXPECT_EQ(axom::utilities::filesystem::removeFile(filename), 0);
}

//------------------------------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions src/axom/slic/tests/slic_macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ TEST(slic_macros, test_macros_file_output)
EXPECT_FALSE(no_fmt_contents.is_open());
EXPECT_FALSE(with_fmt_contents.is_open());

// Closes open file streams associated with Slic streams when deconstructors
// called during slic::finalize().
// Windows _unlink file deletion fails if file is still in use.
#ifdef WIN32
slic::finalize();
#endif
// Closes open file streams associated with Slic streams when deconstructors
// called during slic::finalize().
// Windows _unlink file deletion fails if file is still in use.
#ifdef WIN32
slic::finalize();
#endif

// Cleanup generated files (not working Windows)
int ret_code = axom::utilities::filesystem::removeFile(no_fmt);
Expand Down
7 changes: 7 additions & 0 deletions src/axom/slic/tests/slic_macros_parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,13 @@ TEST_P(SlicMacrosParallel, test_macros_file_output)
EXPECT_EQ(with_fmt_out_buf.str(), "Test outputLocalMessages()");
}

// Closes open file streams associated with Slic streams when deconstructors
// called during slic::finalize().
// Windows _unlink file deletion fails if file is still in use.
#ifdef WIN32
slic::finalize();
#endif

// Cleanup generated files
EXPECT_EQ(axom::utilities::filesystem::removeFile(no_fmt), 0);
EXPECT_EQ(axom::utilities::filesystem::removeFile(with_fmt), 0);
Expand Down

0 comments on commit b06225f

Please sign in to comment.