]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
testsuite: close minor assertion gaps
authorAndrew Tridgell <andrew@tridgell.net>
Sun, 24 May 2026 22:23:11 +0000 (08:23 +1000)
committerAndrew Tridgell <andrew@tridgell.net>
Mon, 25 May 2026 21:43:00 +0000 (07:43 +1000)
  symlink-dirlink-basis  assert the --backup file holds the pre-update content,
                         not merely that the backup file exists.
  acls-default           check that clearing the inherited default ACL actually
                         succeeded, so the no-default-ACL cases can't silently
                         test against the scratch dir's seeded default ACL.
  alt-dest               assert --copy-dest produces a distinct inode from the
                         alt-dir candidate (a copy, not a hard link) -- the
                         property that distinguishes it from --link-dest, which
                         checkit's tree comparison alone doesn't capture.

(crtimes' "independently pin the historical create time" gap is left as-is: the
touch-trick pinning is APFS-specific and not locally verifiable, and a mistuned
probe would make the test skip on macOS and break its expected-skip set.)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
testsuite/acls-default_test.py
testsuite/alt-dest_test.py
testsuite/symlink-dirlink-basis_test.py

index 66c8cef4108a93dab23ab3fd9cc291dfef0008fb..e780de66d64a5a1f2555a28aac8fee6ca5256982 100644 (file)
@@ -12,7 +12,7 @@ import subprocess
 
 from rsyncfns import (
     SCRATCHDIR,
-    check_perms, run_rsync, test_skipped,
+    check_perms, run_rsync, test_fail, test_skipped,
 )
 
 
@@ -41,8 +41,11 @@ def testit(dirname, default_acl, file_expected, prog_expected):
     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]
index 7530bd5a27ae68183c3446492fdc4bc3bdff2141..07389d456efb9a9b05bbda1a76a550111a458d0c 100644 (file)
@@ -12,7 +12,7 @@ import time
 
 from rsyncfns import (
     CHKDIR, FROMDIR, RSYNC, SCRATCHDIR, SRCDIR, TMPDIR, TODIR,
-    checkit, hands_setup, rmtree, run_rsync,
+    checkit, hands_setup, rmtree, run_rsync, test_fail,
 )
 
 
@@ -62,6 +62,13 @@ for maybe_inplace in ([], ['--inplace']):
     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 ''
index fd880144ac332352549f08cd3bd73b9f8fc1f5f0..8c52e13f9cea7d6ed257798f0f5ea3b076a54fa2 100644 (file)
@@ -132,6 +132,7 @@ make_testfile(srcbase / 'dir' / 'file')
 
 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)
@@ -141,6 +142,9 @@ push('-KRlptv', '--backup', 'dir/file', 'localhost:', label="test 4 update")
 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.