Fix race in KeepsMostRecentEvents.
The test may spawn threads that reference the global clock, so the code that resets the fake clock, needs to run when those threads have been stopped. Bug: webrtc:13947 Change-Id: I1f7dc921b7a8ff8e7e89e03e4397e635b67d77be Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258361 Reviewed-by: Björn Terelius <terelius@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36489}
This commit is contained in:
parent
137c2a8316
commit
093ce288fd
@ -904,6 +904,13 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) {
|
||||
std::make_unique<rtc::ScopedFakeClock>();
|
||||
fake_clock->SetTime(Timestamp::Seconds(kStartTimeSeconds));
|
||||
|
||||
// Create a scope for the TQ and event log factories.
|
||||
// This way, we make sure that task queue instances that may rely on a clock
|
||||
// have been torn down before we run the verification steps at the end of
|
||||
// the test.
|
||||
int64_t start_time_us, utc_start_time_us, stop_time_us;
|
||||
|
||||
{
|
||||
auto task_queue_factory = CreateDefaultTaskQueueFactory();
|
||||
RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get());
|
||||
// When `log` goes out of scope, the contents are flushed
|
||||
@ -922,13 +929,14 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) {
|
||||
i, kStartBitrate + i * 1000));
|
||||
fake_clock->AdvanceTime(TimeDelta::Millis(10));
|
||||
}
|
||||
int64_t start_time_us = rtc::TimeMicros();
|
||||
int64_t utc_start_time_us = rtc::TimeUTCMicros();
|
||||
start_time_us = rtc::TimeMicros();
|
||||
utc_start_time_us = rtc::TimeUTCMicros();
|
||||
log->StartLogging(log_output_factory_->Create(temp_filename),
|
||||
RtcEventLog::kImmediateOutput);
|
||||
fake_clock->AdvanceTime(TimeDelta::Millis(10));
|
||||
int64_t stop_time_us = rtc::TimeMicros();
|
||||
stop_time_us = rtc::TimeMicros();
|
||||
log->StopLogging();
|
||||
}
|
||||
|
||||
// Read the generated log from memory.
|
||||
ParsedRtcEventLog parsed_log;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user