diff --git a/tests/bugfixes/github/test_pr1475_AVIF.py b/tests/bugfixes/github/test_pr1475_AVIF.py index ef5b6d13..eac49523 100644 --- a/tests/bugfixes/github/test_pr1475_AVIF.py +++ b/tests/bugfixes/github/test_pr1475_AVIF.py @@ -51,7 +51,7 @@ Exiv2::BmffImage::boxHandler: free 336->64 Exiv2::BmffImage::boxHandler: mdat 400->218816 ""","",""] -class pr_1475_avif_exif_xmp(metaclass=system_tests.CaseMeta): +class pr_1475_exif_xmp_avif(metaclass=system_tests.CaseMeta): url = "https://github.com/Exiv2/exiv2/pull/1475" filename = "$data_path/avif_exif_xmp.avif" if bSkip: @@ -246,7 +246,7 @@ Exiv2::BmffImage::boxHandler: mdat 411->10452 """,""] -class pr_1475_avif_metadata2(metaclass=system_tests.CaseMeta): +class pr_1475_metadata2_avif(metaclass=system_tests.CaseMeta): url = "https://github.com/Exiv2/exiv2/pull/1475" filename = "$data_path/avif_metadata2.avif" if bSkip: diff --git a/tests/bugfixes/github/test_pr1475_HIF.py b/tests/bugfixes/github/test_pr1475_HIF.py index 90432b56..96755148 100644 --- a/tests/bugfixes/github/test_pr1475_HIF.py +++ b/tests/bugfixes/github/test_pr1475_HIF.py @@ -1,65 +1,22 @@ # -*- coding: utf-8 -*- import system_tests +# test needs system_tests.vv.enable_bmff=1 +vv=system_tests.verbose_version() +enable_bmff = 'enable_bmff' +bSkip = not (enable_bmff in vv and vv[enable_bmff] == '1') -from system_tests import BT -import os -import sys -import shlex -import shutil -import subprocess - -# https://github.com/Exiv2/exiv2/issues/1215 -def error(s): - print('**',s,'**') - -def warn(s): - print('--',s) - -def chop(blob): - lines=[] - line='' - for c in blob.decode('utf-8'): - if c == '\n': - lines=lines+[line] - line='' - elif c != '\r': - line=line+str(c) - if len(line) != 0: - lines=lines+line - return lines - -def runTest(cmd): - if sys.platform == 'win32': - args = cmd - else: - args = shlex.split(cmd) - try: - p = subprocess.Popen( args, stdout=subprocess.PIPE,shell=False) - out,err = p.communicate() - if p.returncode != 0: - print('%s returncode = %d' % (cmd,p.returncode) ) - out=chop(out) - except: - error('%s died' % cmd ) - return out - -class pr_1475_hif_Sony(metaclass=system_tests.CaseMeta): +class pr_1475_Sony_hif(metaclass=system_tests.CaseMeta): url = "https://github.com/Exiv2/exiv2/pull/1475" - bSkip=False - - # test needs enable_bmff=1 - exiv2_exe=os.path.join(BT.Config.bin_dir, "exiv2") - bSkip = bSkip or runTest(exiv2_exe + " -vVg enable_bmff")[-1] != "enable_bmff=1" + filename = "$data_path/Sony.HIF" if bSkip: commands=[] retval=[] stdin=[] stderr=[] stdout=[] - print("*** test skipped ***") + print("*** test skipped. requires enable_bmff=1***") else: - filename = "$data_path/Sony.HIF" commands = ["$exiv2 -g Image.Make -g Date -g Xm -g Expo -g Flash $filename" ,"$exiv2 -pS $filename" ,"$exiv2 -pX $filename" @@ -170,22 +127,18 @@ Exiv2::BmffImage::boxHandler: mdat 4088->147464 """,""] -class pr_1475_hif_Canon(metaclass=system_tests.CaseMeta): +class pr_1475_Canon_hif(metaclass=system_tests.CaseMeta): url = "https://github.com/Exiv2/exiv2/pull/1475" - bSkip=False - - # test needs enable_bmff=1 - exiv2_exe=os.path.join(BT.Config.bin_dir, "exiv2") - bSkip = bSkip or runTest(exiv2_exe + " -vVg enable_bmff")[-1] != "enable_bmff=1" + filename = "$data_path/Canon.HIF" + if bSkip: commands=[] retval=[] stdin=[] stderr=[] stdin=[] - print("*** skipped. test requires both enable_bmff and debug***") + print("*** test skipped. requires enable_bmff=1***") else: - filename = "$data_path/Canon.HIF" commands = ["$exiv2 -g Image.Make -g Date -g Xm -g Expo -g Flash $filename" ,"$exiv2 -pS $filename" ,"$exiv2 -pX $filename" diff --git a/tests/system_tests.py b/tests/system_tests.py index e1e95186..25eeece6 100644 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -981,3 +981,80 @@ def check_no_ASAN_UBSAN_errors(self, i, command, got_stderr, expected_stderr): self.assertNotIn(UBSAN_MSG, got_stderr) self.assertNotIn(ASAN_MSG, got_stderr) +# Apologies Dan. I can't write python in your beautiful style and I know nothing about python objects +# https://github.com/Exiv2/exiv2/issues/1215 +def error(s): + print('**',s,'**') + +def warn(s): + print('--',s) + +def chop(blob): + lines=[] + line='' + for c in blob.decode('utf-8'): + if c == '\n': + lines=lines+[line] + line='' + elif c != '\r': + line=line+str(c) + if len(line) != 0: + lines=lines+line + return lines + +def runTest(cmd): + if sys.platform == 'win32': + args = cmd + else: + args = shlex.split(cmd) + + # Updat PATH, LD_LIBRARY_PATH and DYLD_LIBRARY_PATH + key="PATH" + bin=os.path.dirname(exiv2) + if key in os.environ: + os.environ[key] = bin + os.pathsep + os.environ[key] + else: + os.environ[key] = bin + + for key in [ "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH" ]: + lib=os.path.join(os.path.dirname(os.path.dirname(exiv2)),'lib') + if key in os.environ: + os.environ[key] = lib + os.pathsep + os.environ[key] + else: + os.environ[key] = lib + + try: + p = subprocess.Popen( args, stdout=subprocess.PIPE,shell=False) + out,err = p.communicate() + if p.returncode != 0: + print('%s returncode = %d' % (cmd,p.returncode) ) + out=chop(out) + except: + error('%s died' % cmd ) + return out + +def verbose_version(verbose=False): + vv = {} + lines = runTest(exiv2 + ' --verbose --version') + for line in lines: + kv=line.rstrip().split('=') + if len(kv) == 2: + key=kv[0] + val=kv[1] + if not key in vv: + vv[key]=val + elif type(vv[key]) == type([]): + vv[key].append(val) + else: + vv[key]=[ vv[key] ] + + if verbose: + for key in vv: + blanks=' '*(20-len(key)) + val=vv[key] + if type(val) == type([]): + val= '[ %s +%d ]' % (val[0],len(val)-1) + print(key,blanks,val) + + return vv +