aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Caruso <ejcaruso@chromium.org>2018-02-06 16:26:54 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-08 19:43:52 -0800
commitc1f7f7c6368b36b6632a9c353673f6a0f9b816bb (patch)
tree1cc97340571c9508d5f03bfa3224c3c7ae7f358f
parent48386c33c7caaf1015d7c4b15991ace455eb3fa2 (diff)
downloadplatform_external_libbrillo-c1f7f7c6368b36b6632a9c353673f6a0f9b816bb.tar.gz
platform_external_libbrillo-c1f7f7c6368b36b6632a9c353673f6a0f9b816bb.tar.bz2
platform_external_libbrillo-c1f7f7c6368b36b6632a9c353673f6a0f9b816bb.zip
libbrillo: use ScopedTempDir::GetPath
Upstream versions of libchrome have gotten rid of ScopedTempDir's inline path method because they wanted to introduce a DCHECK that helps make sure people create the temp directory before using it. To avoid introducing a header dependency on the logging header they took this method out of the header so it wouldn't be inlined. BUG=b:37434548 TEST=unit tests Change-Id: Ic83227a7ddbbad32a1df1f9554d29470c1a2dd42 Reviewed-on: https://chromium-review.googlesource.com/905784 Commit-Ready: Eric Caruso <ejcaruso@chromium.org> Tested-by: Eric Caruso <ejcaruso@chromium.org> Reviewed-by: Dan Erat <derat@chromium.org>
-rw-r--r--brillo/file_utils_unittest.cc8
-rw-r--r--brillo/http/http_form_data_unittest.cc10
-rw-r--r--brillo/key_value_store_unittest.cc5
-rw-r--r--brillo/osrelease_reader_unittest.cc12
-rw-r--r--brillo/process_unittest.cc4
-rw-r--r--brillo/streams/file_stream_unittest.cc20
-rw-r--r--policy/tests/policy_util_unittest.cc6
-rw-r--r--policy/tests/resilient_policy_util_unittest.cc12
8 files changed, 39 insertions, 38 deletions
diff --git a/brillo/file_utils_unittest.cc b/brillo/file_utils_unittest.cc
index 96c1fd7..7a730f0 100644
--- a/brillo/file_utils_unittest.cc
+++ b/brillo/file_utils_unittest.cc
@@ -37,7 +37,7 @@ class FileUtilsTest : public testing::Test {
public:
FileUtilsTest() {
CHECK(temp_dir_.CreateUniqueTempDir());
- file_path_ = temp_dir_.path().Append("test.temp");
+ file_path_ = temp_dir_.GetPath().Append("test.temp");
}
protected:
@@ -68,7 +68,7 @@ class FileUtilsTest : public testing::Test {
// Creates a file with a random name in the temporary directory.
base::FilePath GetTempName() {
- return temp_dir_.path().Append(GetRandomSuffix());
+ return temp_dir_.GetPath().Append(GetRandomSuffix());
}
};
@@ -87,7 +87,7 @@ TEST_F(FileUtilsTest, TouchFileCreateThroughUmask) {
}
TEST_F(FileUtilsTest, TouchFileCreateDirectoryStructure) {
- file_path_ = temp_dir_.path().Append("foo/bar/baz/test.temp");
+ file_path_ = temp_dir_.GetPath().Append("foo/bar/baz/test.temp");
EXPECT_TRUE(TouchFile(file_path_));
ExpectFileContains("");
}
@@ -106,7 +106,7 @@ TEST_F(FileUtilsTest, TouchFileReplaceDirectory) {
}
TEST_F(FileUtilsTest, TouchFileReplaceSymlink) {
- base::FilePath symlink_target = temp_dir_.path().Append("target.temp");
+ base::FilePath symlink_target = temp_dir_.GetPath().Append("target.temp");
EXPECT_TRUE(base::CreateSymbolicLink(symlink_target, file_path_));
EXPECT_TRUE(TouchFile(file_path_));
EXPECT_FALSE(base::IsLink(file_path_));
diff --git a/brillo/http/http_form_data_unittest.cc b/brillo/http/http_form_data_unittest.cc
index 842225d..34288d0 100644
--- a/brillo/http/http_form_data_unittest.cc
+++ b/brillo/http/http_form_data_unittest.cc
@@ -42,7 +42,7 @@ TEST(HttpFormData, FileFormField) {
base::ScopedTempDir dir;
ASSERT_TRUE(dir.CreateUniqueTempDir());
std::string file_content{"text line1\ntext line2\n"};
- base::FilePath file_name = dir.path().Append("sample.txt");
+ base::FilePath file_name = dir.GetPath().Append("sample.txt");
ASSERT_EQ(file_content.size(),
static_cast<size_t>(base::WriteFile(
file_name, file_content.data(), file_content.size())));
@@ -70,12 +70,12 @@ TEST(HttpFormData, MultiPartFormField) {
base::ScopedTempDir dir;
ASSERT_TRUE(dir.CreateUniqueTempDir());
std::string file1{"text line1\ntext line2\n"};
- base::FilePath filename1 = dir.path().Append("sample.txt");
+ base::FilePath filename1 = dir.GetPath().Append("sample.txt");
ASSERT_EQ(file1.size(),
static_cast<size_t>(
base::WriteFile(filename1, file1.data(), file1.size())));
std::string file2{"\x01\x02\x03\x04\x05"};
- base::FilePath filename2 = dir.path().Append("test.bin");
+ base::FilePath filename2 = dir.GetPath().Append("test.bin");
ASSERT_EQ(file2.size(),
static_cast<size_t>(
base::WriteFile(filename2, file2.data(), file2.size())));
@@ -145,12 +145,12 @@ TEST(HttpFormData, FormData) {
base::ScopedTempDir dir;
ASSERT_TRUE(dir.CreateUniqueTempDir());
std::string file1{"text line1\ntext line2\n"};
- base::FilePath filename1 = dir.path().Append("sample.txt");
+ base::FilePath filename1 = dir.GetPath().Append("sample.txt");
ASSERT_EQ(file1.size(),
static_cast<size_t>(
base::WriteFile(filename1, file1.data(), file1.size())));
std::string file2{"\x01\x02\x03\x04\x05"};
- base::FilePath filename2 = dir.path().Append("test.bin");
+ base::FilePath filename2 = dir.GetPath().Append("test.bin");
ASSERT_EQ(file2.size(),
static_cast<size_t>(
base::WriteFile(filename2, file2.data(), file2.size())));
diff --git a/brillo/key_value_store_unittest.cc b/brillo/key_value_store_unittest.cc
index cd18e89..68875ef 100644
--- a/brillo/key_value_store_unittest.cc
+++ b/brillo/key_value_store_unittest.cc
@@ -40,8 +40,9 @@ class KeyValueStoreTest : public ::testing::Test {
TEST_F(KeyValueStoreTest, LoadAndSaveFromFile) {
base::ScopedTempDir temp_dir_;
CHECK(temp_dir_.CreateUniqueTempDir());
- base::FilePath temp_file_ = temp_dir_.path().Append("temp.conf");
- base::FilePath saved_temp_file_ = temp_dir_.path().Append("saved_temp.conf");
+ base::FilePath temp_file_ = temp_dir_.GetPath().Append("temp.conf");
+ base::FilePath saved_temp_file_ =
+ temp_dir_.GetPath().Append("saved_temp.conf");
string blob = "A=B\n# Comment\n";
ASSERT_EQ(blob.size(), base::WriteFile(temp_file_, blob.data(), blob.size()));
diff --git a/brillo/osrelease_reader_unittest.cc b/brillo/osrelease_reader_unittest.cc
index 88185a0..9381367 100644
--- a/brillo/osrelease_reader_unittest.cc
+++ b/brillo/osrelease_reader_unittest.cc
@@ -16,8 +16,8 @@ class OsReleaseReaderTest : public ::testing::Test {
public:
void SetUp() override {
CHECK(temp_dir_.CreateUniqueTempDir());
- osreleased_ = temp_dir_.path().Append("etc").Append("os-release.d");
- osrelease_ = temp_dir_.path().Append("etc").Append("os-release");
+ osreleased_ = temp_dir_.GetPath().Append("etc").Append("os-release.d");
+ osrelease_ = temp_dir_.GetPath().Append("etc").Append("os-release");
base::CreateDirectory(osreleased_);
}
@@ -28,12 +28,12 @@ class OsReleaseReaderTest : public ::testing::Test {
};
TEST_F(OsReleaseReaderTest, MissingOsReleaseTest) {
- store_.LoadTestingOnly(temp_dir_.path());
+ store_.LoadTestingOnly(temp_dir_.GetPath());
}
TEST_F(OsReleaseReaderTest, MissingOsReleaseDTest) {
base::DeleteFile(osreleased_, true);
- store_.LoadTestingOnly(temp_dir_.path());
+ store_.LoadTestingOnly(temp_dir_.GetPath());
}
TEST_F(OsReleaseReaderTest, CompleteTest) {
@@ -46,7 +46,7 @@ TEST_F(OsReleaseReaderTest, CompleteTest) {
base::WriteFile(osreleased_.Append("GREETINGS"), ola.data(), ola.size());
base::WriteFile(osrelease_, osreleasecontent.data(), osreleasecontent.size());
- store_.LoadTestingOnly(temp_dir_.path());
+ store_.LoadTestingOnly(temp_dir_.GetPath());
string test_key_value;
ASSERT_TRUE(store_.GetString("TEST_KEY", &test_key_value));
@@ -80,7 +80,7 @@ TEST_F(OsReleaseReaderTest, NoNewLine) {
base::WriteFile(
osreleased_.Append("BONJOUR"), bonjour.data(), bonjour.size());
- store_.LoadTestingOnly(temp_dir_.path());
+ store_.LoadTestingOnly(temp_dir_.GetPath());
string hello_value;
string bonjour_value;
diff --git a/brillo/process_unittest.cc b/brillo/process_unittest.cc
index 2416e76..d980e2b 100644
--- a/brillo/process_unittest.cc
+++ b/brillo/process_unittest.cc
@@ -107,7 +107,7 @@ class ProcessTest : public ::testing::Test {
public:
void SetUp() {
CHECK(temp_dir_.CreateUniqueTempDir());
- output_file_ = temp_dir_.path().Append("fork_out").value();
+ output_file_ = temp_dir_.GetPath().Append("fork_out").value();
process_.RedirectOutput(output_file_);
ClearLog();
}
@@ -336,7 +336,7 @@ TEST_F(ProcessTest, ProcessExists) {
}
TEST_F(ProcessTest, ResetPidByFile) {
- FilePath pid_path = temp_dir_.path().Append("pid");
+ FilePath pid_path = temp_dir_.GetPath().Append("pid");
EXPECT_FALSE(process_.ResetPidByFile(pid_path.value()));
EXPECT_TRUE(base::WriteFile(pid_path, "456\n", 4));
EXPECT_TRUE(process_.ResetPidByFile(pid_path.value()));
diff --git a/brillo/streams/file_stream_unittest.cc b/brillo/streams/file_stream_unittest.cc
index 830d31c..ebbe551 100644
--- a/brillo/streams/file_stream_unittest.cc
+++ b/brillo/streams/file_stream_unittest.cc
@@ -703,7 +703,7 @@ TEST_F(FileStreamTest, CreateTemporary) {
TEST_F(FileStreamTest, OpenRead) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
std::vector<char> buffer(1024 * 1024);
base::RandBytes(buffer.data(), buffer.size());
int file_size = buffer.size(); // Stupid base::WriteFile taking "int" size.
@@ -731,7 +731,7 @@ TEST_F(FileStreamTest, OpenRead) {
TEST_F(FileStreamTest, OpenWrite) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
std::vector<char> buffer(1024 * 1024);
base::RandBytes(buffer.data(), buffer.size());
@@ -760,7 +760,7 @@ TEST_F(FileStreamTest, OpenWrite) {
TEST_F(FileStreamTest, Open_OpenExisting) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
std::string data{"Lorem ipsum dolor sit amet ..."};
int data_size = data.size(); // I hate ints for data size...
ASSERT_EQ(data_size, base::WriteFile(path, data.data(), data_size));
@@ -782,7 +782,7 @@ TEST_F(FileStreamTest, Open_OpenExisting) {
TEST_F(FileStreamTest, Open_OpenExisting_Fail) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
ErrorPtr error;
StreamPtr stream = FileStream::Open(path,
@@ -797,7 +797,7 @@ TEST_F(FileStreamTest, Open_OpenExisting_Fail) {
TEST_F(FileStreamTest, Open_CreateAlways_New) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
StreamPtr stream = FileStream::Open(path,
Stream::AccessMode::READ_WRITE,
@@ -816,7 +816,7 @@ TEST_F(FileStreamTest, Open_CreateAlways_New) {
TEST_F(FileStreamTest, Open_CreateAlways_Existing) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
std::string data{"Lorem ipsum dolor sit amet ..."};
int data_size = data.size(); // I hate ints for data size...
ASSERT_EQ(data_size, base::WriteFile(path, data.data(), data_size));
@@ -838,7 +838,7 @@ TEST_F(FileStreamTest, Open_CreateAlways_Existing) {
TEST_F(FileStreamTest, Open_CreateNewOnly_New) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
StreamPtr stream = FileStream::Open(path,
Stream::AccessMode::READ_WRITE,
@@ -857,7 +857,7 @@ TEST_F(FileStreamTest, Open_CreateNewOnly_New) {
TEST_F(FileStreamTest, Open_CreateNewOnly_Existing) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
std::string data{"Lorem ipsum dolor sit amet ..."};
int data_size = data.size(); // I hate ints for data size...
ASSERT_EQ(data_size, base::WriteFile(path, data.data(), data_size));
@@ -875,7 +875,7 @@ TEST_F(FileStreamTest, Open_CreateNewOnly_Existing) {
TEST_F(FileStreamTest, Open_TruncateExisting_New) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
ErrorPtr error;
StreamPtr stream = FileStream::Open(
@@ -891,7 +891,7 @@ TEST_F(FileStreamTest, Open_TruncateExisting_New) {
TEST_F(FileStreamTest, Open_TruncateExisting_Existing) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+ base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
std::string data{"Lorem ipsum dolor sit amet ..."};
int data_size = data.size(); // I hate ints for data size...
ASSERT_EQ(data_size, base::WriteFile(path, data.data(), data_size));
diff --git a/policy/tests/policy_util_unittest.cc b/policy/tests/policy_util_unittest.cc
index 74032d4..f26622f 100644
--- a/policy/tests/policy_util_unittest.cc
+++ b/policy/tests/policy_util_unittest.cc
@@ -20,9 +20,9 @@ TEST(DevicePolicyUtilTest, LoadPolicyFromPath) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath invalid_policy_data_path(temp_dir.path().Append("policy"));
- base::FilePath inexistent_file(temp_dir.path().Append("policy.1"));
- base::FilePath good_policy_data_path(temp_dir.path().Append("policy.2"));
+ base::FilePath invalid_policy_data_path(temp_dir.GetPath().Append("policy"));
+ base::FilePath inexistent_file(temp_dir.GetPath().Append("policy.1"));
+ base::FilePath good_policy_data_path(temp_dir.GetPath().Append("policy.2"));
// Create the file with invalid data.
std::string data = "invalid data";
diff --git a/policy/tests/resilient_policy_util_unittest.cc b/policy/tests/resilient_policy_util_unittest.cc
index e45ab34..0963b08 100644
--- a/policy/tests/resilient_policy_util_unittest.cc
+++ b/policy/tests/resilient_policy_util_unittest.cc
@@ -31,11 +31,11 @@ TEST(DevicePolicyUtilTest, GetSortedResilientPolicyFilePaths) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath file0(temp_dir.path().Append("policy"));
- base::FilePath file1(temp_dir.path().Append("policy.12"));
- base::FilePath file2(temp_dir.path().Append("policy.2"));
- base::FilePath file3(temp_dir.path().Append("policy.30"));
- base::FilePath invalid(temp_dir.path().Append("policy_4"));
+ base::FilePath file0(temp_dir.GetPath().Append("policy"));
+ base::FilePath file1(temp_dir.GetPath().Append("policy.12"));
+ base::FilePath file2(temp_dir.GetPath().Append("policy.2"));
+ base::FilePath file3(temp_dir.GetPath().Append("policy.30"));
+ base::FilePath invalid(temp_dir.GetPath().Append("policy_4"));
CreateFile(file0);
CreateFile(file1);
@@ -43,7 +43,7 @@ TEST(DevicePolicyUtilTest, GetSortedResilientPolicyFilePaths) {
CreateFile(file3);
const base::FilePath test_file_path(
- temp_dir.path().Append(kDefaultResilientPolicyFilePath));
+ temp_dir.GetPath().Append(kDefaultResilientPolicyFilePath));
std::map<int, base::FilePath> sorted_file_paths =
GetSortedResilientPolicyFilePaths(test_file_path);