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
//! A process that prints far more than one poll's window and then keeps
//! running — the fixture the bounded-output tests need.
//!
//! `examples/tick.rs` exists because nothing portable both keeps running and
//! keeps printing; this exists for the same reason at the other end of the
//! scale. Proving that a handle nobody polls cannot exhaust memory needs a
//! program that produces much more output than the poll window, as fast as the
//! operating system will take it, and `yes`, `seq` and a shell loop are each
//! either absent on a Windows runner or exactly the construct this crate
//! refuses to hand to a shell. So the flood is written here, in Rust, and is the
//! same program everywhere.
//!
//! Two properties the tests depend on, both deliberate:
//!
//! * **It stops writing and stays alive.** The volume is an argument rather than
//! "until killed", so the total is the test's choice and not the runner's
//! disk's — a genuinely unbounded writer would put however many megabytes a
//! loaded machine's scheduling happened to allow into a temporary file, and
//! the bound under test is per-poll and does not depend on the total. Staying
//! alive afterwards is what lets a test ask the operating system whether a
//! handle that flooded is still killable.
//! * **The lines are fixed width.** `flood 000001` is not a prefix of any other
//! line, so a test can assert that the *earliest* output is absent from a
//! window without the assertion being satisfied by `flood 000010`.
//!
//! Arguments: `flood [lines]`, default one line. Run directly rather than as a
//! test: `cargo run --example flood 1000`.
use ;