ATF-devel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Take action based on check outcome



On Tue, May 4, 2010 at 5:12 AM, Stathis Kamperis <ekamperi%gmail.com@localhost> 
wrote:
> For once more, hello :)
>
> There are cases where I would like to take actions depending on the
> outcome of a check.
> E.g. (schematic):
>
> x = random_double();
> y = random_double();
> rv = mathfunc(x, y);
>
> if (!ATF_CHECK(... some condition on rv ...) {
>    fprintf(stderr, "mathfunc() failed on: x: %e\t y:%e  (got: %e)\n",
> x, y, rv);
> }

Take a look at atf-c/macros.h.  There are more checks that you can use.

If all you want is to change the failure message, do:
ATF_CHECK_MSG(condition, "My message %s", some format).  You can also
check for equality with ATF_CHECK_EQ, which will provide a more
accurate message automatically, or ATF_CHECK_EQ_MSG to provide your
own message.

If the macros do not provide enough functionality, then implement your
own check.  E.g., for a fatal error:

if (some condition)
    atf_tc_fail("condition blah not met due to %d %d", x, y);

Or use atf_tc_fail_nonfatal to report an error message, record the
test as failed, but continue execution of the test.

-- 
Julio Merino


Home | Main Index | Thread Index | Old Index