mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-06-07 21:58:06 -04:00
Replace the entire shell-based testsuite with Python. runtests.py
already drove the suite (it had replaced runtests.sh earlier); this
converts all 60 test scripts from *.test shell to *_test.py and adds
testsuite/rsyncfns.py as the shared helper module -- the Python
counterpart of the now-removed rsync.fns.
runtests.py:
* Discovers and runs both *.test and *_test.py; dispatches the
Python tests via the same python3 that runs the harness.
* Extends PYTHONPATH so tests can `import rsyncfns`.
testsuite/rsyncfns.py provides everything the ports need:
* environment wiring (scratchdir / srcdir / TOOLDIR / RSYNC /
TLS_ARGS, and HOME pointed at the per-test scratch dir);
* result reporting -- test_fail / test_skipped / test_xfail mapping
to the 0 / 1 / 77 / 78 exit-code convention;
* the transfer-and-verify helpers checkit, checkdiff, verify_dirs,
rsync_ls_lR, check_perms and the v_filt output filter;
* fixture builders hands_setup, build_symlinks, build_rsyncd_conf,
make_data_file, cp_p / cp_touch, makepath / rmtree.
All 60 tests are converted, including the four split-variant tests
that share one source via a Makefile-built symlink (chown/chown-fake,
devices/devices-fake, xattrs/xattrs-hlink, exclude/exclude-lsh);
Makefile.in's CHECK_SYMLINKS now points at the *_test.py names.
The dead rsync.fns shell library is removed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# Python rewrite of testsuite/chmod.test.
|
|
#
|
|
# Test that varied read-only and set[ug]id permissions transfer correctly
|
|
# both on first copy (whole-file) and on subsequent updates (delta).
|
|
|
|
import os
|
|
|
|
from rsyncfns import FROMDIR, TODIR, checkit, hands_setup
|
|
|
|
|
|
hands_setup()
|
|
|
|
# Three of these chmod modes use the sticky/setuid/setgid bits which some
|
|
# platforms refuse for non-root. The shell test tries them in descending
|
|
# order, falling back to plain mode on rejection.
|
|
def _try_chmods(path, modes):
|
|
for m in modes:
|
|
try:
|
|
os.chmod(path, m)
|
|
return
|
|
except PermissionError:
|
|
continue
|
|
# Final mode in the list is the no-special-bits fallback.
|
|
os.chmod(path, modes[-1])
|
|
|
|
|
|
os.chmod(FROMDIR / 'text', 0o440)
|
|
os.chmod(FROMDIR / 'dir' / 'text', 0o500)
|
|
_try_chmods(FROMDIR / 'dir' / 'subdir' / 'foobar.baz',
|
|
[0o6450, 0o2450, 0o1450, 0o450])
|
|
_try_chmods(FROMDIR / 'dir' / 'subdir' / 'subsubdir' / 'etc-ltr-list',
|
|
[0o2670, 0o1670, 0o670])
|
|
|
|
# First a normal whole-file copy.
|
|
checkit(['-avv', f'{FROMDIR}/', str(TODIR)], FROMDIR, TODIR)
|
|
|
|
# Then update through delta with -I (ignore times) so every file is
|
|
# touched again.
|
|
checkit(['-avvI', '--no-whole-file', f'{FROMDIR}/', str(TODIR)], FROMDIR, TODIR)
|