From: Nick Terrell Date: Tue, 24 Jan 2023 04:23:43 +0000 (-0800) Subject: [version-test] Work around bugs in v0.7.3 dict builder X-Git-Tag: v1.5.4^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=321490cd5b9863433b3d44816d04012874e5ecdb;p=thirdparty%2Fzstd.git [version-test] Work around bugs in v0.7.3 dict builder Before calling a dictionary good, make sure that it can compress an input. If v0.7.3 rejects v0.7.3's dictionary, fall back to the v1.0 dictionary. This is not the job of the verison test to test it, because we cannot fix this code. --- diff --git a/tests/test-zstd-versions.py b/tests/test-zstd-versions.py index d6784d615..1bcf39e2b 100755 --- a/tests/test-zstd-versions.py +++ b/tests/test-zstd-versions.py @@ -85,6 +85,18 @@ def get_git_tags(): return tags +def dict_ok(tag, dict_name, sample): + if not os.path.isfile(dict_name): + return False + try: + cmd = ['./zstd.' + tag, '-D', dict_name] + with open(sample, "rb") as i: + subprocess.check_call(cmd, stdin=i, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return True + except: + return False + + def create_dict(tag, dict_source_path, fallback_tag=None): dict_name = 'dict.' + tag if not os.path.isfile(dict_name): @@ -96,7 +108,7 @@ def create_dict(tag, dict_source_path, fallback_tag=None): result = execute('./dictBuilder.' + tag + ' ' + ' '.join(files) + ' -o ' + dict_name, print_output=False, param_shell=True) else: result = execute('./zstd.' + tag + ' -f --train ' + ' '.join(files) + ' -o ' + dict_name, print_output=False, param_shell=True) - if result == 0 and os.path.isfile(dict_name): + if result == 0 and dict_ok(tag, dict_name, files[0]): print(dict_name + ' created') elif fallback_tag is not None: fallback_dict_name = 'dict.' + fallback_tag