[autotest] Add a semi-working |fileno()| to stdout replacement.

Autotest replaces stdout and stderr with file-like objects that redirect
their write() into the logging framework. However, they don't actually
follow the full API for what a file-like object should do, nor are they
backed by a file. Unfortunately, this means that there is no file
descriptor to return for a call to |fileno()|, and it seems pretty
reasonable to expect |sys.stdout.fileno()| to work. Therefore, we create
a pipe so that there is a valid file descriptor to return. We return the
read end of the file descriptor, so that a write to this fd is an error.

TEST=pylint, run_suite.py run
BUG=chromium-os:33320

Change-Id: I7eb4e04049082540b732b8356bc7d5506298e514
Reviewed-on: https://gerrit.chromium.org/gerrit/36846
Tested-by: Alex Miller <milleral@chromium.org>
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Commit-Ready: Alex Miller <milleral@chromium.org>
1 file changed