Remove utils::MakeTempDirectory().
In favor of base::ScopedTempDir, except for PostinstallRunnerAction,
where the temp directory needs to be removed for every partition.
ScopedDirRemover is also removed because it's no longer used.
Test: ./update_engine_unittests
Test: cros_workon_make update_engine --test
Bug: 26955860
Change-Id: I954e6e892aff0cf9f8434a77408dc3c9eb64c1b5
diff --git a/fake_p2p_manager_configuration.h b/fake_p2p_manager_configuration.h
index 2f05ba3..1bc1dc8 100644
--- a/fake_p2p_manager_configuration.h
+++ b/fake_p2p_manager_configuration.h
@@ -17,17 +17,14 @@
#ifndef UPDATE_ENGINE_FAKE_P2P_MANAGER_CONFIGURATION_H_
#define UPDATE_ENGINE_FAKE_P2P_MANAGER_CONFIGURATION_H_
-#include "update_engine/common/test_utils.h"
-#include "update_engine/common/utils.h"
#include "update_engine/p2p_manager.h"
#include <string>
#include <vector>
-#include <base/files/file_util.h>
-#include <base/logging.h>
-#include <base/strings/string_number_conversions.h>
+#include <base/files/scoped_temp_dir.h>
#include <base/strings/string_util.h>
+#include <gtest/gtest.h>
namespace chromeos_update_engine {
@@ -36,19 +33,12 @@
class FakeP2PManagerConfiguration : public P2PManager::Configuration {
public:
FakeP2PManagerConfiguration() {
- EXPECT_TRUE(utils::MakeTempDirectory("p2p-tc.XXXXXX", &p2p_dir_));
- }
-
- ~FakeP2PManagerConfiguration() {
- if (p2p_dir_.size() > 0 &&
- !base::DeleteFile(base::FilePath(p2p_dir_), true)) {
- PLOG(ERROR) << "Unable to unlink files and directory in " << p2p_dir_;
- }
+ EXPECT_TRUE(p2p_dir_.CreateUniqueTempDir());
}
// P2PManager::Configuration override
base::FilePath GetP2PDir() override {
- return base::FilePath(p2p_dir_);
+ return p2p_dir_.path();
}
// P2PManager::Configuration override
@@ -95,7 +85,7 @@
private:
// The temporary directory used for p2p.
- std::string p2p_dir_;
+ base::ScopedTempDir p2p_dir_;
// Argument vector for starting p2p.
std::vector<std::string> initctl_start_args_{"initctl", "start", "p2p"};