Debian Codegraph @

tests/riscv-official/code/helpers.py

raw
1 def max_str_list(list):
2 if (len(list) > 0):
3 return len(max(list, key=lambda x: len(x)))
4 return 0
5
6
7 # Decorative method, if output of the qtrvsim-cli is changed this will probably break!!!
8 def print_formated_output(reg_dump):
9 stdout = reg_dump.stdout.decode("utf-8")
10 stderr = reg_dump.stderr.decode("utf-8")
11 print(stderr)
12 print(stdout)
13
14
15 def res_translate(res):
16 if (res == 0):
17 return "FAIL"
18 elif (res == 1):
19 return "PASS"
20 else:
21 return "ERROR"
22
23
24 def res_print(test, test_res, test_reg_dump, params):
25 if (test_res == 1):
26 if (not params.nopass):
27 if (not params.fileprt):
28 print(test + ": " + '\033[92m' + "PASS" + '\033[0m')
29 else:
30 print(test+":PASS")
31 if (params.dregs):
32 print_formated_output(test_reg_dump)
33 return 1
34 elif (test_res == 0):
35 if (not params.fileprt):
36 print(test + ": " + '\033[93m' + "FAIL" + '\033[0m')
37 else:
38 print(test+":FAIL")
39 if (not params.nodump or params.dregs):
40 print_formated_output(test_reg_dump)
41 return 0
42 else:
43 if (not params.fileprt):
44 print(test + ": " + '\033[91m' + "ERROR" + '\033[0m')
45 else:
46 print(test+":ERROR")
47 if (not params.nodump or params.dregs):
48 print_formated_output(test_reg_dump)
49 return 0
50
51
52 def get_RVxx(tests, isa):
53 isa = str(isa).lower()
54 tests32 = list(filter(lambda t: str(t).__contains__("32"+isa), tests))
55 tests64 = list(filter(lambda t: str(t).__contains__("64"+isa), tests))
56 tests32.sort()
57 tests64.sort()
58 return tests32, tests64