Commit 101ac180 authored by TJ Yin's avatar TJ Yin Committed by Facebook GitHub Bot

fix flaky unit-test CodelTest

Summary:
Sometimes it fails to throw exception in [Codel::setOptions](https://github.com/facebook/folly/blob/master/folly/executors/Codel.cpp#L109), since it failed the check `interval <= delay`.

The reason is that both interval and delay are [POD](https://github.com/facebook/folly/blob/master/folly/executors/Codel.h#L80-L81), thus both are not initialized by default.

Using them without initialization is UB. In x86, they will have random value (since x86 doesn't have trap representation), thus sometimes it passes, sometimes it fails.

Based on comment, it looks like the intention is copying the `options` from default initialized `Codel`.

Reviewed By: amlannayak

Differential Revision: D20499449

fbshipit-source-id: e12de0b42c02a8bf6379ba7fd224e0ae173945f0
parent 4aef2fa3
......@@ -138,7 +138,7 @@ TEST(CodelTest, updateInterval) {
TEST(CodelTest, invalidParamUpdates) {
folly::Codel c;
folly::Codel::Options opts;
folly::Codel::Options opts = c.getOptions();
EXPECT_EQ(milliseconds(5), c.getOptions().targetDelay());
EXPECT_EQ(milliseconds(100), c.getOptions().interval());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment