Files
rsync/testsuite/files-from_test.py
Andrew Tridgell e21cdabd71 runtests: add --rsync-bin2 / --expect-result for version-mixing tests
Let the suite run with two rsync binaries so the current build can be
tested against the actual old code of a previous release, rather than
only forcing the current binary to speak an old protocol (check29/30).

  --rsync-bin2 PATH  exports RSYNC_PEER, the binary used for the SERVER
                     side of two-sided transfers (the daemon process and
                     the remote-shell --rsync-path target). Defaults to
                     RSYNC, so single-binary runs are byte-for-byte
                     unchanged.
  --expect-result F  the manifest's listed tests ARE the run set; each
                     test's actual outcome (pass/skip/fail/xfail) is
                     compared to its expected one and any mismatch --
                     including an unexpected pass (xpass) -- fails the
                     run. --expect-skipped and the default exit logic
                     are untouched.

rsyncfns gains the RSYNC_PEER global and launches the daemon with it
(start_rsyncd / start_test_daemon, the latter with an optional rsync_cmd
override used by the reverse-direction test); the remote-shell tests
pass --rsync-path={RSYNC_PEER}. All no-ops when no peer is selected.

Direction is fixed: the current binary always drives (only it
understands the new test scripts); the old binary is only ever the
server/daemon side.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 19:21:35 +10:00

52 lines
1.7 KiB
Python

#!/usr/bin/env python3
# Python rewrite of testsuite/files-from.test.
#
# Verify that --files-from=LIST drives rsync correctly both for a plain
# local sync and across the lsh.sh "remote shell" with each of the four
# files-host / src-host / dest-host placement combinations.
from rsyncfns import (
CHKDIR, FROMDIR, RSYNC, RSYNC_PEER, SCRATCHDIR, SRCDIR, TODIR,
checkit, hands_setup, rmtree, run_rsync,
)
SSH = str(SRCDIR / 'support' / 'lsh.sh')
hands_setup()
# Files-from list: skip the contents of subsubdir but include subsubdir2/
# in full (the trailing slash on subsubdir2/ is what flips it).
filelist = SCRATCHDIR / 'filelist'
filelist.write_text(
"from/./\n"
"from/./dir/subdir\n"
"from/./dir/subdir/subsubdir\n"
"from/./dir/subdir/subsubdir2/\n"
"from/./dir/subdir/foobar.baz\n"
)
# chkdir is what we expect the transfer to produce: source minus
# dir/text and minus everything under subsubdir/.
run_rsync('-a', '--exclude=dir/text', '--exclude=subsubdir/**',
f'{FROMDIR}/', f'{CHKDIR}/')
# Local case.
checkit(['-av', f'--files-from={filelist}', str(SCRATCHDIR), f'{TODIR}/'],
CHKDIR, TODIR)
# All four combinations of files-host / source-host / dest-host across the
# lsh.sh "remote shell". In each loop iteration exactly one of source or
# dest is remote (matches the original test's branch logic).
for filehost in ('', 'localhost:'):
for srchost in ('', 'localhost:'):
desthost = 'localhost:' if not srchost else ''
rmtree(TODIR)
checkit(
['-avse', SSH, f'--rsync-path={RSYNC_PEER}',
f'--files-from={filehost}{filelist}',
f'{srchost}{SCRATCHDIR}', f'{desthost}{TODIR}/'],
CHKDIR, TODIR,
)