mirror of
https://github.com/storytold/indd-utils.git
synced 2026-11-21 01:30:48 +01:00
`src/hostile.rs` converts damaged inputs and fails if a conversion panics or takes longer than 20 s: - Synthetic documents built from a seed with `database::synthetic`: a document object with well-formed lists, spreads that hold spread layers, pages and page items, and objects of the model's classes with chunks of the model's IDs (taken from the hexadecimal constants of the model sources). Chunk data is shaped like UID lists, child lists, attribute lists, strings and numbers, or random. Each document is converted as built, with one object truncated, with bytes flipped, and with the file image truncated, through the model and the IDML writer. - The fixture files, if fetched: truncated at structure boundaries and random lengths, and with 1 to 64 bytes flipped, a quarter of the cases in the header and master pages. The cases come from a fixed seed and run on all cores, with a watchdog for hangs. The default sweep has about 1,600 cases and takes 2 s in a debug build and 0.5 s in a release build (16 cores). INDD_HOSTILE_SCALE multiplies the cases and INDD_HOSTILE_SEED changes the seed; sweeps at scale 40 with seeds 0x1DD and 7 (about 63,000 cases each, debug build with overflow checks) found no panic or hang. Idea from storytold/designcraft#98.