BullseyeCoverage Up Contents Search

No Measurement of setjmp

Symptoms

BullseyeCoverage does not measure coverage of control structures containing setjmp in the controlling expression.

Cause

The behavior is by design and required due to the limitations on setjmp described in the C standard.

Resolution

Transfer the return value from setjmp to a variable, then test the variable. For example, BullseyeCoverage cannot measure the decision tested in the following code fragment.

if (setjmp(env) != 0) {
    /* handle call from longjmp */
}

BullseyeCoverage can measure the equivalent decision tested in the code fragment below.

int sj;
if (setjmp(env) == 0)
    sj = 0;
else
    sj = 1;
if (sj != 0) {
    /* handle call from longjmp */
}

Updated: 3 Nov 2004