Merge "fiemap_writer_test: add block truncation and sync for safety" into main

This commit is contained in:
Jaegeuk Kim 2024-10-07 17:04:08 +00:00 committed by Gerrit Code Review
commit 7179bd1a02
2 changed files with 8 additions and 1 deletions

View file

@ -66,7 +66,11 @@ class FiemapWriterTest : public ::testing::Test {
testfile = gTestDir + "/"s + tinfo->name();
}
void TearDown() override { unlink(testfile.c_str()); }
void TearDown() override {
truncate(testfile.c_str(), 0);
unlink(testfile.c_str());
sync();
}
// name of the file we use for testing
std::string testfile;

View file

@ -196,10 +196,13 @@ bool SplitFiemap::RemoveSplitFiles(const std::string& file_path, std::string* me
if (access(file.c_str(), F_OK) != 0 && (errno == ENOENT || errno == ENAMETOOLONG)) {
continue;
}
truncate(file.c_str(), 0);
ok &= android::base::RemoveFileIfExists(file, message);
}
}
truncate(file_path.c_str(), 0);
ok &= android::base::RemoveFileIfExists(file_path, message);
sync();
return ok;
}