from rsyncfns import (
SCRATCHDIR,
- check_perms, run_rsync, test_skipped,
+ check_perms, run_rsync, test_fail, test_skipped,
)
a transfer into a fresh subdir picks up the inherited perms."""
todir = SCRATCHDIR / dirname
todir.mkdir()
- # Clear any inherited default ACL first.
- subprocess.run(shlex.split(setfacl_nodef) + [str(todir)])
+ # Clear any inherited default ACL first -- and confirm it succeeded, so the
+ # no-default-ACL cases can't silently inherit the scratch dir's seeded
+ # default ACL and test the wrong base state.
+ if subprocess.run(shlex.split(setfacl_nodef) + [str(todir)]).returncode != 0:
+ test_fail(f"{dirname}: clearing the inherited default ACL failed")
if default_acl:
if '-k' in setfacl_nodef.split():
opts = ['-dm', default_acl]
from rsyncfns import (
CHKDIR, FROMDIR, RSYNC, SCRATCHDIR, SRCDIR, TMPDIR, TODIR,
- checkit, hands_setup, rmtree, run_rsync,
+ checkit, hands_setup, rmtree, run_rsync, test_fail,
)
rmtree(TODIR)
checkit(['-av', *maybe_inplace, f'--copy-dest={alt3dir}',
f'{FROMDIR}/', f'{TODIR}/'], FROMDIR, TODIR)
+ # --copy-dest must COPY the unchanged candidate, not hard-link it: the
+ # result is a distinct inode from the alt-dir source (this is the property
+ # that distinguishes --copy-dest from --link-dest, which checkit's tree
+ # comparison alone does not capture).
+ if os.stat(TODIR / 'likely').st_ino == os.stat(alt3dir / 'likely').st_ino:
+ test_fail(f"--copy-dest{' --inplace' if maybe_inplace else ''} "
+ "hard-linked 'likely' instead of copying it")
for srchost in ('', 'localhost:'):
desthost = 'localhost:' if not srchost else ''
push('-KRlptv', 'dir/file', 'localhost:', label="test 4 initial")
+old_content = (srcbase / 'dir' / 'file').read_bytes() # the backup should hold this
with open(srcbase / 'dir' / 'file', 'ab') as f:
f.write(b"backup update\n")
time.sleep(1)
assert_same("test 4 update", srcbase / 'dir' / 'file', home / 'real-dir' / 'file')
if not (home / 'real-dir' / 'file~').is_file():
test_fail("test 4: backup file was not created")
+# The backup must hold the OLD content, not just exist.
+if (home / 'real-dir' / 'file~').read_bytes() != old_content:
+ test_fail("test 4: backup file~ does not hold the pre-update content")
# Test 5: --inplace.