unittest: Remove temporary directories.
The CreateExtImageAtPath() test helper function creates an image
and mounts it at a randomly genereted path directory. Nevertheless,
this function wasn't removing the created mount path at the end
since the mount path is a directory and not a regular file. This
was leaving a lot of empty temporary directories in /tmp and
printing the following error message during test:
[0808/211221:ERROR:utils.h(401)] Unable to unlink path /tmp/UpdateEngineTests_mnt-fymh70: Is a directory
This patch fixes that problem removing the directory when the
function exits.
BUG=None
TEST=unittest pass and doesn't print the mentioned error line.
Change-Id: Iec1d38b0fce437a3b5ecc26ae8c933b8ff1bba80
Reviewed-on: https://gerrit.chromium.org/gerrit/65286
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/test_utils.cc b/test_utils.cc
index b489cf1..d00f432 100644
--- a/test_utils.cc
+++ b/test_utils.cc
@@ -198,7 +198,7 @@
// create 10MiB sparse file, mounted at a unique location.
string mount_path;
CHECK(utils::MakeTempDirectory(kMountPathTemplate, &mount_path));
- ScopedPathUnlinker mount_path_unlinker(mount_path);
+ ScopedDirRemover mount_path_unlinker(mount_path);
EXPECT_EQ(0, System(StringPrintf("dd if=/dev/zero of=%s"
" seek=10485759 bs=1 count=1",