ATF-devel archive

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

Take action based on check outcome



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);
}

So that I can later on inspect the output log and see what where the
offending values.
Obviously I could do:

x = random_double();
y = random_double();
rv = mathfunc(x, y);

ATF_CHECK(... some condition on rv ...);
if ( ! ... some condition on rv ...) {
    fprintf(stderr, "mathfunc() failed on: x: %e\t y:%e  (got: %e)\n",
x, y, rv);
}

Is there a more elegant way to do this ? (that is without repeating
the condition on its reverse form).
If not, no big deal :)

Thanks!,
Stathis

P.S. yep, I know that ATF_CHECK() is a macro and doesn't return
anything. Just looking for an alternative.


Home | Main Index | Thread Index | Old Index