AU: shift to use new TMPDIR-enabled temp file
The main change here is that delta generator will now create all
temporary files in TMPDIR, if set. Other than that, we're converting all
other temporary file/directory creation to use the new functions.
- All temps of the form "/tmp/foo" are converted to "foo": this
preserves the behavior in the default case (where TMPDIR is not set),
yet will do the right thing if run with a different TMPDIR.
- A few other cases (for example, temp file created relative to the
current working directory) will now be created in TMPDIR or /tmp.
These are all in unit tests and the transition makes sense anyway.
Note that two temp file/directory creation calls in actual UE code were
using "/tmp/..." and were not changed. This will ensure that they are
resilient to TMPDIR changes and will always be allocated in the same
(hard-coded) location.
BUG=chromium:253622
TEST=Unit tests.
Change-Id: Ia1208963a0e2fcd43b8d6f92bb3d1b7459e930a2
Reviewed-on: https://chromium-review.googlesource.com/182247
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/metadata_unittest.cc b/metadata_unittest.cc
index dc10a6e..096ea9f 100644
--- a/metadata_unittest.cc
+++ b/metadata_unittest.cc
@@ -31,9 +31,9 @@
TEST_F(MetadataTest, RunAsRootReadMetadataDissimilarFileSystems) {
string a_img, b_img;
- EXPECT_TRUE(utils::MakeTempFile("/tmp/a_img.XXXXXX", &a_img, NULL));
+ EXPECT_TRUE(utils::MakeTempFile("a_img.XXXXXX", &a_img, NULL));
ScopedPathUnlinker a_img_unlinker(a_img);
- EXPECT_TRUE(utils::MakeTempFile("/tmp/b_img.XXXXXX", &b_img, NULL));
+ EXPECT_TRUE(utils::MakeTempFile("b_img.XXXXXX", &b_img, NULL));
ScopedPathUnlinker b_img_unlinker(b_img);
CreateEmptyExtImageAtPath(a_img, 10485759, 4096);
@@ -65,11 +65,11 @@
TEST_F(MetadataTest, RunAsRootReadMetadata) {
string a_img, b_img, data_file;
- EXPECT_TRUE(utils::MakeTempFile("/tmp/a_img.XXXXXX", &a_img, NULL));
+ EXPECT_TRUE(utils::MakeTempFile("a_img.XXXXXX", &a_img, NULL));
ScopedPathUnlinker a_img_unlinker(a_img);
- EXPECT_TRUE(utils::MakeTempFile("/tmp/b_img.XXXXXX", &b_img, NULL));
+ EXPECT_TRUE(utils::MakeTempFile("b_img.XXXXXX", &b_img, NULL));
ScopedPathUnlinker b_img_unlinker(b_img);
- EXPECT_TRUE(utils::MakeTempFile("/tmp/data_file.XXXXXX", &data_file, NULL));
+ EXPECT_TRUE(utils::MakeTempFile("data_file.XXXXXX", &data_file, NULL));
ScopedPathUnlinker data_file_unlinker(data_file);
const size_t image_size = (256 * 1024 * 1024); // Enough for 2 block groups