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/payload_file_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/payload_file_unittest.cc')
-rw-r--r-- | payload_generator/payload_file_unittest.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/payload_generator/payload_file_unittest.cc b/payload_generator/payload_file_unittest.cc index 45faebb9..1fd36f52 100644 --- a/payload_generator/payload_file_unittest.cc +++ b/payload_generator/payload_file_unittest.cc @@ -36,7 +36,7 @@ class PayloadFileTest : public ::testing::Test { }; TEST_F(PayloadFileTest, ReorderBlobsTest) { - test_utils::ScopedTempFile orig_blobs("ReorderBlobsTest.orig.XXXXXX"); + ScopedTempFile orig_blobs("ReorderBlobsTest.orig.XXXXXX"); // The operations have three blob and one gap (the whitespace): // Rootfs operation 1: [8, 3] bcd @@ -45,7 +45,7 @@ TEST_F(PayloadFileTest, ReorderBlobsTest) { string orig_data = "kernel abcd"; EXPECT_TRUE(test_utils::WriteFileString(orig_blobs.path(), orig_data)); - test_utils::ScopedTempFile new_blobs("ReorderBlobsTest.new.XXXXXX"); + ScopedTempFile new_blobs("ReorderBlobsTest.new.XXXXXX"); payload_.part_vec_.resize(2); |