Debian Codegraph @

testsuite/operator-path-compare-dest_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # --compare-dest symlink policy matrix. A followed --compare-dest symlink lets
3 # the basis lookup read an out-of-tree directory; a match there makes rsync treat
4 # the file as already present and SKIP creating it in dest (out-of-tree read).
5 # The ownership walk must follow only uid0/euid-owned symlinks; --insecure-links
6 # is the local opt-out.
7
8 import os
9 import subprocess
10
11 from rsyncfns import rsync_argv, run_symlink_matrix, plant_operator_symlink
12
13 T = 1234567890
14
15
16 def case(ctx):
17 src = ctx.base / 'src'
18 dest = ctx.base / 'dest'
19 src.mkdir()
20 dest.mkdir()
21 (src / 'f0').write_text("BASIS-MATCH\n")
22 opt, escape = plant_operator_symlink(ctx, dest)
23 escape.mkdir(parents=True, exist_ok=True)
24 (escape / 'f0').write_text("BASIS-MATCH\n")
25 os.utime(src / 'f0', (T, T))
26 os.utime(escape / 'f0', (T, T))
27 extra = ['--insecure-links'] if ctx.insecure else []
28 subprocess.run(
29 rsync_argv('-a', f'--compare-dest={opt}', *extra, 'src/', 'dest/'),
30 cwd=str(ctx.base), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
31 # Followed == the out-of-tree basis matched, so f0 was skipped (not created).
32 return not (dest / 'f0').exists()
33
34
35 run_symlink_matrix('--compare-dest', case)
36 print("--compare-dest symlink policy matrix: enforced")