Debian Codegraph @

testsuite/scanner-daemon-log-checksum_test.py

raw symbols SCIP
1 #!/usr/bin/python3
2 # Regression test for run5 0025: a daemon-as-sender with -c and a module
3 # `log format` containing %C read F_SUM(file) in log_formatted(), but
4 # start_server() never set sender_keeps_checksum, so make_file() reserved no
5 # SUM_EXTRA_CNT and F_SUM() read past the pool slot (hex-encoding adjacent heap
6 # into the transfer log). Pull with -c from a %C-logging module; the daemon
7 # child must not crash (RED under ASAN before the fix).
8 import subprocess
9 from rsyncfns import (
10 SCRATCHDIR, make_tree, makepath, rmtree, rsync_argv,
11 start_test_daemon, test_fail, write_daemon_conf,
12 )
13
14 DAEMON_PORT = 12894
15
16 mod = SCRATCHDIR / 'csum-mod'
17 rmtree(mod)
18 makepath(mod)
19 make_tree(mod, depth=2, data=True)
20
21 conf = write_daemon_conf([
22 ('csum', {'path': str(mod), 'read only': 'yes',
23 # The module `log format` is only installed when transfer logging
24 # is on (clientserver.c lp_transfer_logging gate); without this the
25 # %C path -- the whole point of this test -- never runs.
26 'transfer logging': 'yes', 'log format': '%o %C %f %l'}),
27 ])
28 url = start_test_daemon(conf, DAEMON_PORT).rstrip('/')
29
30 dest = SCRATCHDIR / 'csum-pull'
31 rmtree(dest)
32 makepath(dest)
33 # Daemon is the SENDER; -c forces always_checksum so log_formatted()'s %C reads
34 # F_SUM(file) in the daemon child.
35 r = subprocess.run(rsync_argv('-a', '-c', f'{url}/csum/', f'{dest}/'),
36 capture_output=True, text=True)
37 if r.returncode < 0 or r.returncode >= 128:
38 test_fail(f'daemon-as-sender -c with %C crashed (rc={r.returncode}): '
39 f'{r.stderr.strip()[:200]}')
40 if not any(dest.rglob('f*')):
41 test_fail(f'pull transferred no files (rc={r.returncode}): {r.stderr.strip()[:200]}')
42 print("scanner-daemon-log-checksum: daemon-as-sender -c with %C log format is clean")