Commit Graph

21 Commits

Author SHA1 Message Date
22e0814d51 Update VirtualSocketServerTest to use a fake clock.
Since this is a test for a fake network, it's only natural that it uses
a fake clock as well. This makes the tests much faster, less flaky, and
lets them be moved out of  "webrtc_nonparallel_tests", since they no
longer have a dependency on any "real" thing (sockets, or time) and
can be run in parallel as easily as any other tests.

As part of this CL, added the fake clock as an argument to
VirtualSocketServer's and TestClient's constructors, since these classes
have methods that wait synchronously for something to occur, and if the
test is using a fake clock, they need to advance it in order to make
progress.

Lastly, added a DCHECK in Thread::ProcessMessages. If called with a
nonzero time while a fake clock is used, it will get stuck in an
infinite loop; a DCHECK is easier to notice than an infinite loop.

BUG=webrtc:7727, webrtc:2409

Review-Url: https://codereview.webrtc.org/2927413002
Cr-Commit-Position: refs/heads/master@{#18544}
2017-06-12 21:30:28 +00:00
c7c26a0e64 Reland of place basictypes.h with stdint.h for int_t types. (patchset #1 id:1 of https://codereview.webrtc.org/2603203003/ )
Reason for revert:
Doing a reland where systeminfo.cc includes basictypes.h so that CPU_X86 etc. are defined when they are checked/used.

Original issue's description:
> Revert of Replace basictypes.h with stdint.h for int_t types. (patchset #1 id:1 of https://codereview.webrtc.org/2604043002/ )
>
> Reason for revert:
> Very likely cause of Chromium import bot breakage (unused function '__cpuid'), TBD why.
>
> Original issue's description:
> > Replace basictypes.h with stdint.h for int_t types.
> >
> > Removes basictypes.h for types that only makes use of it for fixed-size-int
> > typedefs and replaces it with stdint.h.
> >
> > BUG=webrtc:6853
> > R=tommi@webrtc.org
> >
> > Review-Url: https://codereview.webrtc.org/2604043002
> > Cr-Commit-Position: refs/heads/master@{#15867}
> > Committed: 7fd1a75300
>
> TBR=tommi@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6853
>
> Review-Url: https://codereview.webrtc.org/2603203003
> Cr-Commit-Position: refs/heads/master@{#15869}
> Committed: 7eb0e23bcf

BUG=webrtc:6853
TBR=tommi@webrtc.org

Review-Url: https://codereview.webrtc.org/2609783002
Cr-Commit-Position: refs/heads/master@{#15873}
2017-01-02 16:42:32 +00:00
7eb0e23bcf Revert of Replace basictypes.h with stdint.h for int_t types. (patchset #1 id:1 of https://codereview.webrtc.org/2604043002/ )
Reason for revert:
Very likely cause of Chromium import bot breakage (unused function '__cpuid'), TBD why.

Original issue's description:
> Replace basictypes.h with stdint.h for int_t types.
>
> Removes basictypes.h for types that only makes use of it for fixed-size-int
> typedefs and replaces it with stdint.h.
>
> BUG=webrtc:6853
> R=tommi@webrtc.org
>
> Review-Url: https://codereview.webrtc.org/2604043002
> Cr-Commit-Position: refs/heads/master@{#15867}
> Committed: 7fd1a75300

TBR=tommi@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6853

Review-Url: https://codereview.webrtc.org/2603203003
Cr-Commit-Position: refs/heads/master@{#15869}
2017-01-02 15:32:25 +00:00
7fd1a75300 Replace basictypes.h with stdint.h for int_t types.
Removes basictypes.h for types that only makes use of it for fixed-size-int
typedefs and replaces it with stdint.h.

BUG=webrtc:6853
R=tommi@webrtc.org

Review-Url: https://codereview.webrtc.org/2604043002
Cr-Commit-Position: refs/heads/master@{#15867}
2017-01-02 14:58:46 +00:00
deb95f32f4 Change rtc::TimeNanos and rtc::TimeMicros return value from uint64_t to int64_t.
Also updated types close to call sites.

BUG=webrtc:6733

Review-Url: https://codereview.webrtc.org/2514553003
Cr-Commit-Position: refs/heads/master@{#15255}
2016-11-28 09:55:05 +00:00
cdf37a9293 Delete Timing class, timing.h, and update all users.
BUG=webrtc:6324

Review-Url: https://codereview.webrtc.org/2290203002
Cr-Commit-Position: refs/heads/master@{#14203}
2016-09-14 06:41:55 +00:00
4f0dfbd213 Change initial DTLS retransmission timer from 1 second to 50ms.
This will help ensure a timely DTLS handshake when there's packet
loss. It will likely result in spurious retransmissions (since the
RTT is usually > 50ms), but since exponential backoff is still used,
there will at most be ~4 extra retransmissions. For a time-sensitive
application like WebRTC this seems like a reasonable tradeoff.

R=pthatcher@webrtc.org, juberti@chromium.org, juberti@webrtc.org

Review URL: https://codereview.webrtc.org/1981463002 .

Committed: https://crrev.com/1e435628366fb9fed71632369f05928ed857d8ef
Cr-Original-Commit-Position: refs/heads/master@{#12853}
Cr-Commit-Position: refs/heads/master@{#13159}
2016-06-16 00:15:35 +00:00
f5f03e823c Reland of: Improving the fake clock and using it to fix a flaky STUN timeout test.
When the fake clock's time is advanced, it now ensures all pending
queued messages have been dispatched. This allows us to write a
"SIMULATED_WAIT" macro that ticks the simulated clock by milliseconds up
until the target time.

Useful in this case, where we know the STUN timeout should take a total
of 9500ms, but it would be overly complex to write test code that waits
for each individual timeout, ensures a STUN packet has been
retransmited, etc.

(The test described above *should* be written, but it belongs in
p2ptransportchannel_unittest.cc, not webrtcsession_unittest.cc).

Review-Url: https://codereview.webrtc.org/2024813004
Cr-Commit-Position: refs/heads/master@{#13052}
2016-06-06 18:16:13 +00:00
f83a94a41e Revert of Improving the fake clock and using it to fix a flaky STUN timeout test. (patchset #10 id:180001 of https://codereview.webrtc.org/2024813004/ )
Reason for revert:
There seems to be a TSan warning that wasn't caught by the trybot: https://build.chromium.org/p/client.webrtc/builders/Linux%20Tsan%20v2/builds/6732/steps/peerconnection_unittests/logs/stdio

Apparently a thread is still alive even after destroying WebRTCSession. Need to think of a way to fix this, without adding a critical section around g_clock (since that would hurt performance).

Original issue's description:
> Improving the fake clock and using it to fix a flaky STUN timeout test.
>
> When the fake clock's time is advanced, it now ensures all pending
> queued messages have been dispatched. This allows us to write a
> "SIMULATED_WAIT" macro that ticks the simulated clock by milliseconds up
> until the target time.
>
> Useful in this case, where we know the STUN timeout should take a total
> of 9500ms, but it would be overly complex to write test code that waits
> for each individual timeout, ensures a STUN packet has been
> retransmited, etc.
>
> (The test described above *should* be written, but it belongs in
> p2ptransportchannel_unittest.cc, not webrtcsession_unittest.cc).
>
> Committed: https://crrev.com/ffbe0e17e2c9b7fe101023acf40574dc0c95631a
> Cr-Commit-Position: refs/heads/master@{#13043}

TBR=pthatcher@webrtc.org,tommi@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.webrtc.org/2038213002
Cr-Commit-Position: refs/heads/master@{#13045}
2016-06-03 23:05:30 +00:00
ffbe0e17e2 Improving the fake clock and using it to fix a flaky STUN timeout test.
When the fake clock's time is advanced, it now ensures all pending
queued messages have been dispatched. This allows us to write a
"SIMULATED_WAIT" macro that ticks the simulated clock by milliseconds up
until the target time.

Useful in this case, where we know the STUN timeout should take a total
of 9500ms, but it would be overly complex to write test code that waits
for each individual timeout, ensures a STUN packet has been
retransmited, etc.

(The test described above *should* be written, but it belongs in
p2ptransportchannel_unittest.cc, not webrtcsession_unittest.cc).

Review-Url: https://codereview.webrtc.org/2024813004
Cr-Commit-Position: refs/heads/master@{#13043}
2016-06-03 22:31:37 +00:00
b3c6810be3 Adding the ability to use a simulated clock for unit tests.
This will be useful for any tests that test objects with time-dependent
behavior. It will allow such tests to be written in such a way that their
outcome is more repeatable (less flaky), and will also allow such tests
to finish quicker. For example, a test for STUN timeout doesn't need to
wait the full timeout interval in real time; it can simply advance the
simulated clock.

BUG=webrtc:4925
R=pthatcher@webrtc.org

Review URL: https://codereview.webrtc.org/1895933003 .

Cr-Commit-Position: refs/heads/master@{#12950}
2016-05-27 21:16:07 +00:00
82d7862fe7 Change default timestamp to 64 bits in all webrtc directories.
BUG=
R=pbos@webrtc.org, pthatcher@webrtc.org, solenberg@webrtc.org

Review URL: https://codereview.webrtc.org/1835053002 .

Cr-Commit-Position: refs/heads/master@{#12646}
2016-05-06 18:29:27 +00:00
1bffc1d1a4 Rename rtc::Time64 --> rtc::TimeMillis.
In the discussion on https://codereview.webrtc.org/1888593004/, a more
decriptive name was suggested for Time64.

BUG=webrtc:5740

Review-Url: https://codereview.webrtc.org/1923213002
Cr-Commit-Position: refs/heads/master@{#12594}
2016-05-02 15:19:00 +00:00
b0c293c5ab Delete unused code in rtc timeutils.
BUG=webrtc:5740

Review URL: https://codereview.webrtc.org/1859413002

Cr-Commit-Position: refs/heads/master@{#12275}
2016-04-07 09:12:12 +00:00
34b11eb66e Using 64-bit timestamp to replace the 32-bit one in webrtc/p2p.
Also changed from unsigned to signed integer per the style guide.
By the way, I kept all delta-times to be 32-bit int.

The only things left in the p2p dir are
1. proberprober/main.cc where Time() is used as the input for a random number.
2. pseudotcp.cc: where 32-bit time info is sent over the wire.

BUG=webrtc:5636

Review URL: https://codereview.webrtc.org/1793553002

Cr-Commit-Position: refs/heads/master@{#12019}
2016-03-16 15:55:48 +00:00
46c9cc0190 Provide method for returning certificate expiration time stamp.
We convert ASN1 time via std::tm to int64_t representing milliseconds-since-epoch. We do not use time_t since that cannot store milliseconds, and expires for 32-bit platforms in 2038 also for seconds.

Conversion via std::tm might might seem silly, but actually doesn't add any complexity.

One would expect tm -> seconds-since-epoch to already exist on the standard library. There is mktime, but it uses localtime (and sets an environment variable, and has the 2038 problem).

The ASN1 TIME parsing is limited to what is required by RFC 5280.

BUG=webrtc:5150
R=hbos@webrtc.org, nisse@webrtc.org, tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1468273004 .

Cr-Commit-Position: refs/heads/master@{#10854}
2015-12-01 12:06:46 +00:00
0c4e06b4c6 Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.

BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org

Review URL: https://codereview.webrtc.org/1362503003 .

Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 10:23:32 +00:00
99b4162ccf Rebase webrtc/base 6163:6216 (svn diff -r 6163:6216 http://webrtc.googlecode.com/svn/trunk/talk/base, apply diff manually)
BUG=3379
TBR=wu@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/17619004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6217 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-05-21 20:42:17 +00:00
f048872e91 Adds a modified copy of talk/base to webrtc/base. It is the first step in
migrating talk/base to webrtc/base.

BUG=N/A
R=niklas.enbom@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/17479005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6129 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-05-13 18:00:26 +00:00
e9a604accd Revert 6107 "Adds a modified copy of talk/base to webrtc/base. I..."
This breaks Chromium FYI builds and prevent roll of webrtc/libjingle to Chrome.

http://chromegw.corp.google.com/i/chromium.webrtc.fyi/builders/Win%20Builder/builds/457


> Adds a modified copy of talk/base to webrtc/base. It is the first step in migrating talk/base to webrtc/base.
> 
> BUG=N/A
> R=andrew@webrtc.org, wu@webrtc.org
> 
> Review URL: https://webrtc-codereview.appspot.com/12199004

TBR=henrike@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/14479004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6116 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-05-13 08:15:48 +00:00
2c7d1b39b9 Adds a modified copy of talk/base to webrtc/base. It is the first step in migrating talk/base to webrtc/base.
BUG=N/A
R=andrew@webrtc.org, wu@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/12199004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6107 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-05-12 18:03:09 +00:00