aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--luni/src/test/java/libcore/libcore/io/OsTest.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/luni/src/test/java/libcore/libcore/io/OsTest.java b/luni/src/test/java/libcore/libcore/io/OsTest.java
index ab8f16e39d9..5e8a6919a41 100644
--- a/luni/src/test/java/libcore/libcore/io/OsTest.java
+++ b/luni/src/test/java/libcore/libcore/io/OsTest.java
@@ -714,8 +714,12 @@ public class OsTest extends TestCase {
int newValue = 3000;
Libcore.os.setsockoptInt(fd, OsConstants.IPPROTO_TCP, OsConstants.TCP_USER_TIMEOUT,
newValue);
- assertEquals(newValue, Libcore.os.getsockoptInt(fd, OsConstants.IPPROTO_TCP,
- OsConstants.TCP_USER_TIMEOUT));
+ int actualValue = Libcore.os.getsockoptInt(fd, OsConstants.IPPROTO_TCP,
+ OsConstants.TCP_USER_TIMEOUT);
+ // The kernel can round the requested value based on the HZ setting. We allow up to 10ms
+ // difference.
+ assertTrue("Returned incorrect timeout:" + actualValue,
+ Math.abs(newValue - actualValue) <= 10);
// No need to reset the value to 0, since we're throwing the socket away
} finally {
Libcore.os.close(fd);