These tests would fail when ran in our cloud. This was due to lines that
were more than 2047 bytes in length, causing us to fail readLine with a
ReadChildError. This fix lets it read lines of any length, but in 2047
byte segments.
Signed-off-by: Bob Campbell <bobcampbell@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Read a line from the child's pipe, returns the string read.
Throws ReadChildError if the read fails.
"""
- buf = os.read(pipe, 2047)
- newline = buf.find('\n')
- if newline == -1:
- raise ReadChildError()
+ newline = -1
+ buf = ""
+ while newline == -1:
+ more = os.read(pipe, 2047)
+ buf = buf + more
+ newline = buf.find('\n')
+ if more == "":
+ raise ReadChildError()
+
return buf[:newline]
def writeLine(pipe, buf):