Add -r timeout[:interval] option to atf-check.

Sponsored by:   EMC / Isilon storage division

[PR notes, not for commit log:

I'm mostly soliciting feedback, I don't expect this to be merged as-is (although that would be fine with me). Let me know why it's horrible and I can try and clean it up.

I looked a little bit at trying to make this less noisy (currently each iteration produces the failed status, stdout, and stderr output), but lots of `atf-check.cpp` is hardcoded to write directly out to `std::cout` or `std::cerr`. Changing this would be pretty invasive, and doing it appropriately is probably beyond my C++ abilities.

Doing it right should just be a matter of directing `atf-check.cpp` output to a `stringstream` for each of stdout, stderr; on repeat (the `if ()` clause where we `usleep()`), clear the buffers with `.str("")` and `.clear()`. On exiting the `do { ... } while (...)` loop, print the contents of each buffer to its appropriate stream. This won't interleave exactly the same, but I hope we were not relying on that.

Thanks for taking a look.]
Except (now that I think about) what about the no -r case?

> On Jul 31, 2014, at 11:58, Conrad Meyer <notifications@github.com> wrote:
> 
> In atf-sh/atf-check.cpp:
> 
> > @@ -821,12 +910,23 @@ atf_check::main(void)
> >      if (m_stderr_checks.empty())
> >          m_stderr_checks.push_back(output_check(oc_empty, false, ""));
> >  
> > -    if ((run_status_checks(m_status_checks, *r) == false) ||
> > -        (run_output_checks(*r, "stderr") == false) ||
> > -        (run_output_checks(*r, "stdout") == false))
> > -        status = EXIT_FAILURE;
> > -    else
> > -        status = EXIT_SUCCESS;
> > +    do {
> How about this instead?
> 
> if (m_rflag && status == EXIT_FAILURE) {
>     if (timo_expired(m_timo))
>         break;
>     usleep(m_interval);
> }
> \
> Reply to this email directly or view it on GitHub.