Commit graph

24 commits

Author SHA1 Message Date
Danil Chapovalov
24b0543ee0 Delete ProcessThread creation from test TimeController as unused
Bug: webrtc:7219
Change-Id: Ia34f24a804b8a1e06b089774e37cac6e6d749e82
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266366
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37311}
2022-06-23 09:41:43 +00:00
Artem Titov
1ee563d5e0 Use backticks not vertical bars to denote variables in comments for /test
Bug: webrtc:12338
Change-Id: I2a33903a79194bb092a17ea1e1505bf2a3377d8b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227027
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34558}
2021-07-27 12:50:31 +00:00
Markus Handell
049ed447b0 ModuleRtpRtcpImpl2: update test code.
This change prepares for later CLs that partly replaces
logic in the module that depends on the Module system
for logic that depends on task queues.

The change also changes SendTransport::SendRTCP
to schedule packet reception with the simulated time
controller. This fixes the problem that SendRTCP itself
updates the simulated time which makes it hard to
understand the tests.

Finally, GlobalSimulatedTimeController was updated
to support addition of custom SimulatedSequenceRunners
like SendTransport.

Bug: webrtc:11581
Change-Id: I0aa310ad0a10526479ad8c28affc38a413363ffd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/222602
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34348}
2021-06-21 23:36:49 +00:00
Markus Handell
e56976d2db Reland "Migrate test/time_controller to webrtc::Mutex."
This is a reland of 52fd96fb73

Original change's description:
> Migrate test/time_controller to webrtc::Mutex.
>
> Bug: webrtc:11567
> Change-Id: I26fb07bf84ed197ce667290aa0bf4816bc9c5c06
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178818
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Commit-Queue: Markus Handell <handellm@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31660}

Bug: webrtc:11567
Change-Id: I4979b6be8ac5ec661e0f18cca4d0c185916233bb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178876
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31687}
2020-07-09 12:52:06 +00:00
Markus Handell
122fadc608 Revert "Migrate test/time_controller to webrtc::Mutex."
This reverts commit 52fd96fb73.

Reason for revert: previously undetected lock recursions happening in downstream project.

Original change's description:
> Migrate test/time_controller to webrtc::Mutex.
> 
> Bug: webrtc:11567
> Change-Id: I26fb07bf84ed197ce667290aa0bf4816bc9c5c06
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178818
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Commit-Queue: Markus Handell <handellm@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31660}

TBR=srte@webrtc.org,handellm@webrtc.org

Change-Id: Icccfa32ac21412bc46f75ac7aca76641f5593096
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:11567
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178872
Reviewed-by: Markus Handell <handellm@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31668}
2020-07-08 10:17:02 +00:00
Markus Handell
52fd96fb73 Migrate test/time_controller to webrtc::Mutex.
Bug: webrtc:11567
Change-Id: I26fb07bf84ed197ce667290aa0bf4816bc9c5c06
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178818
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31660}
2020-07-08 08:36:47 +00:00
Markus Handell
222598d1bf SimulatedTimeController: remove lock recursions.
This change removes lock recursions and adds thread annotations.

Bug: webrtc:11567
Change-Id: If6c86adddf006367eefedf10cce819e776e6afc2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175111
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31294}
2020-05-18 07:42:46 +00:00
Sebastian Jansson
274cc7fadf Adds current thread to yielders in SimulatedThread::SendTask.
Bug: webrtc:11255
Change-Id: Ib65b902b60b15f402fac51269c74ac46b56cabc5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166462
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30304}
2020-01-17 15:08:53 +00:00
Sebastian Jansson
fc8279d66c Reland "Using simulated rtc::Thread for peer connection scenario tests."
This is a reland of b70c5c5ce9

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}

Bug: webrtc:11255
Change-Id: If65cd56b59158cebec5609407a721fbdb47cfd1b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166046
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30294}
2020-01-17 09:22:18 +00:00
Sebastian Jansson
f1173f46e5 Revert "Using simulated rtc::Thread for peer connection scenario tests."
This reverts commit b70c5c5ce9.

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}
2020-01-15 10:10:07 +00:00
Sebastian Jansson
b70c5c5ce9 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}
2020-01-15 09:35:40 +00:00
Sebastian Jansson
53cd9e2645 Separates simulated TaskQueue and simulated ProcessThread.
The overlap in functionality is quite limited and separating the
functionality makes it a bit easier to follow each. This prepares
for adding a SimulatedThread class in a follow up CL.

Bug: webrtc:11255
Change-Id: I83c754bd570113dfb582098bb4d39e27bb4f4d87
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165688
Reviewed-by: Jonas Olsson <jonasolsson@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30229}
2020-01-13 11:26:42 +00:00
philipel
d572748885 Run delay tasks on time when using GlobalSimulatedTimeController.
This change means tasks scheduled at the end time reached when making a call to GlobalSimulatedTimeController::AdvanceTime will also be executed.

In other words, with this change, if you schedule a task in X milliseconds and then call AdvanceTime(TimeDelta::ms(X)) the scheduled task will be executed.

Bug: none
Change-Id: I337e574a88b235639e82ffcacf1484daa6cf3172
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/164522
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30146}
2020-01-03 16:37:42 +00:00
Sebastian Jansson
340af975e9 Always enter yield policy scope using simulated TimeControllers.
This makes the class easier to use at a minor cost of making it slightly
more magic.

Bug: webrtc:9883
Change-Id: If807cfbf046615333c3bcd3b58a001813102a9f9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161231
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30008}
2019-12-04 17:16:32 +00:00
Markus Handell
486cc55a02 TimeController: Rename Sleep to AdvanceTime.
This change renames TimeController's Sleep method to AdvanceTime, unifying
the same name with the same semantic as for downstream projects.

Bug: webrtc:11154
Change-Id: Id79bcf0eafcd0b47a76407ba220479d84df5a736
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161092
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29989}
2019-12-03 16:08:54 +00:00
Bjorn A Mellem
c4f865413a Add TimeController to api/test/ and add a CreateTimeController API.
Creates an abstraction for an "alarm clock" which can schedule
time-controller callbacks and exposes a time controller driven by
an external alarm.

Bug: webrtc:9719
Change-Id: I08c2aa9dba25603043bfba48f55c925716a55bae
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158969
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Bjorn Mellem <mellem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29879}
2019-11-22 17:07:23 +00:00
Mirko Bonadei
317a1f09ed Use std::make_unique instead of absl::make_unique.
WebRTC is now using C++14 so there is no need to use the Abseil version
of std::make_unique.

This CL has been created with the following steps:

git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt
git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt
git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt

diff --new-line-format="" --unchanged-line-format="" \
  /tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \
  uniq > /tmp/only_make_unique.txt
diff --new-line-format="" --unchanged-line-format="" \
  /tmp/only_make_unique.txt /tmp/memory.txt | \
  xargs grep -l "absl/memory" > /tmp/add-memory.txt

git grep -l "\babsl::make_unique\b" | \
  xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g"

git checkout PRESUBMIT.py abseil-in-webrtc.md

cat /tmp/add-memory.txt | \
  xargs sed -i \
  's/#include "absl\/memory\/memory.h"/#include <memory>/g'
git cl format
# Manual fix order of the new inserted #include <memory>

cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \
  xargs sed -i '/#include "absl\/memory\/memory.h"/d'

git ls-files | grep BUILD.gn | \
  xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d'

python tools_webrtc/gn_check_autofix.py \
  -m tryserver.webrtc -b linux_rel

# Repead the gn_check_autofix step for other platforms

git ls-files | grep BUILD.gn | \
  xargs sed -i 's/absl\/memory:memory/absl\/memory/g'
git cl format

Bug: webrtc:10945
Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29209}
2019-09-17 15:47:29 +00:00
Jonas Olsson
a4d873786f Format almost everything.
This CL was generated by running

git ls-files | grep -P "(\.h|\.cc)$" | grep -v 'sdk/' | grep -v 'rtc_base/ssl_' | \
grep -v 'fake_rtc_certificate_generator.h' | grep -v 'modules/audio_device/win/' | \
grep -v 'system_wrappers/source/clock.cc' | grep -v 'rtc_base/trace_event.h' | \
grep -v 'modules/audio_coding/codecs/ilbc/' | grep -v 'screen_capturer_mac.h' | \
grep -v 'spl_inl_mips.h' | grep -v 'data_size_unittest.cc' | grep -v 'timestamp_unittest.cc' \
| xargs clang-format -i ; git cl format

Most of these changes are clang-format grouping and reordering includes
differently.

Bug: webrtc:9340
Change-Id: Ic83ddbc169bfacd21883e381b5181c3dd4fe8a63
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144051
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28505}
2019-07-08 13:45:15 +00:00
Sebastian Jansson
d624c3903c Make MessageQueue processing an optional feature of FakeClock
This is used to avoid thread processing in simulated time
controller. This saves up to 30% execution time in debug builds.

Bug: webrtc:10365
Change-Id: Ie83dfb2468d371e4687d28c776acf7e23eb411d1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133173
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27666}
2019-04-17 14:10:16 +00:00
Sebastian Jansson
1b40823870 Fix for recursive yield crash in simulated time controller.
Without this |ready_runners_| might still have entries left if the
yield call comes from another task queue (only done in testing).

Bug: webrtc:10365
Change-Id: I704249e00bf5e75e1f58fdda1809b955de20c304
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132713
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27596}
2019-04-12 14:46:48 +00:00
Sebastian Jansson
5a000165d2 Cleanup: Using DCHECK comparison macros for unit types.
This provides nicer error messages.

Bug: webrtc:9883
Change-Id: I7664c12f34bec2ba46a4057b1f45958daf3944b8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132707
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27590}
2019-04-12 13:01:03 +00:00
Sebastian Jansson
7654081e91 Fix for use after free in simulated time controller.
We need to keep the lock until we have finished using the task runner
returned by GetNextReadyRunner to ensure that we don't remove it from
another thread. Additionally, we must get only one runner at a time in
case the first runner removes the second runner.

Bug: webrtc:10538
Change-Id: Idbd5610b67666238545b3a321fb79f7e86fcac56
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132342
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27584}
2019-04-12 10:06:14 +00:00
Sebastian Jansson
7b6add35ab Makes simulated time controller deterministic.
Replacing sets of pointers (that will depend on allocation addresses)
with vectors and lists. This allows deterministic execution.

Also doing some cleanup of the task queue configuration, ensuring that
the task queue states is not set outside of actual task queues.

Bug: webrtc:10365
Change-Id: I1fad621c7b1ba0bbb33db8c3bd69cb3a1e212b9c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130460
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27364}
2019-03-29 18:40:37 +00:00
Sebastian Jansson
0d617ccc1c Adds simulated time controller
This CL introduces the TimeControllerInterface that provides timing
related functionality. Most notably it provides a TaskQueueFactory
and facilitates creation of ProcessThread.

Two implementations of the interface are provided, RealTimeController
and SimulatedTimeController.

This prepares for an upcoming CL using these in Scenario tests.

Bug: webrtc:10365
Change-Id: Id956a29628d7e2f53ecaedadd643a9f697329d2f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127297
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27244}
2019-03-22 14:57:23 +00:00