OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Unit tests for event trace consumer_ base class. | 5 // Unit tests for event trace consumer_ base class. |
6 #include "base/event_trace_consumer_win.h" | 6 #include "base/event_trace_consumer_win.h" |
7 #include <list> | 7 #include <list> |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/event_trace_controller_win.h" | 9 #include "base/event_trace_controller_win.h" |
10 #include "base/event_trace_provider_win.h" | 10 #include "base/event_trace_provider_win.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 ScopedHandle consumer_ready_; | 171 ScopedHandle consumer_ready_; |
172 ScopedHandle consumer_thread_; | 172 ScopedHandle consumer_thread_; |
173 }; | 173 }; |
174 } // namespace | 174 } // namespace |
175 | 175 |
176 TEST_F(EtwTraceConsumerRealtimeTest, ConsumerReturnsWhenSessionClosed) { | 176 TEST_F(EtwTraceConsumerRealtimeTest, ConsumerReturnsWhenSessionClosed) { |
177 EtwTraceController controller; | 177 EtwTraceController controller; |
178 | 178 |
179 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024); | 179 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024); |
180 if (hr == E_ACCESSDENIED) { | 180 if (hr == E_ACCESSDENIED) { |
181 LOG(INFO) << "You must be an administrator to run this test on Vista"; | 181 VLOG(1) << "You must be an administrator to run this test on Vista"; |
182 return; | 182 return; |
183 } | 183 } |
184 | 184 |
185 // Start the consumer_. | 185 // Start the consumer_. |
186 ASSERT_HRESULT_SUCCEEDED(StartConsumerThread()); | 186 ASSERT_HRESULT_SUCCEEDED(StartConsumerThread()); |
187 | 187 |
188 // Wait around for the consumer_ thread a bit. | 188 // Wait around for the consumer_ thread a bit. |
189 ASSERT_EQ(WAIT_TIMEOUT, ::WaitForSingleObject(consumer_thread_, 50)); | 189 ASSERT_EQ(WAIT_TIMEOUT, ::WaitForSingleObject(consumer_thread_, 50)); |
190 | 190 |
191 ASSERT_HRESULT_SUCCEEDED(controller.Stop(NULL)); | 191 ASSERT_HRESULT_SUCCEEDED(controller.Stop(NULL)); |
(...skipping 11 matching lines...) Expand all Loading... |
203 // {57E47923-A549-476f-86CA-503D57F59E62} | 203 // {57E47923-A549-476f-86CA-503D57F59E62} |
204 DEFINE_GUID(kTestEventType, | 204 DEFINE_GUID(kTestEventType, |
205 0x57e47923, 0xa549, 0x476f, 0x86, 0xca, 0x50, 0x3d, 0x57, 0xf5, 0x9e, 0x62); | 205 0x57e47923, 0xa549, 0x476f, 0x86, 0xca, 0x50, 0x3d, 0x57, 0xf5, 0x9e, 0x62); |
206 | 206 |
207 } // namespace | 207 } // namespace |
208 | 208 |
209 TEST_F(EtwTraceConsumerRealtimeTest, ConsumeEvent) { | 209 TEST_F(EtwTraceConsumerRealtimeTest, ConsumeEvent) { |
210 EtwTraceController controller; | 210 EtwTraceController controller; |
211 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024); | 211 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024); |
212 if (hr == E_ACCESSDENIED) { | 212 if (hr == E_ACCESSDENIED) { |
213 LOG(INFO) << "You must be an administrator to run this test on Vista"; | 213 VLOG(1) << "You must be an administrator to run this test on Vista"; |
214 return; | 214 return; |
215 } | 215 } |
216 | 216 |
217 ASSERT_HRESULT_SUCCEEDED(controller.EnableProvider(kTestProvider, | 217 ASSERT_HRESULT_SUCCEEDED(controller.EnableProvider(kTestProvider, |
218 TRACE_LEVEL_VERBOSE, 0xFFFFFFFF)); | 218 TRACE_LEVEL_VERBOSE, 0xFFFFFFFF)); |
219 | 219 |
220 EtwTraceProvider provider(kTestProvider); | 220 EtwTraceProvider provider(kTestProvider); |
221 ASSERT_EQ(ERROR_SUCCESS, provider.Register()); | 221 ASSERT_EQ(ERROR_SUCCESS, provider.Register()); |
222 | 222 |
223 // Start the consumer_. | 223 // Start the consumer_. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 TEST_F(EtwTraceConsumerDataTest, RoundTrip) { | 321 TEST_F(EtwTraceConsumerDataTest, RoundTrip) { |
322 EtwMofEvent<1> event(kTestEventType, 1, TRACE_LEVEL_ERROR); | 322 EtwMofEvent<1> event(kTestEventType, 1, TRACE_LEVEL_ERROR); |
323 | 323 |
324 static const char kData[] = "This is but test data"; | 324 static const char kData[] = "This is but test data"; |
325 event.fields[0].DataPtr = reinterpret_cast<ULONG64>(kData); | 325 event.fields[0].DataPtr = reinterpret_cast<ULONG64>(kData); |
326 event.fields[0].Length = sizeof(kData); | 326 event.fields[0].Length = sizeof(kData); |
327 | 327 |
328 PEVENT_TRACE trace = NULL; | 328 PEVENT_TRACE trace = NULL; |
329 HRESULT hr = RoundTripEvent(&event.header, &trace); | 329 HRESULT hr = RoundTripEvent(&event.header, &trace); |
330 if (hr == E_ACCESSDENIED) { | 330 if (hr == E_ACCESSDENIED) { |
331 LOG(INFO) << "You must be an administrator to run this test on Vista"; | 331 VLOG(1) << "You must be an administrator to run this test on Vista"; |
332 return; | 332 return; |
333 } | 333 } |
334 ASSERT_TRUE(NULL != trace); | 334 ASSERT_TRUE(NULL != trace); |
335 ASSERT_EQ(sizeof(kData), trace->MofLength); | 335 ASSERT_EQ(sizeof(kData), trace->MofLength); |
336 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); | 336 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); |
337 } | 337 } |
OLD | NEW |