forked from oreparaz/dudect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
32 lines (25 loc) · 797 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import sys
_TIMEOUT=60
_EXPECTED_TO_LEAK = [
"dudect_aes32_-O2",
"dudect_donnabad_-O2",
"dudect_simple_O0",
]
_EXPECTED_NOT_TO_LEAK = [
"dudect_donna_-O2",
"dudect_aesbitsliced_-O2",
"dudect_simple_O2",
]
def check(name, expected_to_leak):
cmd = "timeout %d ./%s" % (_TIMEOUT, name)
ret = os.system(cmd) >> 8 # os.system returns the exit code in the top bits
actual_leaks = (ret != 124) # if command timeouts, ret will be 124
if actual_leaks != expected_to_leak:
print("FAIL %s expected? %s actual: %s"%(name, expected_to_leak, actual_leaks))
sys.exit(1)
for name in _EXPECTED_TO_LEAK:
check(name, expected_to_leak=True)
for name in _EXPECTED_NOT_TO_LEAK:
check(name, expected_to_leak=False)
print("PASS")