Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
8a6f9719
Commit
8a6f9719
authored
Sep 17, 2012
by
Marcin Siodelski
Browse files
[master] Adding timeout tolerance to receiveX() timeout checks.
parent
f79bca02
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcp/tests/iface_mgr_unittest.cc
View file @
8a6f9719
...
...
@@ -42,6 +42,13 @@ char LOOPBACK[BUF_SIZE] = "lo";
const
uint16_t
PORT1
=
10547
;
// V6 socket
const
uint16_t
PORT2
=
10548
;
// V4 socket
// On some systems measured duration of receive6() and
// receive4() appears to be shorter than select() timeout.
// called by these functions. This may be the case
// if different ime resolutions are used by these functions.
// For such cases we set the tolerance of 0.01s.
const
uint32_t
TIMEOUT_TOLERANCE
=
10000
;
class
NakedIfaceMgr
:
public
IfaceMgr
{
// "naked" Interface Manager, exposes internal fields
...
...
@@ -250,7 +257,8 @@ TEST_F(IfaceMgrTest, receiveTimeout6) {
// precisely reflect the receive timeout. However the
// uncertainity should be low enough to expect that measured
// value is in the range <1.4s; 1.7s>.
EXPECT_GE
(
duration
.
total_microseconds
(),
1400000
);
EXPECT_GE
(
duration
.
total_microseconds
(),
1400000
-
TIMEOUT_TOLERANCE
);
EXPECT_LE
(
duration
.
total_microseconds
(),
1700000
);
// Test timeout shorter than 1s.
...
...
@@ -260,7 +268,8 @@ TEST_F(IfaceMgrTest, receiveTimeout6) {
ASSERT_FALSE
(
pkt
);
duration
=
stop_time
-
start_time
;
// Check if measured duration is within <0.5s; 0.8s>.
EXPECT_GE
(
duration
.
total_microseconds
(),
500000
);
EXPECT_GE
(
duration
.
total_microseconds
(),
500000
-
TIMEOUT_TOLERANCE
);
EXPECT_LE
(
duration
.
total_microseconds
(),
800000
);
// Test with invalid fractional timeout values.
...
...
@@ -300,7 +309,8 @@ TEST_F(IfaceMgrTest, receiveTimeout4) {
// precisely reflect the receive timeout. However the
// uncertainity should be low enough to expect that measured
// value is in the range <2.3s; 2.6s>.
EXPECT_GE
(
duration
.
total_microseconds
(),
2300000
);
EXPECT_GE
(
duration
.
total_microseconds
(),
2300000
-
TIMEOUT_TOLERANCE
);
EXPECT_LE
(
duration
.
total_microseconds
(),
2600000
);
// Test timeout shorter than 1s.
...
...
@@ -310,7 +320,8 @@ TEST_F(IfaceMgrTest, receiveTimeout4) {
ASSERT_FALSE
(
pkt
);
duration
=
stop_time
-
start_time
;
// Check if measured duration is within <0.4s; 0.7s>.
EXPECT_GE
(
duration
.
total_microseconds
(),
400000
);
EXPECT_GE
(
duration
.
total_microseconds
(),
400000
-
TIMEOUT_TOLERANCE
);
EXPECT_LE
(
duration
.
total_microseconds
(),
700000
);
// Test with invalid fractional timeout values.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment