/
tc_ub_check_reg_file.py
52 lines (45 loc) · 1.4 KB
/
tc_ub_check_reg_file.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
# SPDX-License-Identifier: GPL-2.0
#
# Description:
# checks if the default values in reg file tb.config.tc_ub_create_reg_file_name
# on the tbot host in tb.workdir have the same values, as the
# registers on the board
# format of the regfile:
# regaddr mask type defval
# ToDo: use the file from the lab host, not the tbot host
# End:
from tbotlib import tbot
tb.define_variable('tc_ub_create_reg_file_name', '')
# set board state for which the tc is valid
tb.set_board_state("u-boot")
c = tb.c_con
fname = tb.workdir + "/" + tb.config.tc_ub_create_reg_file_name
try:
fd = open(fname, 'r')
except IOError:
logging.warning("Could not open: %s", fname)
tb.end_tc(False)
retval = True
for line in fd.readlines():
cols = line.split()
if cols[0] == '#':
continue
val = cols[0]
tmp = 'md.'+ cols[2] + ' ' + val + ' 1'
tb.eof_write(c, tmp)
val = val.replace('0x','')
ret = tb.tbot_expect_string(c, val)
if ret == 'prompt':
tb.end_tc(False)
tb.tbot_expect_prompt(c)
tmp = tb.buf.split(':')
val = tmp[1].split(' ')
val = val[1].lstrip('0')
if val == '':
val = '0x0'
else:
val = '0x' + val
if (int(val, 16) & int(cols[1], 16)) != (int(cols[3], 16) & int(cols[1], 16)):
logging.warn("args: %s %s %s & %s != %s", tb.config.tc_ub_create_reg_file_name, cols[0], val, cols[1], cols[3])
retval = False
tb.end_tc(retval)