Capture the stdout and stderr based on environment

Capture the stdout and stderr based on the environment variable
OS_STDOUT_CAPTURE and OS_STDERR_CAPTURE. This is helpful for using
pdb and ipdb for debug.
This patch does not change the behavior of testr, because the
variables are set to 1 in `.testr.conf` file.

Change-Id: I66d01875a6253524bafddf1b4e20f9126466034e
Merge "Capture the stdout and stderr based on environment"