Skip to content

Commit

Permalink
Fail python tests on error instead of just ERROR output
Browse files Browse the repository at this point in the history
Include the test_iter.py in the test_all.py too.
  • Loading branch information
peace-maker committed Nov 26, 2024
1 parent d89291a commit 4140297
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
17 changes: 13 additions & 4 deletions bindings/python/tests/test_all.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#!/usr/bin/env python3

import test_lite
import test_iter
import test_skipdata
import test_customized_mnem
import test_compatibility_layer

test_lite.test_class()
test_skipdata.test_class()
test_customized_mnem.test()
test_compatibility_layer.test_compatibility()
errors = []
errors.extend(test_lite.test_class())
errors.extend(test_iter.test_class())
errors.extend(test_skipdata.test_class())
errors.extend(test_customized_mnem.test())
errors.extend(test_compatibility_layer.test_compatibility())

if errors:
print("Some errors happened. Please check the output")
for error in errors:
print(error)
exit(1)
7 changes: 6 additions & 1 deletion bindings/python/tests/test_compatibility_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

# Test arm64 and sysz compatibility layer
def test_compatibility():
errors = []
for arch, mode, code, comment in all_tests:
print("*" * 16)
print("Platform: %s" % comment)
Expand All @@ -39,6 +40,7 @@ def test_compatibility():
print()
except CsError as e:
print("ERROR: %s" % e)
errors.append(str(e))

# Test ARM64_ constants
print("arm64.ARM64_CC_AL = %d" % capstone.arm64.ARM64_CC_AL)
Expand All @@ -52,7 +54,10 @@ def test_compatibility():
print("systemz.SYSZ_INS_LG = %d" % capstone.systemz.SYSZ_INS_LG)
print("systemz.SYSTEMZ_INS_LG = %d" % capstone.systemz.SYSTEMZ_INS_LG)
assert capstone.systemz.SYSZ_INS_LG == capstone.systemz.SYSTEMZ_INS_LG
return errors


if __name__ == "__main__":
test_compatibility()
if test_compatibility():
print("Some errors happened. Please check the output")
exit(1)
7 changes: 6 additions & 1 deletion bindings/python/tests/test_customized_mnem.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def print_insn(md, code):


def test():
errors = []
try:
md = Cs(CS_ARCH_X86, CS_MODE_32)

Expand All @@ -33,7 +34,11 @@ def test():
print_insn(md, X86_CODE32)
except CsError as e:
print("ERROR: %s" % e)
errors.append(str(e))
return errors


if __name__ == '__main__':
test()
if test():
print("Some errors happened. Please check the output")
exit(1)
7 changes: 6 additions & 1 deletion bindings/python/tests/test_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

# ## Test class Cs
def test_class():
errors = []
for (arch, mode, code, comment, syntax) in all_tests:
print('*' * 16)
print("Platform: %s" % comment)
Expand All @@ -89,6 +90,10 @@ def test_class():
print()
except CsError as e:
print("ERROR: %s" % e)
errors.append(str(e))
return errors

if __name__ == '__main__':
test_class()
if test_class():
print("Some errors happened. Please check the output")
exit(1)
7 changes: 6 additions & 1 deletion bindings/python/tests/test_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_cs_disasm_quick():

# ## Test class Cs
def test_class():
errors = []
for (arch, mode, code, comment, syntax) in all_tests:
print('*' * 16)
print("Platform: %s" % comment)
Expand All @@ -90,9 +91,13 @@ def test_class():
print()
except CsError as e:
print("ERROR: %s" % e)
errors.append(str(e))
return errors


# test_cs_disasm_quick()
# print "*" * 40
if __name__ == '__main__':
test_class()
if test_class():
print("Some errors happened. Please check the output")
exit(1)
7 changes: 6 additions & 1 deletion bindings/python/tests/test_skipdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def testcb(buffer, size, offset, userdata):

# ## Test class Cs
def test_class():
errors = []
for (arch, mode, code, comment, syntax) in all_tests:
print('*' * 16)
print("Platform: %s" %comment)
Expand Down Expand Up @@ -65,7 +66,11 @@ def test_class():
print
except CsError as e:
print("ERROR: %s" % e)
errors.append(str(e))
return errors


if __name__ == '__main__':
test_class()
if test_class():
print("Some errors happened. Please check the output")
exit(1)

0 comments on commit 4140297

Please sign in to comment.