net_test - extra debugging for ReadProcNetSocket() regexp match failures
See:
https://android-build.googleplex.com/builds/submitted/5097760/kernel_test/latest/view/logs/build.log
ie.:
##### ./forwarding_test.py (5/23)
E.
======================================================================
ERROR: testForwardingCrashTcp (__main__.ForwardingTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "./forwarding_test.py", line 169, in testForwardingCrashTcp
self.CheckForwardingByProto(IPPROTO_TCP)
File "./forwarding_test.py", line 161, in CheckForwardingByProto
self.CheckForwardingHandlerByProto(proto, netid, iface1, iface2)
File "./forwarding_test.py", line 150, in CheckForwardingHandlerByProto
self.CheckForwardingCrashTcp(netid, iif, oif)
File "./forwarding_test.py", line 124, in CheckForwardingCrashTcp
sockets = self.ReadProcNetSocket("tcp6")
File "/host/usr/local/google/buildbot/src/partner-android/common-android-4.19/kernel/tests/net/test/net_test.py", line 462, in ReadProcNetSocket
_, _, uid, _, _, refcnt, _, extra) = regexp.match(line).groups()
AttributeError: 'NoneType' object has no attribute 'groups'
----------------------------------------------------------------------
Ran 2 tests in 0.452s
FAILED (errors=1)
E.
...(and then it reruns and promptly fails again in the same way)...
'./forwarding_test.py' failed more than once, giving up
#####
I've had no luck reproducing the failure locally...
But I'm guessing one of the 8 hex digit regexps is not matching due to printing
out a negative 64 bit integer (which requires 16 hex digits).
I'm intentionally leaving this in a way it can still fail, so we get to the
bottom of this and actually fix the regexps.
(while we're at it remove a spurious second | operator)
Bug: 118651133
Change-Id: I6fbdc563cedbba3648d74b6bea1911b94086d0f3
diff --git a/net/test/net_test.py b/net/test/net_test.py
index 6b19f54..035ba60 100755
--- a/net/test/net_test.py
+++ b/net/test/net_test.py
@@ -433,7 +433,7 @@
if protocol.startswith("tcp"):
# Real sockets have 5 extra numbers, timewait sockets have none.
- end_regexp = "(| +[0-9]+ [0-9]+ [0-9]+ [0-9]+ -?[0-9]+|)$"
+ end_regexp = "(| +[0-9]+ [0-9]+ [0-9]+ [0-9]+ -?[0-9]+)$"
elif re.match("icmp|udp|raw", protocol):
# Drops.
end_regexp = " +([0-9]+) *$"
@@ -458,8 +458,11 @@
# TODO: consider returning a dict or namedtuple instead.
out = []
for line in lines:
+ m = regexp.match(line)
+ if m is None:
+ raise ValueError("Failed match on [%s]" % line)
(_, src, dst, state, mem,
- _, _, uid, _, _, refcnt, _, extra) = regexp.match(line).groups()
+ _, _, uid, _, _, refcnt, _, extra) = m.groups()
out.append([src, dst, state, mem, uid, refcnt, extra])
return out