From 8670b1c23f1c074ce430213efc69f573410eabd3 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Wed, 5 Oct 2011 10:43:01 -0700 Subject: [PATCH] ListeningPortsTest: Make error message more useful. - Add UID of listener to error message. - Convert hex port number to decimal for easier reading by humans. Change-Id: I0b8edcf14ebd0c039b936055a265f4706558f9fe --- tests/cts/net/src/android/net/cts/ListeningPortsTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/cts/net/src/android/net/cts/ListeningPortsTest.java b/tests/cts/net/src/android/net/cts/ListeningPortsTest.java index b6e6efbc71..5c1ba7cab8 100644 --- a/tests/cts/net/src/android/net/cts/ListeningPortsTest.java +++ b/tests/cts/net/src/android/net/cts/ListeningPortsTest.java @@ -118,13 +118,18 @@ public class ListeningPortsTest extends TestCase { String localAddress = fields[1]; String state = fields[3]; + String uid = fields[7]; assertTrue(procFilePath + " should have an IP address in the second column", isAddress(localAddress)); + String localIp = localAddress.split(":")[0]; + int localPort = Integer.parseInt(localAddress.split(":")[1], 16); + if (!isException(localAddress) && isPortListening(state, isTcp)) { throw new ListeningPortsAssertionError( - "Found port listening on " + localAddress + " in " + procFilePath); + "Found port listening on addr=" + localIp + ", port=" + + localPort + ", UID=" + uid + " in " + procFilePath); } } } catch (FileNotFoundException notFound) {