Update tests

This commit is contained in:
Romain Thomas 2021-01-12 22:15:16 +01:00
parent d29a74996b
commit e6c606e78a
2 changed files with 17 additions and 2 deletions

View File

@ -14,6 +14,7 @@ try:
except ImportError:
from pprint import pprint
HAS_EXCEPTION = False
class exceptions_handler(object):
func = None
@ -28,14 +29,15 @@ class exceptions_handler(object):
try:
return self.func(*args, **kwargs)
except self.exceptions as e:
HAS_EXCEPTION = True
if self.on_except_callback is not None:
self.on_except_callback(e)
else:
print("-" * 60)
print("-" * 60, file=sys.stderr)
print("Exception in {}: {}".format(self.func.__name__, e))
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback.print_tb(exc_traceback)
print("-" * 60)
print("-" * 60, file=sys.stderr)
@exceptions_handler(Exception)
def print_attr(indent: int, auth: lief.PE.Attribute):
@ -300,3 +302,5 @@ def main():
if __name__ == "__main__":
main()
if HAS_EXCEPTION:
sys.exit(1)

View File

@ -76,6 +76,17 @@ if (PYTHON_TESTS_ENABLED)
${PYTHON_EXECUTABLE}
"${CMAKE_CURRENT_SOURCE_DIR}/test_authenticode.py")
ADD_PYTHON_TEST(EXAMPLE_PYTHON_pe_authenticode_reader
${PYTHON_EXECUTABLE}
"${LIEF_EXAMPLES_DIRECTORY}/python/authenticode/authenticode_reader.py \
--all --crt --hash --check --allow-expired --save test.p7b \
${LIEF_SAMPLES_DIRECTORY}/PE/PE32_x86-64_binary_avast-free-antivirus-setup-online.exe")
ADD_PYTHON_TEST(EXAMPLE_PYTHON_pe_authenticode_api
${PYTHON_EXECUTABLE}
"${LIEF_EXAMPLES_DIRECTORY}/python/authenticode/api_example.py \
${LIEF_SAMPLES_DIRECTORY}/PE/PE32_x86-64_binary_avast-free-antivirus-setup-online.exe")
endif()