I was auditing our process launching API and looking at how well it was tested, and I noticed that none of the functionality related to I/O redirection was tested at all. I also noticed that all testing was done via unit tests and they are all extremely hard to understand and follow.
The approach here is more LLVMish, using a tool to dump some output and then FileCheck it. Since I was specifically trying to test re-direction here, the only support I've added so far is for specifying command line arguments that describe how to redirect stdout and stderr, and I wrote some tests which I believe are significantly easier to understand than the existing unit tests.
There are plenty of other interesting opportunities for exploration with a tool such as this. For example, LLDB (or any kind of tracing utility) could use it as a kind of "strace" equivalent where it logs all of its events and we could FileCheck that.
In a followup patch, I plan to use this mechanism to test that launching a process with a specific environment works. I am going to do this by introducing meta-variable substitutions into the command language, so that you can write something like write stdout $ENV{PATH}
Is io.h really needed?