Fix missing socket closure in LocalSocketTest
Noticed as a result of 8fbc09bde8c5723d57a3b188e7fc69916cc62cca.
One of the AF_UNIX sockets being created in three tests was not
being closed (until GC/finalization). Because the name is now
used in multiple tests some of the tests would fail in the CTS
test runner ("Address already in use") if no GC had occurred.
Bug: 3106438
Change-Id: I7debe5ed26d9d09e71a3d8a1b5b7d85b13e6e069
diff --git a/tests/cts/net/src/android/net/cts/LocalSocketTest.java b/tests/cts/net/src/android/net/cts/LocalSocketTest.java
index 22a2c7a..9da8fbe 100644
--- a/tests/cts/net/src/android/net/cts/LocalSocketTest.java
+++ b/tests/cts/net/src/android/net/cts/LocalSocketTest.java
@@ -116,7 +116,7 @@
public void testAccessors() throws IOException{
LocalSocket socket = new LocalSocket();
- LocalSocketAddress addr = new LocalSocketAddress("secondary");
+ LocalSocketAddress addr = new LocalSocketAddress(mSockAddr);
assertFalse(socket.isBound());
socket.bind(addr);
@@ -170,6 +170,8 @@
} catch (UnsupportedOperationException e) {
// expected
}
+
+ socket.close();
}
public void testAvailable() throws Exception {
@@ -198,6 +200,7 @@
clientSocket.close();
serverSocket.close();
+ localServerSocket.close();
}
public void testFlush() throws Exception {
@@ -220,6 +223,7 @@
clientSocket.close();
serverSocket.close();
+ localServerSocket.close();
}
private void testFlushWorks(OutputStream outputStream, InputStream inputStream)