Skip to content

Commit

Permalink
tests: manual fstring conversions
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Dec 13, 2024
1 parent 0492d32 commit d3433bb
Show file tree
Hide file tree
Showing 34 changed files with 72 additions and 147 deletions.
2 changes: 1 addition & 1 deletion tests/bugfixes/github/test_CVE_2017_1000126.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/175"

filename = "$data_path/cve_2017_1000126_stack-oob-read.webp"
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
stdout = [""]
stderr = [
f"""$exiv2_exception_message {filename}:
Expand Down
16 changes: 7 additions & 9 deletions tests/bugfixes/github/test_CVE_2017_14859.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
commands = [f"$exiv2 {filename}"]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ ":\n"
+ (
"$kerFailedToReadImageData"
if system_tests.BT.Config.is_64bit
else "$kerCorruptedMetadata"
)
+ "\n"
f"""$exiv2_exception_message {filename}:
{(
"$kerFailedToReadImageData"
if system_tests.BT.Config.is_64bit
else "$kerCorruptedMetadata"
)}
"""
]
retval = [1]

Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_CVE_2017_14860.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/73"

filename = "$data_path/003-heap-buffer-over"
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerCorruptedMetadata
"""
]
Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_CVE_2017_14862.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/75"

filename = "$data_path/008-invalid-mem"
commands = ["$exiv2 -q " + filename]
commands = [f"$exiv2 -q {filename}"]

if system_tests.BT.Config.is_64bit:
stderr = [""]
retval = [0]
else:
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerCorruptedMetadata
"""
]
Expand Down
16 changes: 7 additions & 9 deletions tests/bugfixes/github/test_CVE_2017_14864.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
commands = [f"$exiv2 -q {filename}"]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ ":\n"
+ (
"$kerFailedToReadImageData"
if system_tests.BT.Config.is_64bit
else "$kerCorruptedMetadata"
)
+ "\n"
f"""$exiv2_exception_message {filename}:
{(
"$kerFailedToReadImageData"
if system_tests.BT.Config.is_64bit
else "$kerCorruptedMetadata"
)}
"""
]
retval = [1]
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_CVE_2017_17669.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/187"

filename = "$data_path/issue_187"
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
retval = [1]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerFailedToReadImageData
"""
]
8 changes: 3 additions & 5 deletions tests/bugfixes/github/test_CVE_2017_17722.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/208"

filename = "$data_path/2018-01-09-exiv2-crash-001.tiff"
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
retval = [1]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
$filename: $kerFileContainsUnknownImageType
f"""$exiv2_exception_message {filename}:
{filename}: $kerFileContainsUnknownImageType
"""
]
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_CVE_2017_17725.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
found_by = ["Wei You", "@youwei1988"]

filename = "$data_path/poc_2017-12-12_issue188"
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerCorruptedMetadata
"""
]
Expand Down
4 changes: 1 addition & 3 deletions tests/bugfixes/github/test_CVE_2017_18005.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class TestPoC(metaclass=system_tests.CaseMeta):
commands = [f"$exiv2 -vPEIXxgklnycsvth -b {filename}"]

stdout = [
"""File 1/1: """
+ filename
+ """
f"""File 1/1: {filename}
0x0117 Image Exif.Image.StripByteCounts StripByteCounts Strip Byte Count SByte 0 0
"""
Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_CVE_2018_10999.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/306"

filename = "$data_path/pocIssue306"
commands = ["$exiv2 -et " + filename]
commands = [f"$exiv2 -et {filename}"]
retval = [1]
stdout = [""]
stderr = [
"""$exception_in_extract """
+ filename
+ """:
f"""$exception_in_extract {filename}:
$kerCorruptedMetadata
"""
]
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_CVE_2018_4868.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ class TestCvePoC(metaclass=system_tests.CaseMeta):
found_by = ["afl", "topsecLab", "xcainiao"]

filename = "$data_path/exiv2-memorymmap-error"
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerCorruptedMetadata
"""
]
Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_issue_1011.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

class Test_issue_1011(metaclass=CaseMeta):
filename = path("$data_path/Jp2Image_readMetadata_loop.poc")
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerCorruptedMetadata
"""
]
Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_issue_170.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ class DecodeIHDRChunkOutOfBoundsRead(metaclass=system_tests.CaseMeta):

filename = "$data_path/issue_170_poc"

commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerFailedToReadImageData
"""
]
Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_issue_1833.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ class TiffMnEntryDoCountInvalidTiffType(metaclass=CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/1833"

filename = path("$data_path/issue_1833_poc.jpg")
commands = ["$exiv2 -pS $filename"]
commands = [f"$exiv2 -pS {filename}"]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerFailedToReadImageData
"""
]
Expand Down
4 changes: 1 addition & 3 deletions tests/bugfixes/github/test_issue_1845.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ class TiffDirectoryWriteDirEntryAssert(metaclass=CaseMeta):
filename = path("$tmp_path/issue_1845_poc.jp2")
commands = ["$exiv2 -q -D +1 ad $filename"]
stderr = [
"""$exception_in_adjust """
+ filename
+ """:
f"""$exception_in_adjust {filename}:
$kerCorruptedMetadata
"""
]
Expand Down
4 changes: 1 addition & 3 deletions tests/bugfixes/github/test_issue_1881.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class SonyPreviewImageLargeAllocation(metaclass=CaseMeta):
filename2 = path("$tmp_path/issue_1881_coverage.jpg")
commands = ["$exiv2 -q -d I rm $filename1", "$exiv2 -q -d I rm $filename2"]
stderr = [
"""$exception_in_erase """
+ filename1
+ """:
f"""$exception_in_erase {filename1}:
$kerFailedToReadImageData
""",
"",
Expand Down
10 changes: 4 additions & 6 deletions tests/bugfixes/github/test_issue_20.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ class TamronSupport(metaclass=system_tests.CaseMeta):
"TamronSP90mmF2.8DiVCUSDMacroF004.exv",
"TamronSP90mmF2.8DiVCUSDMacroF017.exv",
]
commands = [f"$exiv2 -pa --grep lens/i ../../../test/data/{files[0]}"] + list(
map(
lambda fname: f"$exiv2 -pa --grep lenstype/i ../../../test/data/{fname}",
files[1:],
)
)
commands = [f"$exiv2 -pa --grep lens/i ../../../test/data/{files[0]}"] + [
f"$exiv2 -pa --grep lenstype/i ../../../test/data/{fname}"
for fname in files[1:]
]
retval = [0] * len(files)

stdout = [
Expand Down
4 changes: 1 addition & 3 deletions tests/bugfixes/github/test_issue_227.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ class SigmaLenses(metaclass=system_tests.CaseMeta):
"Sigma_50mm_F1.4_DG_HSM_A.exv",
]

commands = list(
map(lambda fname: f"$exiv2 -pa --grep lens/i $data_path/{fname}", files)
)
commands = [f"$exiv2 -pa --grep lens/i $data_path/{fname}" for fname in files]

retval = 3 * [0]
stderr = 3 * [""]
Expand Down
4 changes: 1 addition & 3 deletions tests/bugfixes/github/test_issue_2270.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class WebPImage_inject_VP8X_integer_overflow(metaclass=CaseMeta):
commands = ["$exiv2 rm $filename"]
stdout = [""]
stderr = [
"""$exception_in_erase """
+ filename
+ """:
f"""$exception_in_erase {filename}:
$kerCorruptedMetadata
"""
]
Expand Down
10 changes: 3 additions & 7 deletions tests/bugfixes/github/test_issue_246.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,17 @@ class TestFirstPoC(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/246"

filename = "$data_path/1-string-format.jpg"
commands = ["$exiv2 -pS " + filename]
commands = [f"$exiv2 -pS {filename}"]
stdout = [
"""STRUCTURE OF JPEG FILE: """
+ filename
+ """
f"""STRUCTURE OF JPEG FILE: {filename}
address | marker | length | data
0 | 0xffd8 SOI
2 | 0xffe1 APP1 | 60 | Exif..II*.....0.i...........0000
"""
]

stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerNoImageInInputData
"""
]
Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_issue_253.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ class TestFirstPoC(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/253"

filename = "$data_path/3-stringformat-outofbound-read"
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
stdout = [""]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerNotAJpeg
"""
]
Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_issue_400.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ class parseTXTChunkOutOfBoundsRead(metaclass=system_tests.CaseMeta):

filenames = [system_tests.path("$data_path/issue_400_poc" + str(i)) for i in (1, 2)]

commands = ["$exiv2 " + fname for fname in filenames]
commands = [f"$exiv2 {fname}" for fname in filenames]
stdout = [""] * 2
stderr = [
"""$exiv2_exception_message """
+ fname
+ """:
f"""$exiv2_exception_message {fname}:
$kerCorruptedMetadata
"""
for fname in filenames
Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_issue_426.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ class DetectsWrongLengthOfImageResourceInPSDFile(metaclass=system_tests.CaseMeta
url = "https://github.com/Exiv2/exiv2/issues/426"

filename = system_tests.path("$data_path/h02.psd")
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
retval = [1]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerCorruptedMetadata
"""
]
12 changes: 3 additions & 9 deletions tests/bugfixes/github/test_issue_428.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@


def stderr_exception(fname):
return (
"""$exiv2_exception_message """
+ fname
+ """:
return f"""$exiv2_exception_message {fname}:
$kerFailedToReadImageData
"""
)


class PngReadRawProfile(metaclass=system_tests.CaseMeta):
Expand All @@ -27,14 +23,12 @@ class PngReadRawProfile(metaclass=system_tests.CaseMeta):
system_tests.path("$data_path/issue_428_poc6.png"),
]

commands = ["$exiv2 " + fname for fname in filenames]
commands = [f"$exiv2 {fname}" for fname in filenames]
stdout = [""] * len(filenames)
stderr = [stderr_exception(fname) for fname in filenames[0:6]]

stderr.append(
"""$exiv2_exception_message """
+ filenames[6]
+ """:
f"""$exiv2_exception_message {filenames[6]}:
$kerInputDataReadFailed
"""
)
Expand Down
6 changes: 2 additions & 4 deletions tests/bugfixes/github/test_issue_460.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ class ThrowsWhenCRWImageIsMalformed(metaclass=system_tests.CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/460"

filename = system_tests.path("$data_path/issue_460")
commands = ["$exiv2 " + filename]
commands = [f"$exiv2 {filename}"]
retval = [1]
stderr = [
"""$exiv2_exception_message """
+ filename
+ """:
f"""$exiv2_exception_message {filename}:
$kerCorruptedMetadata
"""
]
Loading

0 comments on commit d3433bb

Please sign in to comment.