Test capabilities: environment/build features a unit test may depend on. More...
#include <errno.h>#include <fcntl.h>#include <stdio.h>#include <string.h>#include <sys/param.h>#include <unistd.h>#include <atalk/ea.h>#include <atalk/volume.h>#include "faultinject.h"#include "test_capabilities.h"Functions | |
| const char * | test_capability_name (enum test_capability cap) |
| Short capability name for skip/log messages. | |
| static int | probe_ea_sys (const struct vol *vol) |
| Does the filesystem under vol->v_path support user extended attributes? | |
| static int | probe_fault_inject (const struct vol *vol) |
| Is the LD_PRELOAD interposer active and reaching libc here? | |
| int | test_capability (enum test_capability cap, const struct vol *vol) |
| Probe a capability; the result is cached for the run. | |
Variables | |
| static int | cap_cache [] |
Test capabilities: environment/build features a unit test may depend on.
Some tests can only run where a feature is present (the LD_PRELOAD shim reaches libatalk; the filesystem supports user extended attributes for an ea=sys volume). A test probes the capability it needs and returns TEST_SKIP when it is absent, so coverage stays honest per platform rather than failing where the feature is simply unavailable. Each capability is probed once by actually exercising it (e.g. an xattr round-trip), not by trusting a higher-level operation that may succeed without the underlying support; the result is cached for the run.
|
static |
Does the filesystem under vol->v_path support user extended attributes?
Round-trips a real xattr on a scratch file: set, read back, remove. An ea=sys volume stores AppleDouble metadata in xattrs, so without this the volume opens (openvol() does not write-probe) but every metadata write fails — which would surface as a test failure rather than an honest skip. Probing here keeps the skip honest.
|
static |
Is the LD_PRELOAD interposer active and reaching libc here?
Arms a one-shot open() failure and checks it fired. macOS's two-level namespace ignores a plain symbol preload, so the injection never takes effect there and fault-injection-dependent tests skip.
| int test_capability | ( | enum test_capability | cap, |
| const struct vol * | vol ) |
Probe a capability; the result is cached for the run.
| cap | the capability to probe |
| vol | supplies a filesystem path for capabilities probed against the volume (TEST_CAP_EA_SYS, TEST_CAP_FAULT_INJECT use vol->v_path for a scratch file); must not be NULL. |
| const char * test_capability_name | ( | enum test_capability | cap | ) |
Short capability name for skip/log messages.
|
static |