1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Harness for faults that cannot be injected in this process.
//!
//! Two kinds of test need their own process. One is a fault switch that
//! is **global**: `av_max_alloc` makes every FFmpeg allocation past a
//! size fail, which is the only honest way to test an out-of-memory
//! path against the real library — and it would break every other lane
//! running beside it. The other is a failure whose whole point is that
//! it *used* to end the process: a test that asserts the process
//! survives has to be able to observe a process that did not.
//!
//! [`in_subprocess`] re-runs one named test in a child of the test
//! binary itself, single-threaded and alone, and the parent asserts the
//! child exited normally. A child that aborts is reported as the
//! signal it died of rather than as a passing test.
/// Runs `body` in a child process running only this test, and asserts
/// the child exited cleanly.
///
/// `test_path` must be the test's name as libtest spells it — the
/// module path inside the crate, e.g. `demuxer::tests::the_lane` — so
/// that `--exact` selects exactly this test in the child.
/// Makes every FFmpeg allocation larger than `max` fail, returning
/// `NULL` the way an out-of-memory allocator would.
///
/// # Safety
///
/// The cap is process-global: from this call until
/// [`uncap_ffmpeg_allocations`], every FFmpeg allocation larger than
/// `max` returns null, on every thread. ffmpeg-next's own safe
/// constructors do not check for that — `frame::Video::empty` and
/// `codec::Parameters::new` wrap the null they are handed, and the next
/// call through one dereferences it — so the caller must ensure that no
/// allocation made while the cap stands hands a null to code that will
/// dereference it. In practice: only inside [`in_subprocess`]'s child,
/// which runs one test alone, and only around code that checks what it
/// allocates or never uses what it did not get.
pub unsafe
/// Lifts the cap [`cap_ffmpeg_allocations`] set.