Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: syzygy/integration_tests/instrument_integration_test.cc

Issue 2993173002: Fix an ownership issue in ScopedAgentLogger (Closed)
Patch Set: Fix an ownership issue in ScopedAgentLogger Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Google Inc. All Rights Reserved. 1 // Copyright 2013 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // and getting the contents of its log file. Not thread safe. 89 // and getting the contents of its log file. Not thread safe.
90 struct ScopedAgentLogger { 90 struct ScopedAgentLogger {
91 explicit ScopedAgentLogger(base::FilePath temp_dir) 91 explicit ScopedAgentLogger(base::FilePath temp_dir)
92 : nul_(NULL), temp_dir_(temp_dir) { 92 : nul_(NULL), temp_dir_(temp_dir) {
93 agent_logger_ = testing::GetOutputRelativePath( 93 agent_logger_ = testing::GetOutputRelativePath(
94 L"agent_logger.exe"); 94 L"agent_logger.exe");
95 instance_id_ = base::StringPrintf("integra%08X", ::GetCurrentProcessId()); 95 instance_id_ = base::StringPrintf("integra%08X", ::GetCurrentProcessId());
96 } 96 }
97 97
98 ~ScopedAgentLogger() { 98 ~ScopedAgentLogger() {
99 // Clean up the temp directory if we created one.
100 if (!temp_dir_.empty())
101 base::DeleteFile(temp_dir_, true);
102
103 if (nul_) { 99 if (nul_) {
104 ::CloseHandle(nul_); 100 ::CloseHandle(nul_);
105 nul_ = NULL; 101 nul_ = NULL;
106 } 102 }
107 } 103 }
108 104
109 void RunAction(const char* action, base::Process* process) { 105 void RunAction(const char* action, base::Process* process) {
110 DCHECK_NE(static_cast<const char*>(nullptr), action); 106 DCHECK_NE(static_cast<const char*>(nullptr), action);
111 DCHECK_NE(static_cast<base::Process*>(nullptr), process); 107 DCHECK_NE(static_cast<base::Process*>(nullptr), process);
112 108
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 157
162 void GetLog(std::string* log) { 158 void GetLog(std::string* log) {
163 DCHECK_NE(static_cast<std::string*>(nullptr), log); 159 DCHECK_NE(static_cast<std::string*>(nullptr), log);
164 *log = log_contents_; 160 *log = log_contents_;
165 } 161 }
166 162
167 // Initialized at construction. 163 // Initialized at construction.
168 base::FilePath agent_logger_; 164 base::FilePath agent_logger_;
169 std::string instance_id_; 165 std::string instance_id_;
170 166
167 // The temp directory used by this logger. This is owned by the object that
168 // owns this logger.
169 base::FilePath temp_dir_;
170
171 // Modified by Start and Stop. 171 // Modified by Start and Stop.
172 base::FilePath temp_dir_;
173 base::FilePath log_file_; 172 base::FilePath log_file_;
174 base::Process process_; 173 base::Process process_;
175 HANDLE nul_; 174 HANDLE nul_;
176 175
177 // Modified by Stop. 176 // Modified by Stop.
178 std::string log_contents_; 177 std::string log_contents_;
179 }; 178 };
180 179
181 enum AccessMode { 180 enum AccessMode {
182 ASAN_READ_ACCESS = agent::asan::ASAN_READ_ACCESS, 181 ASAN_READ_ACCESS = agent::asan::ASAN_READ_ACCESS,
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 1759
1761 TEST_F(InstrumentAppIntegrationTest, DeferredFreeTLS) { 1760 TEST_F(InstrumentAppIntegrationTest, DeferredFreeTLS) {
1762 ASSERT_NO_FATAL_FAILURE(StartService()); 1761 ASSERT_NO_FATAL_FAILURE(StartService());
1763 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1762 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1764 ASSERT_EQ(0, InvokeTestDllFunction(testing::kAsanDeferredFreeTLS)); 1763 ASSERT_EQ(0, InvokeTestDllFunction(testing::kAsanDeferredFreeTLS));
1765 ASSERT_NO_FATAL_FAILURE(UnloadDll()); 1764 ASSERT_NO_FATAL_FAILURE(UnloadDll());
1766 ASSERT_NO_FATAL_FAILURE(StopService()); 1765 ASSERT_NO_FATAL_FAILURE(StopService());
1767 } 1766 }
1768 1767
1769 } // namespace integration_tests 1768 } // namespace integration_tests
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698