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,31 +904,39 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) {
|
|||||||
std::make_unique<rtc::ScopedFakeClock>();
|
std::make_unique<rtc::ScopedFakeClock>();
|
||||||
fake_clock->SetTime(Timestamp::Seconds(kStartTimeSeconds));
|
fake_clock->SetTime(Timestamp::Seconds(kStartTimeSeconds));
|
||||||
|
|
||||||
auto task_queue_factory = CreateDefaultTaskQueueFactory();
|
// Create a scope for the TQ and event log factories.
|
||||||
RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get());
|
// This way, we make sure that task queue instances that may rely on a clock
|
||||||
// When `log` goes out of scope, the contents are flushed
|
// have been torn down before we run the verification steps at the end of
|
||||||
// to the output.
|
// the test.
|
||||||
std::unique_ptr<RtcEventLog> log =
|
int64_t start_time_us, utc_start_time_us, stop_time_us;
|
||||||
rtc_event_log_factory.CreateRtcEventLog(encoding_type_);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < kNumEvents; i++) {
|
{
|
||||||
// The purpose of the test is to verify that the log can handle
|
auto task_queue_factory = CreateDefaultTaskQueueFactory();
|
||||||
// more events than what fits in the internal circular buffer. The exact
|
RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get());
|
||||||
// type of events does not matter so we chose ProbeSuccess events for
|
// When `log` goes out of scope, the contents are flushed
|
||||||
// simplicity.
|
// to the output.
|
||||||
// We base the various values on the index. We use this for some basic
|
std::unique_ptr<RtcEventLog> log =
|
||||||
// consistency checks when we read back.
|
rtc_event_log_factory.CreateRtcEventLog(encoding_type_);
|
||||||
log->Log(std::make_unique<RtcEventProbeResultSuccess>(
|
|
||||||
i, kStartBitrate + i * 1000));
|
for (size_t i = 0; i < kNumEvents; i++) {
|
||||||
|
// The purpose of the test is to verify that the log can handle
|
||||||
|
// more events than what fits in the internal circular buffer. The exact
|
||||||
|
// type of events does not matter so we chose ProbeSuccess events for
|
||||||
|
// simplicity.
|
||||||
|
// We base the various values on the index. We use this for some basic
|
||||||
|
// consistency checks when we read back.
|
||||||
|
log->Log(std::make_unique<RtcEventProbeResultSuccess>(
|
||||||
|
i, kStartBitrate + i * 1000));
|
||||||
|
fake_clock->AdvanceTime(TimeDelta::Millis(10));
|
||||||
|
}
|
||||||
|
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));
|
fake_clock->AdvanceTime(TimeDelta::Millis(10));
|
||||||
|
stop_time_us = rtc::TimeMicros();
|
||||||
|
log->StopLogging();
|
||||||
}
|
}
|
||||||
int64_t start_time_us = rtc::TimeMicros();
|
|
||||||
int64_t 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();
|
|
||||||
log->StopLogging();
|
|
||||||
|
|
||||||
// Read the generated log from memory.
|
// Read the generated log from memory.
|
||||||
ParsedRtcEventLog parsed_log;
|
ParsedRtcEventLog parsed_log;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user