forked from tropicsquare/ts-spect-fw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_clear.py
executable file
·59 lines (42 loc) · 1.45 KB
/
test_clear.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import sys
import os
import test_common as tc
if __name__ == "__main__":
ops_cfg = tc.get_ops_config()
test_name = "clear"
tc.print_run_name("clear")
test_dir = tc.make_test_dir(test_name)
cmd_file = tc.get_cmd_file(test_dir)
tc.start(cmd_file)
ctx = tc.run_op(cmd_file, "clear", 0x0, 0x1, 0, ops_cfg, test_dir, run_name="clear_dummy", main="tests/dummy.s")
cmd_file = tc.get_cmd_file(test_dir)
tc.start(cmd_file)
ctx = tc.run_op(cmd_file, "clear", 0x0, 0x1, 0, ops_cfg, test_dir, old_context=ctx)
ctx_dict = tc.parse_context(test_dir, "clear")
ret = 0
for i in range(32):
if ctx_dict["GPR"][i] != 0:
print(f"r{i} != 0")
ret = 1
if ctx_dict["SHA"] != tc.SHA_CTX_INIT:
print("SHA ctx != Init ctx")
ret = 1
if int.from_bytes(ctx_dict["TMAC"], 'big') != 0:
print("TMAC ctx not cleared")
ret = 1
for i in range(tc.DATA_RAM_IN_DEPTH):
if ctx_dict["DATA RAM IN"][i] != 0:
print(f"Data RAM In {hex(i)} is not cleared")
ret = 1
for i in range(tc.DATA_RAM_OUT_DEPTH):
if ctx_dict["DATA RAM OUT"][i] != 0:
print(f"Data RAM Out {hex(i)} is not cleared")
ret = 1
if ret:
tc.print_failed()
else:
tc.print_passed()
if "TS_SPECT_FW_TEST_DONT_DUMP" in os.environ.keys():
os.system(f"rm -r {test_dir}")
sys.exit(ret)