diff options
author | Amin Hassani <ahassani@chromium.org> | 2020-10-26 17:21:29 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-29 00:46:59 +0000 |
commit | ed03b44c7f9136d6491d7c238f1ab7b66c12456c (patch) | |
tree | f6a0adb7ea4d324cd6b1b4c1a06010a8004cc25c /payload_generator/ext2_filesystem_unittest.cc | |
parent | 5d56c1eef7fd730a164c44a742ef2cb0afcfca8d (diff) |
update_engine: Fix leaking unit tests
Some of the unit tests have been leaking temp files because they don't
properly unlink them. In this CL, we did some rearrangement of the
ScopedTempFile class and moved it into the utils.h (instead of testing
only location) so it can be used everywhere and more efficiently. Also
added functionality to open an file descriptor too so users don't have
to keep a different object for the file descriptor.
BUG=b:162766400
TEST=cros_workon_make --board reef --test; Then looked at the
/build/reef/tmp directory and no files were leaked.
Change-Id: Id64a2923d30f27628120497fdefe16bf65fa3fb0
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2500772
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Diffstat (limited to 'payload_generator/ext2_filesystem_unittest.cc')
-rw-r--r-- | payload_generator/ext2_filesystem_unittest.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/payload_generator/ext2_filesystem_unittest.cc b/payload_generator/ext2_filesystem_unittest.cc index 54600e90..88e15383 100644 --- a/payload_generator/ext2_filesystem_unittest.cc +++ b/payload_generator/ext2_filesystem_unittest.cc @@ -62,7 +62,7 @@ void ExpectBlocksInRange(const vector<Extent>& extents, uint64_t total_blocks) { class Ext2FilesystemTest : public ::testing::Test {}; TEST_F(Ext2FilesystemTest, InvalidFilesystem) { - test_utils::ScopedTempFile fs_filename_{"Ext2FilesystemTest-XXXXXX"}; + ScopedTempFile fs_filename_{"Ext2FilesystemTest-XXXXXX"}; ASSERT_EQ(0, truncate(fs_filename_.path().c_str(), kDefaultFilesystemSize)); unique_ptr<Ext2Filesystem> fs = Ext2Filesystem::CreateFromFile(fs_filename_.path()); |