]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
testsuite: cover groupmap empty source matching
authorZen Dodd <mail@steadytao.com>
Sat, 6 Jun 2026 04:03:30 +0000 (14:03 +1000)
committerAndrew Tridgell <andrew@tridgell.net>
Sat, 6 Jun 2026 04:29:15 +0000 (14:29 +1000)
testsuite/ownership-depth_test.py

index 9a5d5ed80e0a90fcfb30fac481ce2b851c1a818f..f4df789afbb82b9485035e39052d10a742451cdc 100644 (file)
@@ -11,6 +11,7 @@ we belong to; the uid side then needs root and is skipped.
 # remap only runs as root, so a non-root run exercises the group-only path too.
 fleet_nonroot = True
 
+import grp
 import os
 
 from rsyncfns import (
@@ -45,6 +46,13 @@ def assert_all(entries, *, gid=None, uid=None, label=''):
             test_fail(f"{label}: owner of {rel} is {st.st_uid}, expected {uid}")
 
 
+try:
+    grp.getgrgid(prim)
+    prim_has_name = True
+except KeyError:
+    prim_has_name = False
+
+
 if is_root:
     # Root may assign any numeric id (it need not exist); pick targets that
     # differ from the source's ids so the remap is observable.
@@ -55,6 +63,20 @@ if is_root:
     run_rsync('-a', f'--groupmap={prim}:{target_gid}', f'{src}/', f'{TODIR}/')
     assert_all(entries, gid=target_gid, label='--groupmap (root)')
 
+    entries = seed()
+    run_rsync('-a', f'--groupmap=*:{target_gid}', f'{src}/', f'{TODIR}/')
+    assert_all(entries, gid=target_gid, label='--groupmap wildcard (root)')
+
+    if prim_has_name:
+        entries = seed()
+        run_rsync('-a', f'--groupmap=:{target_gid}', f'{src}/', f'{TODIR}/')
+        assert_all(entries, gid=prim, label='--groupmap empty named group (root)')
+
+    entries = seed()
+    run_rsync('-a', '--numeric-ids', f'--groupmap=:{target_gid}',
+              f'{src}/', f'{TODIR}/')
+    assert_all(entries, gid=target_gid, label='--groupmap empty nameless group (root)')
+
     entries = seed()
     run_rsync('-a', f'--chown=:{target_gid}', f'{src}/', f'{TODIR}/')
     assert_all(entries, gid=target_gid, label='--chown group (root)')
@@ -79,6 +101,19 @@ else:
     run_rsync('-a', f'--groupmap={prim}:{sec}', f'{src}/', f'{TODIR}/')
     assert_all(entries, gid=sec, label='--groupmap')
 
+    entries = seed()
+    run_rsync('-a', f'--groupmap=*:{sec}', f'{src}/', f'{TODIR}/')
+    assert_all(entries, gid=sec, label='--groupmap wildcard')
+
+    if prim_has_name:
+        entries = seed()
+        run_rsync('-a', f'--groupmap=:{sec}', f'{src}/', f'{TODIR}/')
+        assert_all(entries, gid=prim, label='--groupmap empty named group')
+
+    entries = seed()
+    run_rsync('-a', '--numeric-ids', f'--groupmap=:{sec}', f'{src}/', f'{TODIR}/')
+    assert_all(entries, gid=sec, label='--groupmap empty nameless group')
+
     entries = seed()
     run_rsync('-a', f'--chown=:{sec}', f'{src}/', f'{TODIR}/')
     assert_all(entries, gid=sec, label='--chown group')