Fix test failures on 32-bit platforms.
This commit is contained in:
parent
a653043110
commit
4a6d786256
@ -14,6 +14,20 @@ from http import server
|
||||
from urllib import request
|
||||
import system_tests
|
||||
|
||||
# Run `exiv2 --verbose --version` to find out if the Exiv2 binary is 32-bit or 64-bit.
|
||||
def exiv2_is_64bit(bin_dir):
|
||||
proc = subprocess.run(
|
||||
[os.path.join(bin_dir, 'exiv2'), '--verbose', '--version'],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
cwd=bin_dir
|
||||
)
|
||||
proc.check_returncode()
|
||||
m = re.search(r'^bits=([0-9]+)\s*$', proc.stdout.decode('utf-8'), re.MULTILINE)
|
||||
numbits = int(m[1])
|
||||
assert numbits in {32, 64}
|
||||
return numbits == 64
|
||||
|
||||
|
||||
"""
|
||||
Part 1:
|
||||
@ -43,6 +57,8 @@ class Config:
|
||||
if 'VALGRIND' in os.environ:
|
||||
valgrind = os.environ['VALGRIND']
|
||||
|
||||
is_64bit = exiv2_is_64bit(bin_dir)
|
||||
|
||||
@classmethod
|
||||
def init(cls):
|
||||
""" Init test environments and variables that may be modified """
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
import system_tests
|
||||
|
||||
|
||||
class TestCvePoC(metaclass=system_tests.CaseMeta):
|
||||
|
||||
url = "https://github.com/Exiv2/exiv2/issues/74"
|
||||
@ -10,9 +9,9 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
|
||||
filename = "$data_path/005-invalid-mem"
|
||||
commands = ["$exiv2 " + filename]
|
||||
stdout = [""]
|
||||
stderr = ["""$exiv2_exception_message """ + filename + """:
|
||||
$kerFailedToReadImageData
|
||||
"""]
|
||||
stderr = ["""$exiv2_exception_message """ + filename + ":\n" +
|
||||
("$kerFailedToReadImageData" if system_tests.BT.Config.is_64bit else "$kerCorruptedMetadata") +
|
||||
"\n"]
|
||||
retval = [1]
|
||||
|
||||
def compare_stderr(self, i, command, got_stderr, expected_stderr):
|
||||
|
||||
@ -10,8 +10,14 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
|
||||
filename = "$data_path/008-invalid-mem"
|
||||
commands = ["$exiv2 -q " + filename]
|
||||
|
||||
stderr = [""]
|
||||
retval = [0]
|
||||
if system_tests.BT.Config.is_64bit:
|
||||
stderr = [""]
|
||||
retval = [0]
|
||||
else:
|
||||
stderr = ["""$exiv2_exception_message """ + filename + """:
|
||||
$kerCorruptedMetadata
|
||||
"""]
|
||||
retval = [1]
|
||||
|
||||
compare_stdout = check_no_ASAN_UBSAN_errors
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
import system_tests
|
||||
|
||||
|
||||
class TestCvePoC(metaclass=system_tests.CaseMeta):
|
||||
|
||||
url = "https://github.com/Exiv2/exiv2/issues/73"
|
||||
@ -10,7 +9,7 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
|
||||
filename = "$data_path/02-Invalid-mem-def"
|
||||
commands = ["$exiv2 -q " + filename]
|
||||
stdout = [""]
|
||||
stderr = ["""$exiv2_exception_message """ + filename + """:
|
||||
$kerFailedToReadImageData
|
||||
"""]
|
||||
stderr = ["""$exiv2_exception_message """ + filename + ":\n" +
|
||||
("$kerFailedToReadImageData" if system_tests.BT.Config.is_64bit else "$kerCorruptedMetadata") +
|
||||
"\n"]
|
||||
retval = [1]
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
import system_tests
|
||||
|
||||
|
||||
class AdditionOverflowInLoaderExifJpeg(metaclass=system_tests.CaseMeta):
|
||||
"""
|
||||
Regression test for bug #365:
|
||||
@ -17,6 +16,7 @@ class AdditionOverflowInLoaderExifJpeg(metaclass=system_tests.CaseMeta):
|
||||
"""Error: Upper boundary of data for directory Image, entry 0x00fe is out of bounds: Offset = 0x0000002a, size = 64, exceeds buffer size by 22 Bytes; truncating the entry
|
||||
Warning: Directory Image, entry 0x0201: Strip 0 is outside of the data area; ignored.
|
||||
Warning: Directory Image, entry 0x0201: Strip 7 is outside of the data area; ignored.
|
||||
"""
|
||||
""" +
|
||||
("" if system_tests.BT.Config.is_64bit else "Uncaught exception: Overflow in addition\n")
|
||||
]
|
||||
retval = [0]
|
||||
retval = [0 if system_tests.BT.Config.is_64bit else 1]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user