mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-11-05 19:43:25 -05:00
testsuite: handle locale-specific number separators (#1142)
* correct some locale dependent test cases comparing decimal numbers in human readable form * add __pycache__ to .gitignore
This commit is contained in:
1 parent
fd96bc7e8a
commit
8718cd28c5
5 files changed
+21
-18
No files matched your search
@@ -13,6 +13,7 @@ config.h.in.old
|
|||||||
config.log
|
config.log
|
||||||
config.status
|
config.status
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
|
__pycache__
|
||||||
/proto.h
|
/proto.h
|
||||||
/proto.h-tstamp
|
/proto.h-tstamp
|
||||||
/rsync*.[15]
|
/rsync*.[15]
|
||||||
|
|||||||
@@ -55,15 +55,15 @@ def make_block(perturb_offset: int = -1, fill: int = C_BYTE) -> bytes:
|
|||||||
|
|
||||||
def parse_stats(out: str):
|
def parse_stats(out: str):
|
||||||
m_delta = re.search(r'hash_hits=(\d+)\s+false_alarms=(\d+)', out)
|
m_delta = re.search(r'hash_hits=(\d+)\s+false_alarms=(\d+)', out)
|
||||||
m_lit = re.search(r'Literal data:\s*([\d,]+)\s*bytes', out)
|
m_lit = re.search(r'Literal data:\s*([\d,.]+)\s*bytes', out)
|
||||||
m_match = re.search(r'Matched data:\s*([\d,]+)\s*bytes', out)
|
m_match = re.search(r'Matched data:\s*([\d,.]+)\s*bytes', out)
|
||||||
if not m_delta or not m_lit or not m_match:
|
if not m_delta or not m_lit or not m_match:
|
||||||
test_fail(f"could not find deltasum/stats in rsync output:\n{out}")
|
test_fail(f"could not find deltasum/stats in rsync output:\n{out}")
|
||||||
return (
|
return (
|
||||||
int(m_delta.group(1)),
|
int(m_delta.group(1)),
|
||||||
int(m_delta.group(2)),
|
int(m_delta.group(2)),
|
||||||
int(m_lit.group(1).replace(',', '')),
|
int(m_lit.group(1).replace(',', '').replace('.', '')),
|
||||||
int(m_match.group(1).replace(',', '')),
|
int(m_match.group(1).replace(',', '').replace('.', '')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,15 +39,15 @@ def make_block(perturb_offset: int = -1, fill: int = C_BYTE) -> bytes:
|
|||||||
|
|
||||||
def parse_stats(out: str):
|
def parse_stats(out: str):
|
||||||
m_delta = re.search(r'hash_hits=(\d+)\s+false_alarms=(\d+)', out)
|
m_delta = re.search(r'hash_hits=(\d+)\s+false_alarms=(\d+)', out)
|
||||||
m_lit = re.search(r'Literal data:\s*([\d,]+)\s*bytes', out)
|
m_lit = re.search(r'Literal data:\s*([\d,.]+)\s*bytes', out)
|
||||||
m_match = re.search(r'Matched data:\s*([\d,]+)\s*bytes', out)
|
m_match = re.search(r'Matched data:\s*([\d,.]+)\s*bytes', out)
|
||||||
if not m_delta or not m_lit or not m_match:
|
if not m_delta or not m_lit or not m_match:
|
||||||
test_fail(f"could not find deltasum/stats in rsync output:\n{out}")
|
test_fail(f"could not find deltasum/stats in rsync output:\n{out}")
|
||||||
return (
|
return (
|
||||||
int(m_delta.group(1)),
|
int(m_delta.group(1)),
|
||||||
int(m_delta.group(2)),
|
int(m_delta.group(2)),
|
||||||
int(m_lit.group(1).replace(',', '')),
|
int(m_lit.group(1).replace(',', '').replace('.', '')),
|
||||||
int(m_match.group(1).replace(',', '')),
|
int(m_match.group(1).replace(',', '').replace('.', '')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ verify_dirs(src, TODIR, label='--quiet still transferred')
|
|||||||
# --- --progress shows a percentage ------------------------------------------
|
# --- --progress shows a percentage ------------------------------------------
|
||||||
rmtree(TODIR)
|
rmtree(TODIR)
|
||||||
p = out('-a', '--progress', f'{src}/', f'{TODIR}/')
|
p = out('-a', '--progress', f'{src}/', f'{TODIR}/')
|
||||||
progress_re = r'[\d.,]+B\s+100%\s+[\d.,]+(?:[KMGTPE]i?)?B/s\s+\d+:\d\d:\d\d'
|
progress_re = r'[\d,.]+B\s+100%\s+[\d,.]+(?:[KMGTPE]i?)?B/s\s+\d+:\d\d:\d\d'
|
||||||
if not re.search(progress_re, p.stdout):
|
if not re.search(progress_re, p.stdout):
|
||||||
test_fail(f"--progress did not show the expected final shape:\n{p.stdout}")
|
test_fail(f"--progress did not show the expected final shape:\n{p.stdout}")
|
||||||
|
|
||||||
@@ -116,17 +116,17 @@ make_data_file(src / 'big', 50_000)
|
|||||||
plain = out('-a', '--stats', f'{src}/', f'{TODIR}/').stdout
|
plain = out('-a', '--stats', f'{src}/', f'{TODIR}/').stdout
|
||||||
rmtree(TODIR)
|
rmtree(TODIR)
|
||||||
human = out('-a', '-h', '--stats', f'{src}/', f'{TODIR}/').stdout
|
human = out('-a', '-h', '--stats', f'{src}/', f'{TODIR}/').stdout
|
||||||
suffix_re = r'Total file size: [\d.,]+[KMG]'
|
suffix_re = r'Total file size: [\d,.]+[KMG]'
|
||||||
if not re.search(suffix_re, human):
|
if not re.search(suffix_re, human):
|
||||||
test_fail(f"-h did not use a human-readable unit suffix:\n{human}")
|
test_fail(f"-h did not use a human-readable unit suffix:\n{human}")
|
||||||
if re.search(suffix_re, plain):
|
if re.search(suffix_re, plain):
|
||||||
test_fail(f"--stats without -h unexpectedly used a unit suffix:\n{plain}")
|
test_fail(f"--stats without -h unexpectedly used a unit suffix:\n{plain}")
|
||||||
|
|
||||||
for label, options, progress_re in (
|
for label, options, progress_re in (
|
||||||
('default', (), r'50[,.]000B\s+100%\s+[\d.,]+[KMGTPE]B/s'),
|
('default', (), r'50[,.]000B\s+100%\s+[\d,.]+[KMGTPE]B/s'),
|
||||||
('--no-h', ('--no-h',), r'50000B\s+100%\s+\d+B/s'),
|
('--no-h', ('--no-h',), r'50000B\s+100%\s+\d+B/s'),
|
||||||
('-h', ('-h',), r'50\.0KB\s+100%\s+[\d.,]+[KMGTPE]B/s'),
|
('-h', ('-h',), r'50[,.]0KB\s+100%\s+[\d,.]+[KMGTPE]B/s'),
|
||||||
('-hh', ('-hh',), r'48\.8KiB\s+100%\s+[\d.,]+[KMGTPE]iB/s'),
|
('-hh', ('-hh',), r'48[,.]8KiB\s+100%\s+[\d,.]+[KMGTPE]iB/s'),
|
||||||
):
|
):
|
||||||
rmtree(TODIR)
|
rmtree(TODIR)
|
||||||
progress = out('-a', '--progress', *options, f'{src}/', f'{TODIR}/').stdout
|
progress = out('-a', '--progress', *options, f'{src}/', f'{TODIR}/').stdout
|
||||||
@@ -135,7 +135,7 @@ for label, options, progress_re in (
|
|||||||
|
|
||||||
rmtree(TODIR)
|
rmtree(TODIR)
|
||||||
human_binary = out('-a', '-hh', '--stats', f'{src}/', f'{TODIR}/').stdout
|
human_binary = out('-a', '-hh', '--stats', f'{src}/', f'{TODIR}/').stdout
|
||||||
if 'Total file size: 48.8Ki bytes' not in human_binary:
|
if not re.search(r'Total file size: 48[,.]8Ki bytes', human_binary):
|
||||||
test_fail(f"-hh did not use dynamic binary-unit precision:\n{human_binary}")
|
test_fail(f"-hh did not use dynamic binary-unit precision:\n{human_binary}")
|
||||||
|
|
||||||
rmtree(src)
|
rmtree(src)
|
||||||
@@ -143,7 +143,7 @@ rmtree(TODIR)
|
|||||||
makepath(src)
|
makepath(src)
|
||||||
make_data_file(src / 'threshold', 1024)
|
make_data_file(src / 'threshold', 1024)
|
||||||
threshold = out('-a', '-hh', '--stats', f'{src}/', f'{TODIR}/').stdout
|
threshold = out('-a', '-hh', '--stats', f'{src}/', f'{TODIR}/').stdout
|
||||||
if 'Total file size: 1.00Ki bytes' not in threshold:
|
if not re.search(r'Total file size: 1[,.]00Ki bytes', threshold):
|
||||||
test_fail(f"-hh did not show an exact-threshold binary unit:\n{threshold}")
|
test_fail(f"-hh did not show an exact-threshold binary unit:\n{threshold}")
|
||||||
|
|
||||||
rmtree(src)
|
rmtree(src)
|
||||||
@@ -151,7 +151,7 @@ rmtree(TODIR)
|
|||||||
makepath(src)
|
makepath(src)
|
||||||
make_data_file(src / 'below-threshold', 1000)
|
make_data_file(src / 'below-threshold', 1000)
|
||||||
below_threshold = out('-a', '-hh', '--stats', f'{src}/', f'{TODIR}/').stdout
|
below_threshold = out('-a', '-hh', '--stats', f'{src}/', f'{TODIR}/').stdout
|
||||||
if 'Total file size: 1,000 bytes' not in below_threshold:
|
if not re.search(r'Total file size: 1[,.]000 bytes', below_threshold):
|
||||||
test_fail("-hh should preserve raw byte formatting below the binary-unit "
|
test_fail("-hh should preserve raw byte formatting below the binary-unit "
|
||||||
f"threshold:\n{below_threshold}")
|
f"threshold:\n{below_threshold}")
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ makepath(src)
|
|||||||
for i in range(999):
|
for i in range(999):
|
||||||
(src / f'f{i}').touch()
|
(src / f'f{i}').touch()
|
||||||
counts = out('-a', '-hh', '--progress', '--no-i-r', f'{src}/', f'{TODIR}/').stdout
|
counts = out('-a', '-hh', '--progress', '--no-i-r', f'{src}/', f'{TODIR}/').stdout
|
||||||
if '1,000 files to consider' not in counts:
|
if not re.search(r'1[,.]000 files to consider', counts):
|
||||||
test_fail(f"file-list count was not grouped:\n{counts}")
|
test_fail(f"file-list count was not grouped:\n{counts}")
|
||||||
rmtree(TODIR)
|
rmtree(TODIR)
|
||||||
counts = out('-a', '--no-h', '--progress', '--no-i-r', f'{src}/', f'{TODIR}/').stdout
|
counts = out('-a', '--no-h', '--progress', '--no-i-r', f'{src}/', f'{TODIR}/').stdout
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import os
|
|||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from rsyncfns import (
|
from rsyncfns import (
|
||||||
@@ -82,7 +83,8 @@ base_file.write_bytes(os.urandom(4 * 1024 * 1024))
|
|||||||
proc = run_client(base_file, dest_full)
|
proc = run_client(base_file, dest_full)
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
test_fail(f"rsync failed on full write test:\n{proc.stdout}")
|
test_fail(f"rsync failed on full write test:\n{proc.stdout}")
|
||||||
if "Number of 4 KiB logical blocks touched: 1,024\n" not in proc.stdout:
|
#if "Number of 4 KiB logical blocks touched: 1,024\n" not in proc.stdout:
|
||||||
|
if not re.search(r'Number of 4 KiB logical blocks touched: 1[,.]024\n', proc.stdout):
|
||||||
test_fail(f"Full write check failed! Expected 1,024 blocks. Output:\n{proc.stdout}")
|
test_fail(f"Full write check failed! Expected 1,024 blocks. Output:\n{proc.stdout}")
|
||||||
|
|
||||||
# TEST 5: Sparse File Write (Hole skipping)
|
# TEST 5: Sparse File Write (Hole skipping)
|
||||||
|
|||||||
Reference in new issue
Block a user