| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| Yann Collet | 0d0f7e4 | 2016-05-25 10:58:11 +0200 | [diff] [blame] | 2 | """Test zstd interoperability between versions""" |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 3 | # Based on LZ4 version test script, by Takayuki Matsuoka |
| 4 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 5 | import filecmp |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 6 | import glob |
| 7 | import hashlib |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 8 | import os |
| 9 | import shutil |
| 10 | import sys |
| inikep | 4545671 | 2016-06-17 13:39:43 +0200 | [diff] [blame] | 11 | import subprocess |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 12 | from subprocess import Popen, PIPE |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 13 | |
| 14 | repo_url = 'https://github.com/Cyan4973/zstd.git' |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 15 | tmp_dir_name = 'tests/versionsTest' |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 16 | make_cmd = 'make' |
| 17 | git_cmd = 'git' |
| 18 | test_dat_src = 'README.md' |
| 19 | test_dat = 'test_dat' |
| 20 | head = 'vdevel' |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 21 | dict_source = 'dict_source' |
| 22 | dict_files = './zstd/programs/*.c ./zstd/lib/common/*.c ./zstd/lib/compress/*.c ./zstd/lib/decompress/*.c ./zstd/lib/dictBuilder/*.c ./zstd/lib/legacy/*.c ' |
| 23 | dict_files += './zstd/programs/*.h ./zstd/lib/common/*.h ./zstd/lib/compress/*.h ./zstd/lib/dictBuilder/*.h ./zstd/lib/legacy/*.h' |
| 24 | |
| 25 | |
| inikep | 2ef1650 | 2016-06-17 14:07:42 +0200 | [diff] [blame] | 26 | def execute(command, print_output=False, print_error=True, param_shell=False): |
| 27 | popen = Popen(command, stdout=PIPE, stderr=PIPE, shell=param_shell) |
| inikep | 4545671 | 2016-06-17 13:39:43 +0200 | [diff] [blame] | 28 | stdout_lines, stderr_lines = popen.communicate() |
| 29 | stderr_lines = stderr_lines.decode("utf-8") |
| 30 | stdout_lines = stdout_lines.decode("utf-8") |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 31 | if print_output: |
| 32 | print(stdout_lines) |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 33 | print(stderr_lines) |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 34 | if popen.returncode is not None and popen.returncode != 0: |
| 35 | if not print_output and print_error: |
| 36 | print(stderr_lines) |
| inikep | 4545671 | 2016-06-17 13:39:43 +0200 | [diff] [blame] | 37 | return popen.returncode |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 38 | |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 39 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 40 | def proc(cmd_args, pipe=True, dummy=False): |
| 41 | if dummy: |
| 42 | return |
| 43 | if pipe: |
| inikep | 4545671 | 2016-06-17 13:39:43 +0200 | [diff] [blame] | 44 | subproc = Popen(cmd_args, stdout=PIPE, stderr=PIPE) |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 45 | else: |
| inikep | 4545671 | 2016-06-17 13:39:43 +0200 | [diff] [blame] | 46 | subproc = Popen(cmd_args) |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 47 | return subproc.communicate() |
| 48 | |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 49 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 50 | def make(args, pipe=True): |
| 51 | return proc([make_cmd] + args, pipe) |
| 52 | |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 53 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 54 | def git(args, pipe=True): |
| 55 | return proc([git_cmd] + args, pipe) |
| 56 | |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 57 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 58 | def get_git_tags(): |
| 59 | stdout, stderr = git(['tag', '-l', 'v[0-9].[0-9].[0-9]']) |
| 60 | tags = stdout.decode('utf-8').split() |
| 61 | return tags |
| 62 | |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 63 | |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 64 | def create_dict(tag, dict_source_path): |
| 65 | dict_name = 'dict.' + tag |
| 66 | if not os.path.isfile(dict_name): |
| 67 | cFiles = glob.glob(dict_source_path + "/*.c") |
| 68 | hFiles = glob.glob(dict_source_path + "/*.h") |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 69 | if tag == 'v0.5.0': |
| 70 | result = execute('./dictBuilder.' + tag + ' ' + ' '.join(cFiles) + ' ' + ' '.join(hFiles) + ' -o ' + dict_name, print_output=False, param_shell=True) |
| 71 | else: |
| inikep | e16f656 | 2016-06-17 15:17:35 +0200 | [diff] [blame] | 72 | result = execute('./zstd.' + tag + ' -f --train ' + ' '.join(cFiles) + ' ' + ' '.join(hFiles) + ' -o ' + dict_name, print_output=False, param_shell=True) |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 73 | if result == 0: |
| inikep | 4545671 | 2016-06-17 13:39:43 +0200 | [diff] [blame] | 74 | print(dict_name + ' created') |
| 75 | else: |
| 76 | print('ERROR: creating of ' + dict_name + ' failed') |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 77 | else: |
| 78 | print(dict_name + ' already exists') |
| 79 | |
| 80 | |
| 81 | def dict_compress_sample(tag, sample): |
| 82 | dict_name = 'dict.' + tag |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 83 | DEVNULL = open(os.devnull, 'wb') |
| 84 | if subprocess.call(['./zstd.' + tag, '-D', dict_name, '-f', sample], stderr=DEVNULL) == 0: |
| 85 | os.rename(sample + '.zst', sample + '_01_64_' + tag + '_dictio.zst') |
| 86 | if subprocess.call(['./zstd.' + tag, '-D', dict_name, '-5f', sample], stderr=DEVNULL) == 0: |
| 87 | os.rename(sample + '.zst', sample + '_05_64_' + tag + '_dictio.zst') |
| 88 | if subprocess.call(['./zstd.' + tag, '-D', dict_name, '-9f', sample], stderr=DEVNULL) == 0: |
| 89 | os.rename(sample + '.zst', sample + '_09_64_' + tag + '_dictio.zst') |
| 90 | if subprocess.call(['./zstd.' + tag, '-D', dict_name, '-15f', sample], stderr=DEVNULL) == 0: |
| 91 | os.rename(sample + '.zst', sample + '_15_64_' + tag + '_dictio.zst') |
| 92 | if subprocess.call(['./zstd.' + tag, '-D', dict_name, '-18f', sample], stderr=DEVNULL) == 0: |
| 93 | os.rename(sample + '.zst', sample + '_18_64_' + tag + '_dictio.zst') |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 94 | # zstdFiles = glob.glob("*.zst*") |
| 95 | # print(zstdFiles) |
| 96 | print(tag + " : dict compression completed") |
| 97 | |
| 98 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 99 | def compress_sample(tag, sample): |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 100 | DEVNULL = open(os.devnull, 'wb') |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 101 | if subprocess.call(['./zstd.' + tag, '-f', sample], stderr=DEVNULL) == 0: |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 102 | os.rename(sample + '.zst', sample + '_01_64_' + tag + '_nodict.zst') |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 103 | if subprocess.call(['./zstd.' + tag, '-5f', sample], stderr=DEVNULL) == 0: |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 104 | os.rename(sample + '.zst', sample + '_05_64_' + tag + '_nodict.zst') |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 105 | if subprocess.call(['./zstd.' + tag, '-9f', sample], stderr=DEVNULL) == 0: |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 106 | os.rename(sample + '.zst', sample + '_09_64_' + tag + '_nodict.zst') |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 107 | if subprocess.call(['./zstd.' + tag, '-15f', sample], stderr=DEVNULL) == 0: |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 108 | os.rename(sample + '.zst', sample + '_15_64_' + tag + '_nodict.zst') |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 109 | if subprocess.call(['./zstd.' + tag, '-18f', sample], stderr=DEVNULL) == 0: |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 110 | os.rename(sample + '.zst', sample + '_18_64_' + tag + '_nodict.zst') |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 111 | # zstdFiles = glob.glob("*.zst*") |
| 112 | # print(zstdFiles) |
| Yann Collet | a5ad527 | 2016-06-03 15:41:51 +0200 | [diff] [blame] | 113 | print(tag + " : compression completed") |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 114 | |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 115 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 116 | # http://stackoverflow.com/a/19711609/2132223 |
| 117 | def sha1_of_file(filepath): |
| 118 | with open(filepath, 'rb') as f: |
| 119 | return hashlib.sha1(f.read()).hexdigest() |
| 120 | |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 121 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 122 | def remove_duplicates(): |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 123 | list_of_zst = sorted(glob.glob('*.zst')) |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 124 | for i, ref_zst in enumerate(list_of_zst): |
| 125 | if not os.path.isfile(ref_zst): |
| 126 | continue |
| Yann Collet | 0d0f7e4 | 2016-05-25 10:58:11 +0200 | [diff] [blame] | 127 | for j in range(i + 1, len(list_of_zst)): |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 128 | compared_zst = list_of_zst[j] |
| 129 | if not os.path.isfile(compared_zst): |
| 130 | continue |
| 131 | if filecmp.cmp(ref_zst, compared_zst): |
| 132 | os.remove(compared_zst) |
| 133 | print('duplicated : {} == {}'.format(ref_zst, compared_zst)) |
| 134 | |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 135 | |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 136 | def decompress_zst(tag): |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 137 | dec_error = 0 |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 138 | list_zst = sorted(glob.glob('*_nodict.zst')) |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 139 | for file_zst in list_zst: |
| Yann Collet | 0d0f7e4 | 2016-05-25 10:58:11 +0200 | [diff] [blame] | 140 | print(file_zst, end=' ') |
| 141 | print(tag, end=' ') |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 142 | file_dec = file_zst + '_d64_' + tag + '.dec' |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 143 | if tag <= 'v0.5.0': |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 144 | params = ['./zstd.' + tag, '-df', file_zst, file_dec] |
| 145 | else: |
| 146 | params = ['./zstd.' + tag, '-df', file_zst, '-o', file_dec] |
| inikep | 2ef1650 | 2016-06-17 14:07:42 +0200 | [diff] [blame] | 147 | if execute(params) == 0: |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 148 | if not filecmp.cmp(file_dec, test_dat): |
| 149 | print('ERR !! ') |
| 150 | dec_error = 1 |
| 151 | else: |
| 152 | print('OK ') |
| Yann Collet | 99b23ba | 2016-05-23 15:04:14 +0200 | [diff] [blame] | 153 | else: |
| 154 | print('command does not work') |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 155 | return dec_error |
| 156 | |
| Yann Collet | da4fe74 | 2016-05-23 15:43:17 +0200 | [diff] [blame] | 157 | |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 158 | def decompress_dict(tag): |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 159 | dec_error = 0 |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 160 | list_zst = sorted(glob.glob('*_dictio.zst')) |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 161 | for file_zst in list_zst: |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 162 | dict_tag = file_zst[0:len(file_zst)-11] # remove "_dictio.zst" |
| 163 | if head in dict_tag: # find vdevel |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 164 | dict_tag = head |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 165 | else: |
| 166 | dict_tag = dict_tag[dict_tag.rfind('v'):] |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 167 | if tag == 'v0.6.0' and dict_tag < 'v0.6.0': |
| 168 | continue |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 169 | dict_name = 'dict.' + dict_tag |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 170 | print(file_zst + ' ' + tag + ' dict=' + dict_tag, end=' ') |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 171 | file_dec = file_zst + '_d64_' + tag + '.dec' |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 172 | if tag <= 'v0.5.0': |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 173 | params = ['./zstd.' + tag, '-D', dict_name, '-df', file_zst, file_dec] |
| 174 | else: |
| 175 | params = ['./zstd.' + tag, '-D', dict_name, '-df', file_zst, '-o', file_dec] |
| inikep | 2ef1650 | 2016-06-17 14:07:42 +0200 | [diff] [blame] | 176 | if execute(params) == 0: |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 177 | if not filecmp.cmp(file_dec, test_dat): |
| 178 | print('ERR !! ') |
| 179 | dec_error = 1 |
| 180 | else: |
| 181 | print('OK ') |
| 182 | else: |
| 183 | print('command does not work') |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 184 | dec_error = 1 |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 185 | return dec_error |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 186 | |
| 187 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 188 | if __name__ == '__main__': |
| 189 | error_code = 0 |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 190 | base_dir = os.getcwd() + '/..' # /path/to/zstd |
| 191 | tmp_dir = base_dir + '/' + tmp_dir_name # /path/to/zstd/tests/versionsTest |
| 192 | clone_dir = tmp_dir + '/' + 'zstd' # /path/to/zstd/tests/versionsTest/zstd |
| 193 | dict_source_path = tmp_dir + '/' + dict_source # /path/to/zstd/tests/versionsTest/dict_source |
| 194 | programs_dir = base_dir + '/programs' # /path/to/zstd/programs |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 195 | os.makedirs(tmp_dir, exist_ok=True) |
| 196 | |
| 197 | # since Travis clones limited depth, we should clone full repository |
| 198 | if not os.path.isdir(clone_dir): |
| 199 | git(['clone', repo_url, clone_dir]) |
| 200 | |
| 201 | shutil.copy2(base_dir + '/' + test_dat_src, tmp_dir + '/' + test_dat) |
| 202 | |
| 203 | # Retrieve all release tags |
| 204 | print('Retrieve all release tags :') |
| 205 | os.chdir(clone_dir) |
| 206 | tags = get_git_tags() + [head] |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 207 | print(tags) |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 208 | |
| 209 | # Build all release zstd |
| 210 | for tag in tags: |
| 211 | os.chdir(base_dir) |
| Yann Collet | 803c05e | 2016-06-16 11:32:57 +0200 | [diff] [blame] | 212 | dst_zstd = '{}/zstd.{}'.format(tmp_dir, tag) # /path/to/zstd/tests/versionsTest/zstd.<TAG> |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 213 | if not os.path.isfile(dst_zstd) or tag == head: |
| 214 | if tag != head: |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 215 | r_dir = '{}/{}'.format(tmp_dir, tag) # /path/to/zstd/tests/versionsTest/<TAG> |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 216 | os.makedirs(r_dir, exist_ok=True) |
| 217 | os.chdir(clone_dir) |
| 218 | git(['--work-tree=' + r_dir, 'checkout', tag, '--', '.'], False) |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 219 | if tag == 'v0.5.0': |
| 220 | os.chdir(r_dir + '/dictBuilder') # /path/to/zstd/tests/versionsTest/v0.5.0/dictBuilder |
| 221 | make(['clean', 'dictBuilder'], False) |
| 222 | shutil.copy2('dictBuilder', '{}/dictBuilder.{}'.format(tmp_dir, tag)) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 223 | os.chdir(r_dir + '/programs') # /path/to/zstd/tests/versionsTest/<TAG>/programs |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 224 | make(['clean', 'zstd'], False) |
| 225 | else: |
| 226 | os.chdir(programs_dir) |
| 227 | make(['zstd'], False) |
| 228 | shutil.copy2('zstd', dst_zstd) |
| 229 | |
| 230 | # remove any remaining *.zst and *.dec from previous test |
| 231 | os.chdir(tmp_dir) |
| 232 | for compressed in glob.glob("*.zst"): |
| 233 | os.remove(compressed) |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 234 | for dec in glob.glob("*.dec"): |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 235 | os.remove(dec) |
| 236 | |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 237 | # copy *.c and *.h to a temporary directory ("dict_source") |
| 238 | if not os.path.isdir(dict_source_path): |
| 239 | os.mkdir(dict_source_path) |
| 240 | print('cp ' + dict_files + ' ' + dict_source_path) |
| inikep | 2ef1650 | 2016-06-17 14:07:42 +0200 | [diff] [blame] | 241 | execute('cp ' + dict_files + ' ' + dict_source_path, param_shell=True) |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 242 | |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 243 | print('Compress test.dat by all released zstd') |
| 244 | |
| Yann Collet | ebc13bc | 2016-05-25 10:12:39 +0200 | [diff] [blame] | 245 | error_code = 0 |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 246 | for tag in tags: |
| 247 | print(tag) |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 248 | if tag >= 'v0.5.0': |
| inikep | 24aa7b4 | 2016-06-16 14:15:32 +0200 | [diff] [blame] | 249 | create_dict(tag, dict_source_path) |
| inikep | 150152f | 2016-06-16 19:29:09 +0200 | [diff] [blame] | 250 | dict_compress_sample(tag, test_dat) |
| inikep | d1af4e6 | 2016-06-16 20:23:11 +0200 | [diff] [blame] | 251 | remove_duplicates() |
| 252 | error_code += decompress_dict(tag) |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 253 | compress_sample(tag, test_dat) |
| 254 | remove_duplicates() |
| inikep | 7e3597b | 2016-06-17 14:43:24 +0200 | [diff] [blame] | 255 | error_code += decompress_zst(tag) |
| Yann Collet | dca60f2 | 2016-05-23 14:23:55 +0200 | [diff] [blame] | 256 | |
| 257 | print('') |
| 258 | print('Enumerate different compressed files') |
| 259 | zstds = sorted(glob.glob('*.zst')) |
| 260 | for zstd in zstds: |
| 261 | print(zstd + ' : ' + repr(os.path.getsize(zstd)) + ', ' + sha1_of_file(zstd)) |
| 262 | |
| 263 | if error_code != 0: |
| 264 | print('==== ERROR !!! =====') |
| 265 | |
| 266 | sys.exit(error_code) |