]> git.ipfire.org Git - thirdparty/rsync.git/commit
testsuite: portable make_data_file helper; drop hard /dev/urandom dependency
authorAndrew Tridgell <tridge60@gmail.com>
Wed, 20 May 2026 21:28:03 +0000 (07:28 +1000)
committerAndrew Tridgell <andrew@tridgell.net>
Wed, 20 May 2026 21:40:30 +0000 (07:40 +1000)
commit47e087d8eb4567989db066fa1da7eb5ad88554d2
tree9ba1c2f1a4cd1c183a4194220c3697f66f39588a
parente1c5f0e93a75dd45f32f3b92ba221ef158ac2e5f
testsuite: portable make_data_file helper; drop hard /dev/urandom dependency

symlink-dirlink-basis.test and chdir-symlink-race.test both
require a multi-kilobyte non-trivial-content source file for the
rsync delta algorithm to exercise.  Both used dd / head against
/dev/urandom directly, which fails on platforms that don't ship
/dev/urandom (e.g. HPE NonStop).  The dd error gets swallowed by
'2>/dev/null' and the test then fails with a misleading 'failed
to create test file' that hides the real cause.

Add make_data_file <path> <size> to testsuite/rsync.fns.  Prefers
/dev/urandom when readable (kernel-provided randomness, fast),
falling back to a deterministic awk LCG seeded from PID and a
POSIX cksum of the destination path.  Output is constrained to
printable ASCII (33..126) so the helper survives two awk-portability
quirks:

  - printf '%c', 0 terminates the string in some awks, emitting
    fewer than sz bytes;
  - gawk in UTF-8 locales encodes printf '%c', N for N > 127 as
    a 2-byte UTF-8 sequence, emitting more than sz bytes.

The tests don't need 8-bit binary entropy -- they just need
non-trivial bytes for rsync's block-matching algorithm.

Update both call sites to use the helper.  Linux/FreeBSD/macOS
still take the /dev/urandom fast path; NonStop and any other
platform missing the device get the awk fallback transparently.
Both paths verified locally with the symlink-dirlink-basis test.
testsuite/chdir-symlink-race.test
testsuite/rsync.fns
testsuite/symlink-dirlink-basis.test