diff options
author | Bertrand SIMONNET <bsimonnet@chromium.org> | 2015-07-23 13:03:11 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-07-24 04:17:02 +0000 |
commit | e20603670f44d8b21874c1281ce82cd0f4bcc576 (patch) | |
tree | dcc7a922b3a4c0bacd9dc58f0b8114ffca05abf1 /chromeos | |
parent | 49066668ef3e2250d78ad3772b8c8d1e9fb7dcf0 (diff) | |
download | libbrillo-e20603670f44d8b21874c1281ce82cd0f4bcc576.tar.gz |
libchromeos: Don't use a local path in unittests.
Use ScopedUniqueTempDir instead so that the unittests can be run from
anywhere.
BUG=None
TEST=`FEATURES=test emerge-gizmo libchromeos --nodeps` works
Change-Id: Ic32473835c72e268ab04c025159c67f11f0f99b0
Reviewed-on: https://chromium-review.googlesource.com/287890
Trybot-Ready: Bertrand Simonnet <bsimonnet@chromium.org>
Tested-by: Bertrand Simonnet <bsimonnet@chromium.org>
Reviewed-by: Dan Erat <derat@chromium.org>
Commit-Queue: Bertrand Simonnet <bsimonnet@chromium.org>
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/process_test.cc | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/chromeos/process_test.cc b/chromeos/process_test.cc index 130f75e..61d3d6e 100644 --- a/chromeos/process_test.cc +++ b/chromeos/process_test.cc @@ -8,6 +8,7 @@ #include <base/files/file_path.h> #include <base/files/file_util.h> +#include <base/files/scoped_temp_dir.h> #include <gtest/gtest.h> #include "chromeos/process_mock.h" @@ -72,16 +73,12 @@ TEST(SimpleProcess, BindFd) { class ProcessTest : public ::testing::Test { public: void SetUp() { - test_path_ = FilePath("test"); - output_file_ = test_path_.Append("fork_out").value(); - base::DeleteFile(test_path_, true); - base::CreateDirectory(test_path_); + CHECK(temp_dir_.CreateUniqueTempDir()); + output_file_ = temp_dir_.path().Append("fork_out").value(); process_.RedirectOutput(output_file_); ClearLog(); } - void TearDown() { base::DeleteFile(test_path_, true); } - protected: void CheckStderrCaptured(); FilePath GetFdPath(int fd); @@ -89,7 +86,7 @@ class ProcessTest : public ::testing::Test { ProcessImpl process_; std::vector<const char*> args_; std::string output_file_; - FilePath test_path_; + base::ScopedTempDir temp_dir_; }; TEST_F(ProcessTest, Basic) { @@ -277,7 +274,7 @@ TEST_F(ProcessTest, ProcessExists) { } TEST_F(ProcessTest, ResetPidByFile) { - FilePath pid_path = test_path_.Append("pid"); + FilePath pid_path = temp_dir_.path().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())); |