diff options
author | Neil Fuller <nfuller@google.com> | 2014-07-28 11:57:18 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-07-28 11:57:18 +0000 |
commit | 77c859f4301633b033dc55f366884f55a1041e67 (patch) | |
tree | 792fb26820942562d5d0c7518b7e4707a76f1615 /harmony-tests | |
parent | 38f3fc2c4151d23d7390a8a8ee0f1b34ecd2ef32 (diff) | |
parent | 9ae2eb2e586d43f92c6339e9d7072ec1eef3f0ed (diff) | |
download | libcore-77c859f4301633b033dc55f366884f55a1041e67.zip libcore-77c859f4301633b033dc55f366884f55a1041e67.tar.gz libcore-77c859f4301633b033dc55f366884f55a1041e67.tar.bz2 |
am 9ae2eb2e: Merge "Fix Harmony-707 test for CTS"
* commit '9ae2eb2e586d43f92c6339e9d7072ec1eef3f0ed':
Fix Harmony-707 test for CTS
Diffstat (limited to 'harmony-tests')
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/channels/ServerSocketChannelTest.java | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/channels/ServerSocketChannelTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/channels/ServerSocketChannelTest.java index c1d592a..be40d0b 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/channels/ServerSocketChannelTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/channels/ServerSocketChannelTest.java @@ -657,20 +657,35 @@ public class ServerSocketChannelTest extends TestCase { * @tests ServerSocketChannel#socket().getSoTimeout() */ public void test_accept_SOTIMEOUT() throws IOException { - // regression test for Harmony-707 - final int SO_TIMEOUT = 10; + // Regression test for Harmony-707 + // The timeout actually used may be different from the one set due to + // rounding by the Linux Kernel (see sock_set_timeout() in net/core/sock.c). + // getSoTimeout() can return a different value from the one set with + // setSoTimeout(). Consequently we do not check for equality with what was + // set. + ServerSocketChannel sc = ServerSocketChannel.open(); try { sc.socket().bind(null); + + // Non blocking mode, accept() will return NULL since there are no pending connections. sc.configureBlocking(false); + ServerSocket ss = sc.socket(); + + int defaultTimeout = ss.getSoTimeout(); + assertEquals(0, defaultTimeout); + // The timeout value is unimportant, providing it is large enough to be accepted + // by the Kernel as distinct from the default. + final int SO_TIMEOUT = 200; ss.setSoTimeout(SO_TIMEOUT); + int nonDefaultTimeout = ss.getSoTimeout(); + assertTrue(nonDefaultTimeout != defaultTimeout); + SocketChannel client = sc.accept(); - // non blocking mode, returns null since there are no pending connections. assertNull(client); - int soTimeout = ss.getSoTimeout(); - // Harmony fails here. - assertEquals(SO_TIMEOUT, soTimeout); + // Confirm the timeout was unchanged. + assertEquals(nonDefaultTimeout, ss.getSoTimeout()); } finally { sc.close(); } |