vpn-manager: Use a different temporary directory for each unit test.
The CL modifies each unit test to use a different temporary directory to
prevent race conditions when unit tests run concurrently.
BUG=chromium-os:33867
TEST=cros_run_unit_tests -p vpn-manager
Change-Id: I5b0b66b4795d14422ea4861411cd8f220103614e
Reviewed-on: https://gerrit.chromium.org/gerrit/32904
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
diff --git a/ipsec_manager_test.cc b/ipsec_manager_test.cc
index c95d7e3..89ca003 100644
--- a/ipsec_manager_test.cc
+++ b/ipsec_manager_test.cc
@@ -28,7 +28,7 @@
void SetUp() {
FilePath cwd;
file_util::GetCurrentDirectory(&cwd);
- test_path_ = cwd.Append("test");
+ test_path_ = cwd.Append("ipsec_manager_testdir");
file_util::Delete(test_path_, true);
file_util::CreateDirectory(test_path_);
stateful_container_ = test_path_.Append("etc");
diff --git a/l2tp_manager_test.cc b/l2tp_manager_test.cc
index dc7de35..60bd345 100644
--- a/l2tp_manager_test.cc
+++ b/l2tp_manager_test.cc
@@ -27,7 +27,7 @@
class L2tpManagerTest : public ::testing::Test {
public:
void SetUp() {
- test_path_ = FilePath("test");
+ test_path_ = FilePath("l2tp_manager_testdir");
ServiceManager::temp_path_ = new FilePath(test_path_);
file_util::Delete(test_path_, true);
file_util::CreateDirectory(test_path_);
@@ -70,9 +70,11 @@
"require authentication = yes\n"
"name = me\n"
"%s"
- "pppoptfile = test/pppd.config\n"
- "length bit = yes\n", remote_address_text.c_str(),
- debug ? "ppp debug = yes\n" : "");
+ "pppoptfile = %s/pppd.config\n"
+ "length bit = yes\n",
+ remote_address_text.c_str(),
+ debug ? "ppp debug = yes\n" : "",
+ test_path_.value().c_str());
}
TEST_F(L2tpManagerTest, FormatL2tpdConfiguration) {
@@ -144,9 +146,9 @@
EXPECT_CALL(*l2tpd_, Reset(0));
EXPECT_CALL(*l2tpd_, AddArg(L2TPD));
EXPECT_CALL(*l2tpd_, AddArg("-c"));
- EXPECT_CALL(*l2tpd_, AddArg("test/l2tpd.conf"));
+ EXPECT_CALL(*l2tpd_, AddArg(test_path_.value() + "/l2tpd.conf"));
EXPECT_CALL(*l2tpd_, AddArg("-C"));
- EXPECT_CALL(*l2tpd_, AddArg("test/l2tpd.control"));
+ EXPECT_CALL(*l2tpd_, AddArg(test_path_.value() + "/l2tpd.control"));
EXPECT_CALL(*l2tpd_, AddArg("-D"));
EXPECT_CALL(*l2tpd_, RedirectUsingPipe(STDERR_FILENO, false));
EXPECT_CALL(*l2tpd_, Start());
diff --git a/service_manager_test.cc b/service_manager_test.cc
index c752ca4..3b5587b 100644
--- a/service_manager_test.cc
+++ b/service_manager_test.cc
@@ -32,7 +32,7 @@
class ServiceManagerTest : public ::testing::Test {
public:
void SetUp() {
- test_path_ = FilePath("test");
+ test_path_ = FilePath("service_manager_testdir");
file_util::Delete(test_path_, true);
file_util::CreateDirectory(test_path_);
temp_path_ = test_path_.Append("service");