| 1 |
#include <dlfcn.h> |
| 2 |
#include <stdio.h> |
| 3 |
|
| 4 |
#include <z3.h> |
| 5 |
|
| 6 |
// Mock implementation: return UNDEF for the 5th invocation, otherwise it just |
| 7 |
// returns the result of the real invocation. |
| 8 |
Z3_lbool Z3_API Z3_solver_check(Z3_context c, Z3_solver s) { |
| 9 |
static Z3_lbool (*OriginalFN)(Z3_context, Z3_solver); |
| 10 |
if (!OriginalFN) { |
| 11 |
OriginalFN = (Z3_lbool(*)(Z3_context, Z3_solver))dlsym(RTLD_NEXT, |
| 12 |
"Z3_solver_check"); |
| 13 |
} |
| 14 |
|
| 15 |
// Invoke the actual solver. |
| 16 |
Z3_lbool Result = OriginalFN(c, s); |
| 17 |
|
| 18 |
// Mock the 5th invocation to return UNDEF. |
| 19 |
static unsigned int Counter = 0; |
| 20 |
if (++Counter == 5) { |
| 21 |
fprintf(stderr, "Z3_solver_check returns a mocked value: UNDEF\n"); |
| 22 |
return Z3_L_UNDEF; |
| 23 |
} |
| 24 |
fprintf(stderr, "Z3_solver_check returns the real value: %s\n", |
| 25 |
(Result == Z3_L_UNDEF ? "UNDEF" |
| 26 |
: ((Result == Z3_L_TRUE ? "TRUE" : "FALSE")))); |
| 27 |
return Result; |
| 28 |
} |