From 31dc737d7a01f92016ffb1eaa4fd2700690e4124 Mon Sep 17 00:00:00 2001 From: Stefan Holmer Date: Tue, 28 Apr 2015 15:32:33 +0200 Subject: [PATCH] Platform dependent way of generating the seed for srand for simulations, so that they can be run in parallel. The seed generated for Win won't be good enough to run the simulations in parallel. R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/49829004 Cr-Commit-Position: refs/heads/master@{#9101} --- .../remote_bitrate_estimators_test.cc | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc index 0d9418ec20..42f4e1c2d0 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc @@ -8,6 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ +#ifndef WEBRTC_WIN +#include +#include +#endif + #include #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" @@ -241,7 +246,14 @@ class BweFeedbackTest virtual ~BweFeedbackTest() {} protected: - void SetUp() override { BweTest::SetUp(); } + void SetUp() override { + unsigned int seed = Clock::GetRealTimeClock()->TimeInMicroseconds(); +#ifndef WEBRTC_WIN + seed *= getpid(); +#endif + srand(seed); + BweTest::SetUp(); + } private: DISALLOW_COPY_AND_ASSIGN(BweFeedbackTest); @@ -321,28 +333,27 @@ TEST_P(BweFeedbackTest, DISABLED_GoogleWifiTrace3Mbps) { filter.GetDelayStats(), std::vector>()); } -TEST_P(BweFeedbackTest, PacedSelfFairnessTest) { - srand(Clock::GetRealTimeClock()->TimeInMicroseconds()); +TEST_P(BweFeedbackTest, PacedSelfFairness50msTest) { + RunFairnessTest(GetParam(), 4, 0, 300, 3000, 50); +} + +TEST_P(BweFeedbackTest, PacedSelfFairness500msTest) { RunFairnessTest(GetParam(), 4, 0, 300, 3000, 50); } TEST_P(BweFeedbackTest, PacedSelfFairness1000msTest) { - srand(Clock::GetRealTimeClock()->TimeInMicroseconds()); RunFairnessTest(GetParam(), 4, 0, 300, 3000, 1000); } TEST_P(BweFeedbackTest, TcpFairness50msTest) { - srand(Clock::GetRealTimeClock()->TimeInMicroseconds()); RunFairnessTest(GetParam(), 1, 1, 300, 2000, 50); } TEST_P(BweFeedbackTest, TcpFairness500msTest) { - srand(Clock::GetRealTimeClock()->TimeInMicroseconds()); RunFairnessTest(GetParam(), 1, 1, 300, 2000, 500); } TEST_P(BweFeedbackTest, TcpFairness1000msTest) { - srand(Clock::GetRealTimeClock()->TimeInMicroseconds()); RunFairnessTest(GetParam(), 1, 1, 300, 2000, 1000); } } // namespace bwe