mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-07-30 23:36:21 -04:00
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>
105 lines
2.8 KiB
Python
105 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
# Python rewrite of testsuite/00-hello.test.
|
|
#
|
|
# Foundational smoke test: --version / --info=help / --debug=help all
|
|
# work, plus a round-trip transfer of a directory whose name contains
|
|
# shell-special characters via the lsh.sh remote-shell stand-in.
|
|
|
|
import os
|
|
|
|
from rsyncfns import (
|
|
FROMDIR, RSYNC, RSYNC_PEER, SRCDIR, TODIR,
|
|
checkit, run_rsync, test_fail,
|
|
)
|
|
|
|
|
|
# Set RSYNC_RSH so rsync picks up lsh.sh for the "lh:" hosts below.
|
|
os.environ['RSYNC_RSH'] = str(SRCDIR / 'support' / 'lsh.sh')
|
|
|
|
# Basic help dumps must not crash.
|
|
if run_rsync('--version', check=False).returncode != 0:
|
|
test_fail('--version output failed')
|
|
if run_rsync('--info=help', check=False).returncode != 0:
|
|
test_fail('--info=help output failed')
|
|
if run_rsync('--debug=help', check=False).returncode != 0:
|
|
test_fail('--debug=help output failed')
|
|
|
|
weird_name = "A weird)name"
|
|
|
|
FROMDIR.mkdir(parents=True, exist_ok=True)
|
|
weird_dir = FROMDIR / weird_name
|
|
weird_dir.mkdir()
|
|
|
|
|
|
def append_line(line: str) -> None:
|
|
print(line)
|
|
with open(weird_dir / 'file', 'a') as f:
|
|
f.write(line + '\n')
|
|
|
|
|
|
def copy_weird(args: list, src_host: str, dst_host: str) -> None:
|
|
checkit(
|
|
[*args, f'--rsync-path={RSYNC_PEER}',
|
|
f'{src_host}{weird_dir}/',
|
|
f'{dst_host}{TODIR / weird_name}'],
|
|
FROMDIR, TODIR,
|
|
)
|
|
|
|
|
|
append_line('test1')
|
|
checkit(['-ai', f'{FROMDIR}/', f'{TODIR}/'], FROMDIR, TODIR)
|
|
|
|
append_line('test2')
|
|
copy_weird(['-ai'], 'lh:', '')
|
|
|
|
append_line('test3')
|
|
copy_weird(['-ai'], '', 'lh:')
|
|
|
|
append_line('test4')
|
|
copy_weird(['-ais'], 'lh:', '')
|
|
|
|
append_line('test5')
|
|
copy_weird(['-ais'], '', 'lh:')
|
|
|
|
# test6: --old-args lets two whitespace-separated names go through as a
|
|
# single "one two" remote argument to be re-split by the remote shell.
|
|
print('test6')
|
|
(FROMDIR / 'one').touch()
|
|
(FROMDIR / 'two').touch()
|
|
|
|
saved = os.getcwd()
|
|
os.chdir(FROMDIR)
|
|
try:
|
|
run_rsync('-ai', '--old-args', f'--rsync-path={RSYNC_PEER}',
|
|
'lh:one two', f'{TODIR}/')
|
|
finally:
|
|
os.chdir(saved)
|
|
|
|
if not (TODIR / 'one').is_file() or not (TODIR / 'two').is_file():
|
|
test_fail("old-args copy of 'one two' failed")
|
|
|
|
# test7: the RSYNC_OLD_ARGS=1 env var should be equivalent to --old-args.
|
|
print('test7')
|
|
(TODIR / 'one').unlink()
|
|
(TODIR / 'two').unlink()
|
|
|
|
env = os.environ.copy()
|
|
env['RSYNC_OLD_ARGS'] = '1'
|
|
import subprocess
|
|
from rsyncfns import rsync_argv
|
|
|
|
os.chdir(FROMDIR)
|
|
try:
|
|
subprocess.run(
|
|
rsync_argv('-ai', f'--rsync-path={RSYNC_PEER}',
|
|
'lh:one two', f'{TODIR}/'),
|
|
env=env, check=True,
|
|
)
|
|
finally:
|
|
os.chdir(saved)
|
|
|
|
# check=True only proves a zero exit; confirm the env-var path actually copied
|
|
# both files (as the explicit --old-args case above does).
|
|
if not (TODIR / 'one').is_file() or not (TODIR / 'two').is_file():
|
|
test_fail("RSYNC_OLD_ARGS=1 copy of 'one two' failed")
|