Merge "Snap for 5063281 from fed6186c743607d4c2696cc27385a31567f63185 to oreo-mr1-cts-release" into oreo-mr1-cts-release
diff --git a/luni/src/test/java/libcore/io/OsTest.java b/luni/src/test/java/libcore/io/OsTest.java
index 5b2e7c1..febf6aa 100644
--- a/luni/src/test/java/libcore/io/OsTest.java
+++ b/luni/src/test/java/libcore/io/OsTest.java
@@ -705,8 +705,12 @@
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);