29
29
test_dat = 'test_dat'
30
30
head = 'vdevel'
31
31
dict_source = 'dict_source'
32
- 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 '
33
- dict_files += './zstd/programs/*.h ./zstd/lib/common/*.h ./zstd/lib/compress/*.h ./zstd/lib/dictBuilder/*.h ./zstd/lib/legacy/*.h'
32
+ dict_globs = [
33
+ 'programs/*.c' ,
34
+ 'lib/common/*.c' ,
35
+ 'lib/compress/*.c' ,
36
+ 'lib/decompress/*.c' ,
37
+ 'lib/dictBuilder/*.c' ,
38
+ 'lib/legacy/*.c' ,
39
+ 'programs/*.h' ,
40
+ 'lib/common/*.h' ,
41
+ 'lib/compress/*.h' ,
42
+ 'lib/dictBuilder/*.h' ,
43
+ 'lib/legacy/*.h'
44
+ ]
34
45
35
46
36
47
def execute (command , print_output = False , print_error = True , param_shell = False ):
@@ -85,6 +96,7 @@ def create_dict(tag, dict_source_path):
85
96
result = execute ('./zstd.' + tag + ' -f --train ' + ' ' .join (cFiles ) + ' ' + ' ' .join (hFiles ) + ' -o ' + dict_name , print_output = False , param_shell = True )
86
97
if result == 0 :
87
98
print (dict_name + ' created' )
99
+ assert os .path .isfile (dict_name )
88
100
else :
89
101
raise RuntimeError ('ERROR: creating of ' + dict_name + ' failed' )
90
102
else :
@@ -103,12 +115,15 @@ def zstd(tag, args, input_file, output_file):
103
115
print ("Running: '{}', input={}, output={}" .format (
104
116
' ' .join (cmd ), input_file , output_file
105
117
))
106
- subprocess .check_call (cmd , stdin = i , stdout = o )
118
+ result = subprocess .run (cmd , stdin = i , stdout = o , stderr = subprocess .PIPE )
119
+ print ("Stderr: {}" .format (result .stderr .decode ("ascii" )))
120
+ result .check_returncode ()
107
121
108
122
109
123
def dict_compress_sample (tag , sample ):
110
124
dict_name = 'dict.' + tag
111
- zstd (tag , ['-D' , dict_name , '-1' ], sample , sample + '_01_64_' + tag + '_dictio.zst' )
125
+ verbose = ['-v' , '-v' , '-v' ]
126
+ zstd (tag , ['-D' , dict_name , '-1' ] + verbose , sample , sample + '_01_64_' + tag + '_dictio.zst' )
112
127
zstd (tag , ['-D' , dict_name , '-3' ], sample , sample + '_03_64_' + tag + '_dictio.zst' )
113
128
zstd (tag , ['-D' , dict_name , '-5' ], sample , sample + '_05_64_' + tag + '_dictio.zst' )
114
129
zstd (tag , ['-D' , dict_name , '-9' ], sample , sample + '_09_64_' + tag + '_dictio.zst' )
@@ -246,8 +261,12 @@ def decompress_dict(tag):
246
261
# copy *.c and *.h to a temporary directory ("dict_source")
247
262
if not os .path .isdir (dict_source_path ):
248
263
os .mkdir (dict_source_path )
249
- print ('cp ' + dict_files + ' ' + dict_source_path )
250
- execute ('cp ' + dict_files + ' ' + dict_source_path , param_shell = True )
264
+ for dict_glob in dict_globs :
265
+ files = glob .glob (dict_glob , root_dir = base_dir )
266
+ for file in files :
267
+ file = os .path .join (base_dir , file )
268
+ print ("copying " + file + " to " + dict_source_path )
269
+ shutil .copy (file , dict_source_path )
251
270
252
271
print ('-----------------------------------------------' )
253
272
print ('Compress test.dat by all released zstd' )
0 commit comments