summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-19 23:24:10 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-19 23:24:10 +0000
commit565758b5f9723fca2b71bb2dc411199d866042a6 (patch)
treed9eed038d75378994033c4cbbe0b915ea65caeb2
parent7e3449318db01c81b8f6674f67619b3fb01c11ad (diff)
downloadchromium_src-565758b5f9723fca2b71bb2dc411199d866042a6.zip
chromium_src-565758b5f9723fca2b71bb2dc411199d866042a6.tar.gz
chromium_src-565758b5f9723fca2b71bb2dc411199d866042a6.tar.bz2
Fix file leaks in a ETW test and a ScopedTempDir test.
BUG=none TEST=none Review URL: http://codereview.chromium.org/8972009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115036 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/scoped_temp_dir_unittest.cc7
-rw-r--r--base/win/event_trace_controller_unittest.cc8
2 files changed, 11 insertions, 4 deletions
diff --git a/base/scoped_temp_dir_unittest.cc b/base/scoped_temp_dir_unittest.cc
index 72e410f..eddea83 100644
--- a/base/scoped_temp_dir_unittest.cc
+++ b/base/scoped_temp_dir_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+
#include "base/file_util.h"
#include "base/platform_file.h"
#include "base/scoped_temp_dir.h"
@@ -60,8 +62,8 @@ TEST(ScopedTempDir, TempDir) {
TEST(ScopedTempDir, UniqueTempDirUnderPath) {
// Create a path which will contain a unique temp path.
FilePath base_path;
- file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("base_dir"),
- &base_path);
+ ASSERT_TRUE(file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("base_dir"),
+ &base_path));
FilePath test_path;
{
@@ -73,6 +75,7 @@ TEST(ScopedTempDir, UniqueTempDirUnderPath) {
EXPECT_TRUE(test_path.value().find(base_path.value()) != std::string::npos);
}
EXPECT_FALSE(file_util::DirectoryExists(test_path));
+ file_util::Delete(base_path, true);
}
TEST(ScopedTempDir, MultipleInvocations) {
diff --git a/base/win/event_trace_controller_unittest.cc b/base/win/event_trace_controller_unittest.cc
index 8eab40a..78969d8 100644
--- a/base/win/event_trace_controller_unittest.cc
+++ b/base/win/event_trace_controller_unittest.cc
@@ -9,6 +9,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/scoped_temp_dir.h"
#include "base/sys_info.h"
#include "base/win/event_trace_controller.h"
#include "base/win/event_trace_provider.h"
@@ -139,15 +140,17 @@ TEST(EtwTraceControllerTest, StartRealTimeSession) {
}
TEST(EtwTraceControllerTest, StartFileSession) {
+ ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
FilePath temp;
-
- ASSERT_HRESULT_SUCCEEDED(file_util::CreateTemporaryFile(&temp));
+ ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir.path(), &temp));
EtwTraceController controller;
HRESULT hr = controller.StartFileSession(kTestSessionName,
temp.value().c_str());
if (hr == E_ACCESSDENIED) {
VLOG(1) << "You must be an administrator to run this test on Vista";
+ file_util::Delete(temp, false);
return;
}
@@ -157,6 +160,7 @@ TEST(EtwTraceControllerTest, StartFileSession) {
EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL));
EXPECT_EQ(NULL, controller.session());
EXPECT_STREQ(L"", controller.session_name());
+ file_util::Delete(temp, false);
}
TEST(EtwTraceControllerTest, EnableDisable) {