Makes output from `hatlib.verify_hat` easier to read (#45)

This commit is contained in:
Kern Handa 2022-04-14 22:01:15 -07:00 коммит произвёл GitHub
Родитель 9cb567a1f6
Коммит ce2fb0b133
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 19 добавлений и 6 удалений

Просмотреть файл

@ -9,21 +9,34 @@ def verify_hat_package(hat_path):
_, funcs = hat.load(hat_path)
inputs = hat.generate_input_sets_for_hat_file(hat_path)
for name, fn in funcs.items():
print(f"Verifying function {name} --")
print(f"\n{'*' * 10}\n")
print(f"[*] Verifying function {name} --")
func_inputs = inputs[name]
print("Inputs before function call:")
print("[*] Inputs before function call:")
for i, func_input in enumerate(func_inputs):
print(f"\tInput {i}: {','.join(map(str, func_input.ravel()[:32]))}")
print(f"[*]\tInput {i}: {','.join(map(str, func_input.ravel()[:32]))}")
time = fn(*inputs[name])
try:
time = fn(*inputs[name])
except RuntimeError as e:
print(f"[!] Error while running {name}: {e}")
continue
print("Inputs after function call:")
for i, func_input in enumerate(func_inputs):
print(f"\tInput {i}: {','.join(map(str, func_input.ravel()[:32]))}")
print(f"[*]\tInput {i}: {','.join(map(str, func_input.ravel()[:32]))}")
if time:
print(f"Function execution time: {time:4f}ms")
print(f"[*] Function execution time: {time:4f}ms")
del inputs[name]
else:
print(f"\n{'*' * 10}\n")
def main():