Fix *ExtentWriterTest unittest.
These test were creating local files in the same directory where the
test is running from, which doesn't work on Android. This patch
leverages other newer temp file creation utilities that also take
care of removing the temp files.
Bug: 26955860
TEST=/data/nativetest/update_engine_unittests/update_engine_unittests --gtest_filter=*ExtentWriterTest.*
Change-Id: If5cd506ae0a7ca85b6fd5395a0982f00775836c7
diff --git a/common/test_utils.h b/common/test_utils.h
index b5151f2..7be027a 100644
--- a/common/test_utils.h
+++ b/common/test_utils.h
@@ -162,13 +162,15 @@
class ScopedTempFile {
public:
- ScopedTempFile() {
- EXPECT_TRUE(utils::MakeTempFile("update_engine_test_temp_file.XXXXXX",
- &path_,
- nullptr));
+ ScopedTempFile() : ScopedTempFile("update_engine_test_temp_file.XXXXXX") {}
+
+ explicit ScopedTempFile(const std::string& pattern) {
+ EXPECT_TRUE(utils::MakeTempFile(pattern, &path_, nullptr));
unlinker_.reset(new ScopedPathUnlinker(path_));
}
- const std::string& GetPath() { return path_; }
+
+ const std::string& path() { return path_; }
+
private:
std::string path_;
std::unique_ptr<ScopedPathUnlinker> unlinker_;