]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
cleaner versionsTest script and output
authorYann Collet <yann.collet.73@gmail.com>
Wed, 25 May 2016 08:12:39 +0000 (10:12 +0200)
committerYann Collet <yann.collet.73@gmail.com>
Wed, 25 May 2016 08:12:39 +0000 (10:12 +0200)
versionsTest/test-zstd-versions.py

index b18c3d3c2123fb242d503af42ec0896c29458f66..5b3d9463b1f9999b9cd4490601eed2b2d28b4bc2 100644 (file)
@@ -2,13 +2,13 @@
 
 # Based on LZ4 version test script, by Takayuki Matsuoka
 
-import glob
-import subprocess
 import filecmp
+import glob
+import hashlib
 import os
 import shutil
+import subprocess
 import sys
-import hashlib
 
 repo_url = 'https://github.com/Cyan4973/zstd.git'
 tmp_dir_name = 'versionsTest/zstdtest'
@@ -18,6 +18,7 @@ test_dat_src = 'README.md'
 test_dat = 'test_dat'
 head = 'vdevel'
 
+
 def proc(cmd_args, pipe=True, dummy=False):
     if dummy:
         return
@@ -29,40 +30,46 @@ def proc(cmd_args, pipe=True, dummy=False):
         subproc = subprocess.Popen(cmd_args)
     return subproc.communicate()
 
+
 def make(args, pipe=True):
     return proc([make_cmd] + args, pipe)
 
+
 def git(args, pipe=True):
     return proc([git_cmd] + args, pipe)
 
+
 def get_git_tags():
     stdout, stderr = git(['tag', '-l', 'v[0-9].[0-9].[0-9]'])
     tags = stdout.decode('utf-8').split()
     return tags
 
+
 def compress_sample(tag, sample):
     try:
-        from subprocess import DEVNULL # py3k
+        from subprocess import DEVNULL  # py3k
     except ImportError:
         DEVNULL = open(os.devnull, 'wb')
-    if subprocess.call(['./zstd.' + tag, '-f'  ,  sample], stderr=DEVNULL)==0:
+    if subprocess.call(['./zstd.' + tag, '-f',   sample], stderr=DEVNULL) == 0:
         os.rename(sample + '.zst', sample + '_01_64_' + tag + '.zst')
-    if subprocess.call(['./zstd.' + tag, '-5f' ,  sample], stderr=DEVNULL)==0:
+    if subprocess.call(['./zstd.' + tag, '-5f',  sample], stderr=DEVNULL) == 0:
         os.rename(sample + '.zst', sample + '_05_64_' + tag + '.zst')
-    if subprocess.call(['./zstd.' + tag, '-9f' ,  sample], stderr=DEVNULL)==0 :
+    if subprocess.call(['./zstd.' + tag, '-9f',  sample], stderr=DEVNULL) == 0:
         os.rename(sample + '.zst', sample + '_09_64_' + tag + '.zst')
-    if subprocess.call(['./zstd.' + tag, '-15f',  sample], stderr=DEVNULL)==0 :
+    if subprocess.call(['./zstd.' + tag, '-15f', sample], stderr=DEVNULL) == 0:
         os.rename(sample + '.zst', sample + '_15_64_' + tag + '.zst')
-    if subprocess.call(['./zstd.' + tag, '-18f',  sample], stderr=DEVNULL)==0:
+    if subprocess.call(['./zstd.' + tag, '-18f', sample], stderr=DEVNULL) == 0:
         os.rename(sample + '.zst', sample + '_18_64_' + tag + '.zst')
     # zstdFiles = glob.glob("*.zst*")
     # print(zstdFiles)
 
+
 # http://stackoverflow.com/a/19711609/2132223
 def sha1_of_file(filepath):
     with open(filepath, 'rb') as f:
         return hashlib.sha1(f.read()).hexdigest()
 
+
 def remove_duplicates():
     list_of_zst = sorted(glob.glob('*.zst'))
     for i, ref_zst in enumerate(list_of_zst):
@@ -76,18 +83,19 @@ def remove_duplicates():
                 os.remove(compared_zst)
                 print('duplicated : {} == {}'.format(ref_zst, compared_zst))
 
+
 def decompress_zst(tag):
     dec_error = 0
     list_zst = sorted(glob.glob('*.zst'))
     try:
-        from subprocess import DEVNULL # py3k
+        from subprocess import DEVNULL  # py3k
     except ImportError:
         DEVNULL = open(os.devnull, 'wb')
     for file_zst in list_zst:
         print(file_zst, end=" ")
         print(tag, end=" ")
         file_dec = file_zst + '_d64_' + tag + '.dec'
-        if subprocess.call(['./zstd.'   + tag, '-df', file_zst, '-o', file_dec], stderr=DEVNULL)==0:
+        if subprocess.call(['./zstd.' + tag, '-df', file_zst, '-o', file_dec], stderr=DEVNULL) == 0:
             if not filecmp.cmp(file_dec, test_dat):
                 print('ERR !! ')
                 dec_error = 1
@@ -116,12 +124,12 @@ if __name__ == '__main__':
     print('Retrieve all release tags :')
     os.chdir(clone_dir)
     tags = get_git_tags() + [head]
-    print(tags);
+    print(tags)
 
     # Build all release zstd
     for tag in tags:
         os.chdir(base_dir)
-        dst_zstd   = '{}/zstd.{}'  .format(tmp_dir, tag) # /path/to/zstd/test/zstdtest/zstd.<TAG>
+        dst_zstd = '{}/zstd.{}'  .format(tmp_dir, tag)  # /path/to/zstd/test/zstdtest/zstd.<TAG>
         if not os.path.isfile(dst_zstd) or tag == head:
             if tag != head:
                 r_dir = '{}/{}'.format(tmp_dir, tag)  # /path/to/zstd/test/zstdtest/<TAG>
@@ -139,17 +147,18 @@ if __name__ == '__main__':
     os.chdir(tmp_dir)
     for compressed in glob.glob("*.zst"):
         os.remove(compressed)
-    for dec in glob.glob("*.dec"):   
+    for dec in glob.glob("*.dec"):
         os.remove(dec)
 
     print('Compress test.dat by all released zstd')
 
-    error_code = 0;
+    error_code = 0
     for tag in tags:
         print(tag)
         compress_sample(tag, test_dat)
         remove_duplicates()
-        error_code += decompress_zst(tag)
+        if tag >= 'v0.5.1':
+            error_code += decompress_zst(tag)
 
     print('')
     print('Enumerate different compressed files')