Revert "Using simulated rtc::Thread for peer connection scenario tests."
This reverts commit b70c5c5ce97e7dcf2e1d8453f5ea0639d4b60453. Reason for revert: Interferes with other tests in same binary. Original change's description: > Using simulated rtc::Thread for peer connection scenario tests. > > Bug: webrtc:11255 > Change-Id: I5d29e997a7209ffc64595082358cca9b2115d07a > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165689 > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30258} TBR=steveanton@webrtc.org,srte@webrtc.org Change-Id: If2e60edae264a4bb0dee3abf66ba2078fd85f493 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:11255 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166045 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30259}
This commit is contained in:
committed by
Commit Bot
parent
b70c5c5ce9
commit
f1173f46e5
@ -20,8 +20,6 @@ if (rtc_include_tests) {
|
||||
"simulated_process_thread.h",
|
||||
"simulated_task_queue.cc",
|
||||
"simulated_task_queue.h",
|
||||
"simulated_thread.cc",
|
||||
"simulated_thread.h",
|
||||
"simulated_time_controller.cc",
|
||||
"simulated_time_controller.h",
|
||||
]
|
||||
@ -35,7 +33,6 @@ if (rtc_include_tests) {
|
||||
"../../modules:module_api",
|
||||
"../../modules/utility:utility",
|
||||
"../../rtc_base",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_tests_utils",
|
||||
"../../rtc_base:rtc_event",
|
||||
"../../rtc_base/synchronization:sequence_checker",
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#include "api/units/timestamp.h"
|
||||
#include "modules/include/module.h"
|
||||
#include "modules/utility/include/process_thread.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/synchronization/yield_policy.h"
|
||||
#include "test/time_controller/simulated_time_controller.h"
|
||||
|
||||
@ -185,13 +184,6 @@ void ExternalTimeController::AdvanceTime(TimeDelta duration) {
|
||||
alarm_->Sleep(duration);
|
||||
}
|
||||
|
||||
std::unique_ptr<rtc::Thread> ExternalTimeController::CreateThread(
|
||||
const std::string& name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server) {
|
||||
RTC_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<TaskQueueBase, TaskQueueDeleter>
|
||||
ExternalTimeController::CreateTaskQueue(
|
||||
absl::string_view name,
|
||||
|
||||
@ -38,9 +38,6 @@ class ExternalTimeController : public TimeController, public TaskQueueFactory {
|
||||
std::unique_ptr<ProcessThread> CreateProcessThread(
|
||||
const char* thread_name) override;
|
||||
void AdvanceTime(TimeDelta duration) override;
|
||||
std::unique_ptr<rtc::Thread> CreateThread(
|
||||
const std::string& name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server) override;
|
||||
|
||||
// Implementation of TaskQueueFactory.
|
||||
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> CreateTaskQueue(
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include "test/time_controller/real_time_controller.h"
|
||||
|
||||
#include "api/task_queue/default_task_queue_factory.h"
|
||||
#include "rtc_base/null_socket_server.h"
|
||||
#include "system_wrappers/include/sleep.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -31,17 +30,6 @@ std::unique_ptr<ProcessThread> RealTimeController::CreateProcessThread(
|
||||
return ProcessThread::Create(thread_name);
|
||||
}
|
||||
|
||||
std::unique_ptr<rtc::Thread> RealTimeController::CreateThread(
|
||||
const std::string& name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server) {
|
||||
if (!socket_server)
|
||||
socket_server = std::make_unique<rtc::NullSocketServer>();
|
||||
auto res = std::make_unique<rtc::Thread>(std::move(socket_server));
|
||||
res->SetName(name, nullptr);
|
||||
res->Start();
|
||||
return res;
|
||||
}
|
||||
|
||||
void RealTimeController::AdvanceTime(TimeDelta duration) {
|
||||
SleepMs(duration.ms());
|
||||
}
|
||||
|
||||
@ -28,9 +28,6 @@ class RealTimeController : public TimeController {
|
||||
TaskQueueFactory* GetTaskQueueFactory() override;
|
||||
std::unique_ptr<ProcessThread> CreateProcessThread(
|
||||
const char* thread_name) override;
|
||||
std::unique_ptr<rtc::Thread> CreateThread(
|
||||
const std::string& name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server) override;
|
||||
void AdvanceTime(TimeDelta duration) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "test/time_controller/simulated_thread.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "rtc_base/task_utils/to_queued_task.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
// A socket server that does nothing. It's different from NullSocketServer in
|
||||
// that it does allow sleep/wakeup. This avoids usage of an Event instance which
|
||||
// otherwise would cause issues with the simulated Yeild behavior.
|
||||
class DummySocketServer : public rtc::SocketServer {
|
||||
public:
|
||||
rtc::Socket* CreateSocket(int family, int type) override {
|
||||
RTC_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
rtc::AsyncSocket* CreateAsyncSocket(int family, int type) override {
|
||||
RTC_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
bool Wait(int cms, bool process_io) override {
|
||||
RTC_CHECK_EQ(cms, 0);
|
||||
return true;
|
||||
}
|
||||
void WakeUp() override {}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
SimulatedThread::SimulatedThread(
|
||||
sim_time_impl::SimulatedTimeControllerImpl* handler,
|
||||
absl::string_view name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server)
|
||||
: rtc::Thread(socket_server ? std::move(socket_server)
|
||||
: std::make_unique<DummySocketServer>()),
|
||||
handler_(handler),
|
||||
name_(new char[name.size()]) {
|
||||
std::copy_n(name.begin(), name.size(), name_);
|
||||
}
|
||||
|
||||
SimulatedThread::~SimulatedThread() {
|
||||
handler_->Unregister(this);
|
||||
delete[] name_;
|
||||
}
|
||||
|
||||
void SimulatedThread::RunReady(Timestamp at_time) {
|
||||
CurrentThreadSetter set_current(this);
|
||||
ProcessMessages(0);
|
||||
int delay_ms = GetDelay();
|
||||
rtc::CritScope lock(&lock_);
|
||||
if (delay_ms == kForever) {
|
||||
next_run_time_ = Timestamp::PlusInfinity();
|
||||
} else {
|
||||
next_run_time_ = at_time + TimeDelta::ms(delay_ms);
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatedThread::Send(const rtc::Location& posted_from,
|
||||
rtc::MessageHandler* phandler,
|
||||
uint32_t id,
|
||||
rtc::MessageData* pdata) {
|
||||
if (IsQuitting())
|
||||
return;
|
||||
rtc::Message msg;
|
||||
msg.posted_from = posted_from;
|
||||
msg.phandler = phandler;
|
||||
msg.message_id = id;
|
||||
msg.pdata = pdata;
|
||||
if (IsCurrent()) {
|
||||
msg.phandler->OnMessage(&msg);
|
||||
} else {
|
||||
CurrentThreadSetter set_current(this);
|
||||
msg.phandler->OnMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatedThread::Post(const rtc::Location& posted_from,
|
||||
rtc::MessageHandler* phandler,
|
||||
uint32_t id,
|
||||
rtc::MessageData* pdata,
|
||||
bool time_sensitive) {
|
||||
rtc::Thread::Post(posted_from, phandler, id, pdata, time_sensitive);
|
||||
rtc::CritScope lock(&lock_);
|
||||
next_run_time_ = Timestamp::MinusInfinity();
|
||||
}
|
||||
|
||||
void SimulatedThread::PostDelayed(const rtc::Location& posted_from,
|
||||
int delay_ms,
|
||||
rtc::MessageHandler* phandler,
|
||||
uint32_t id,
|
||||
rtc::MessageData* pdata) {
|
||||
rtc::Thread::PostDelayed(posted_from, delay_ms, phandler, id, pdata);
|
||||
rtc::CritScope lock(&lock_);
|
||||
next_run_time_ =
|
||||
std::min(next_run_time_, Timestamp::ms(rtc::TimeMillis() + delay_ms));
|
||||
}
|
||||
|
||||
void SimulatedThread::PostAt(const rtc::Location& posted_from,
|
||||
int64_t target_time_ms,
|
||||
rtc::MessageHandler* phandler,
|
||||
uint32_t id,
|
||||
rtc::MessageData* pdata) {
|
||||
rtc::Thread::PostAt(posted_from, target_time_ms, phandler, id, pdata);
|
||||
rtc::CritScope lock(&lock_);
|
||||
next_run_time_ = std::min(next_run_time_, Timestamp::ms(target_time_ms));
|
||||
}
|
||||
|
||||
void SimulatedThread::Stop() {
|
||||
Thread::Quit();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef TEST_TIME_CONTROLLER_SIMULATED_THREAD_H_
|
||||
#define TEST_TIME_CONTROLLER_SIMULATED_THREAD_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "test/time_controller/simulated_time_controller.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class SimulatedThread : public rtc::Thread,
|
||||
public sim_time_impl::SimulatedSequenceRunner {
|
||||
public:
|
||||
class CurrentThreadSetter : CurrentTaskQueueSetter {
|
||||
public:
|
||||
explicit CurrentThreadSetter(rtc::Thread* thread)
|
||||
: CurrentTaskQueueSetter(thread),
|
||||
manager_(rtc::ThreadManager::Instance()),
|
||||
previous_(manager_->CurrentThread()) {
|
||||
manager_->ChangeCurrentThreadForTest(thread);
|
||||
}
|
||||
~CurrentThreadSetter() { manager_->ChangeCurrentThreadForTest(previous_); }
|
||||
|
||||
private:
|
||||
rtc::ThreadManager* const manager_;
|
||||
rtc::Thread* const previous_;
|
||||
};
|
||||
SimulatedThread(sim_time_impl::SimulatedTimeControllerImpl* handler,
|
||||
absl::string_view name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server);
|
||||
~SimulatedThread() override;
|
||||
|
||||
void RunReady(Timestamp at_time) override;
|
||||
|
||||
Timestamp GetNextRunTime() const override {
|
||||
rtc::CritScope lock(&lock_);
|
||||
return next_run_time_;
|
||||
}
|
||||
|
||||
TaskQueueBase* GetAsTaskQueue() override { return this; }
|
||||
|
||||
// Thread interface
|
||||
void Send(const rtc::Location& posted_from,
|
||||
rtc::MessageHandler* phandler,
|
||||
uint32_t id,
|
||||
rtc::MessageData* pdata) override;
|
||||
void Post(const rtc::Location& posted_from,
|
||||
rtc::MessageHandler* phandler,
|
||||
uint32_t id,
|
||||
rtc::MessageData* pdata,
|
||||
bool time_sensitive) override;
|
||||
void PostDelayed(const rtc::Location& posted_from,
|
||||
int delay_ms,
|
||||
rtc::MessageHandler* phandler,
|
||||
uint32_t id,
|
||||
rtc::MessageData* pdata) override;
|
||||
void PostAt(const rtc::Location& posted_from,
|
||||
int64_t target_time_ms,
|
||||
rtc::MessageHandler* phandler,
|
||||
uint32_t id,
|
||||
rtc::MessageData* pdata) override;
|
||||
|
||||
void Stop() override;
|
||||
|
||||
private:
|
||||
sim_time_impl::SimulatedTimeControllerImpl* const handler_;
|
||||
// Using char* to be debugger friendly.
|
||||
char* name_;
|
||||
rtc::CriticalSection lock_;
|
||||
Timestamp next_run_time_ RTC_GUARDED_BY(lock_) = Timestamp::PlusInfinity();
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
#endif // TEST_TIME_CONTROLLER_SIMULATED_THREAD_H_
|
||||
@ -20,7 +20,6 @@
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "test/time_controller/simulated_process_thread.h"
|
||||
#include "test/time_controller/simulated_task_queue.h"
|
||||
#include "test/time_controller/simulated_thread.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
@ -64,16 +63,6 @@ std::unique_ptr<ProcessThread> SimulatedTimeControllerImpl::CreateProcessThread(
|
||||
return process_thread;
|
||||
}
|
||||
|
||||
std::unique_ptr<rtc::Thread> SimulatedTimeControllerImpl::CreateThread(
|
||||
const std::string& name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server) {
|
||||
rtc::CritScope lock(&lock_);
|
||||
auto thread =
|
||||
std::make_unique<SimulatedThread>(this, name, std::move(socket_server));
|
||||
runners_.push_back(thread.get());
|
||||
return thread;
|
||||
}
|
||||
|
||||
void SimulatedTimeControllerImpl::YieldExecution() {
|
||||
if (rtc::CurrentThreadId() == thread_id_) {
|
||||
TaskQueueBase* yielding_from = TaskQueueBase::Current();
|
||||
@ -94,9 +83,6 @@ void SimulatedTimeControllerImpl::YieldExecution() {
|
||||
}
|
||||
|
||||
void SimulatedTimeControllerImpl::RunReadyRunners() {
|
||||
// Using a dummy thread rather than nullptr to avoid implicit thread creation
|
||||
// by Thread::Current().
|
||||
SimulatedThread::CurrentThreadSetter set_current(dummy_thread_.get());
|
||||
rtc::CritScope lock(&lock_);
|
||||
RTC_DCHECK_EQ(rtc::CurrentThreadId(), thread_id_);
|
||||
Timestamp current_time = CurrentTime();
|
||||
@ -179,12 +165,6 @@ GlobalSimulatedTimeController::CreateProcessThread(const char* thread_name) {
|
||||
return impl_.CreateProcessThread(thread_name);
|
||||
}
|
||||
|
||||
std::unique_ptr<rtc::Thread> GlobalSimulatedTimeController::CreateThread(
|
||||
const std::string& name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server) {
|
||||
return impl_.CreateThread(name, std::move(socket_server));
|
||||
}
|
||||
|
||||
void GlobalSimulatedTimeController::AdvanceTime(TimeDelta duration) {
|
||||
rtc::ScopedYieldPolicy yield_policy(&impl_);
|
||||
Timestamp current_time = impl_.CurrentTime();
|
||||
|
||||
@ -60,10 +60,6 @@ class SimulatedTimeControllerImpl : public TaskQueueFactory,
|
||||
void YieldExecution() override;
|
||||
// Create process thread with the name |thread_name|.
|
||||
std::unique_ptr<ProcessThread> CreateProcessThread(const char* thread_name);
|
||||
// Create thread using provided |socket_server|.
|
||||
std::unique_ptr<rtc::Thread> CreateThread(
|
||||
const std::string& name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server);
|
||||
|
||||
// Runs all runners in |runners_| that has tasks or modules ready for
|
||||
// execution.
|
||||
@ -79,7 +75,6 @@ class SimulatedTimeControllerImpl : public TaskQueueFactory,
|
||||
|
||||
private:
|
||||
const rtc::PlatformThreadId thread_id_;
|
||||
std::unique_ptr<rtc::Thread> dummy_thread_ = rtc::Thread::Create();
|
||||
rtc::CriticalSection time_lock_;
|
||||
Timestamp current_time_ RTC_GUARDED_BY(time_lock_);
|
||||
rtc::CriticalSection lock_;
|
||||
@ -124,9 +119,6 @@ class GlobalSimulatedTimeController : public TimeController {
|
||||
TaskQueueFactory* GetTaskQueueFactory() override;
|
||||
std::unique_ptr<ProcessThread> CreateProcessThread(
|
||||
const char* thread_name) override;
|
||||
std::unique_ptr<rtc::Thread> CreateThread(
|
||||
const std::string& name,
|
||||
std::unique_ptr<rtc::SocketServer> socket_server) override;
|
||||
|
||||
void AdvanceTime(TimeDelta duration) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user