Fixing checkstyle test hang with nc version >= 1.110

netcat (nc) 1.110 changed the behavior of how sockets are closed when
stdin is at EOF or closed. Previously, nc would call shutdown (TCP FIN
on the write side of the socket) when the end of stdin was reached.
Now, shutdown is only called if '-N' is passed as an argument.

This change was introduced into Ubuntu's fork of OpenBSD nc in Nov. 2016.
So, the affected versions were Ubuntu 17.04+ as well as any other
distribution that uses nc >= 1.110.

This change of behavior causes the call to ByteStreams.toByteArray()
to hang indefinietly, and thus checkstyle tests to hang indefinitely.

Rather than try to figure out which version of nc is present and set
the -N option, we will use an empty line as a sentinel and stop parsing
input when the first empty line is encountered. For this, we need two
changes: (1) send a newline when checking the socket in start-buck-daemon
and (2) send a newline at the end of the file list in onos.bucklet

We also set SO_TIMEOUT to 1 second and will return an exception if
the socket times out. This will prevent tests from hanging indefinitely.

Change-Id: If46b4b78ae89312e1afa0563f63100ae67762f0a
diff --git a/bucklets/onos.bucklet b/bucklets/onos.bucklet
index 8f5a11b..d863db1 100644
--- a/bucklets/onos.bucklet
+++ b/bucklets/onos.bucklet
@@ -23,7 +23,8 @@
 
     if srcs:
         base = get_base_path()
-        files = '%s\n%s\n' % (name, base) + '\n'.join(['%s/%s' % (base, s) for s in srcs])
+        # module name; base filepath; files (line-separated); empty line (to signify end of stream)
+        files = '%s\n%s\n' % (name, base) + '\n'.join(['%s/%s' % (base, s) for s in srcs]) + '\n\n'
 
         genrule(
                 name = name + '-checkstyle-files',
@@ -45,6 +46,7 @@
                     '$(location //tools/build/conf:checkstyle-xml)',
                     '$(location //tools/build/conf:suppressions-xml)',
                     ],
+                #TODO test_rule_timeout_ms seems to be ignored on Linux
                 test_rule_timeout_ms = 45000,
                 labels = [ 'checkstyle' ],
         )