Skip to content

Commit 34f8046

Browse files
committed
fix(test): Synchronize ranks before cleanup in VTK writer test
- Add MPI_Barrier before cleanup to prevent race conditions - Only rank 0 performs cleanup to avoid concurrent file deletion - Fixes vtk_writer_parallel test failure where rank 1's file was deleted by rank 0's cleanup before rank 1 could verify it Root cause: Both ranks run test fixture destructor independently, leading to concurrent cleanup. Rank 0 could delete all test_*.vti files while rank 1 was still checking if its file exists, causing the REQUIRE(fixture.file_exists(piece_filename)) assertion to fail.
1 parent f6183f1 commit 34f8046

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/unit/io/test_vtk_writer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ class VTKWriterTestFixture {
161161
* @brief Clean up all test files created during testing
162162
*/
163163
void cleanup_test_files() {
164+
// Synchronize all ranks before cleanup to avoid race conditions
165+
MPI_Barrier(MPI_COMM_WORLD);
166+
167+
// Only rank 0 performs cleanup to avoid race conditions
168+
if (m_rank != 0) return;
169+
164170
// Pattern: test_*.vti, test_*.pvti
165171
for (const auto &entry : std::filesystem::directory_iterator(".")) {
166172
if (entry.is_regular_file()) {

0 commit comments

Comments
 (0)