mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-06-08 06:05:57 -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>
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# Python rewrite of testsuite/ssh-basic.test.
|
|
#
|
|
# Basic two-step "remote shell" transfer via lsh.sh (or real ssh if
|
|
# rsync_enable_ssh_tests=yes is set in shconfig). Confirms that an -e
|
|
# RSH transfer reproduces the source tree on the destination, and that
|
|
# a follow-up --delete pass cleans up after a destination-side rename.
|
|
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
|
|
from rsyncfns import (
|
|
FROMDIR, SRCDIR, TODIR,
|
|
checkit, hands_setup, runtest, test_skipped,
|
|
)
|
|
|
|
|
|
SSH = str(SRCDIR / 'support' / 'lsh.sh')
|
|
|
|
# Allow opting into real ssh via the shconfig variable, like the shell test.
|
|
if os.environ.get('rsync_enable_ssh_tests') == 'yes':
|
|
real_ssh = shutil.which('ssh')
|
|
if real_ssh:
|
|
SSH = real_ssh
|
|
|
|
probe = subprocess.run(
|
|
[SSH, '-oBatchMode yes', 'localhost', 'echo', 'yes'],
|
|
capture_output=True, text=True,
|
|
)
|
|
if probe.stdout.strip() != 'yes':
|
|
test_skipped(
|
|
"Skipping SSH tests because ssh connection to localhost not authorised"
|
|
)
|
|
|
|
print(f"Using remote shell: {SSH}")
|
|
|
|
hands_setup()
|
|
|
|
# RSYNC may be a multi-word command line; pass it through --rsync-path.
|
|
from rsyncfns import RSYNC, RSYNC_PEER
|
|
|
|
|
|
def _basic():
|
|
checkit(['-avH', '-e', SSH, f'--rsync-path={RSYNC_PEER}',
|
|
f'{FROMDIR}/', f'localhost:{TODIR}'], FROMDIR, TODIR)
|
|
|
|
|
|
def _delete_after_rename():
|
|
shutil.move(str(TODIR / 'text'), str(TODIR / 'ThisShouldGo'))
|
|
checkit(['--delete', '-avH', '-e', SSH, f'--rsync-path={RSYNC_PEER}',
|
|
f'{FROMDIR}/', f'localhost:{TODIR}'], FROMDIR, TODIR)
|
|
|
|
|
|
runtest("ssh: basic test", _basic)
|
|
runtest("ssh: renamed file", _delete_after_rename)
|