Fault-injection framework for the afpdtest unit harness. More...
Functions | |
| void | fault_inject_reset (void) |
| int | faultinject_open_works (const char *scratch_path) |
| Is the LD_PRELOAD open() interposer active on this platform? | |
Variables | |
| struct fault_inject | fi |
Fault-injection framework for the afpdtest unit harness.
One source, two roles selected by -DFAULTINJECT_PRELOAD:
Trigger model (countdown + errno): the per-call "armed" flag enables interception; "fail_after" = N lets the next N armed calls succeed and fails call N+1 once, with the per-call "errno". Because LD_PRELOAD interposition is global, the armed flag MUST be set only around the operation under test (and cleared with fault_inject_reset()), or unrelated infrastructure calls get hit.
Interception is not reliable on every platform (notably macOS's two-level namespace ignores plain symbol preloads); the self-test probes whether it works and dependent tests skip when it does not.
| void fault_inject_reset | ( | void | ) |
| int faultinject_open_works | ( | const char * | scratch_path | ) |
Is the LD_PRELOAD open() interposer active on this platform?
Arms a one-shot open() failure and probes it against the given scratch path. Returns 1 if the injected failure fired (interception works), 0 otherwise (e.g. macOS two-level namespace, or the preload was not loaded). Leaves fi reset. Injection-dependent tests should gate on this and return TEST_SKIP when it is 0, so coverage stays honest per platform.
| struct fault_inject fi |