summaryrefslogtreecommitdiff
path: root/test/py/tests/test_spi.py
diff options
context:
space:
mode:
authorLove Kumar <love.kumar@amd.com>2025-04-15 15:11:09 +0530
committerTom Rini <trini@konsulko.com>2025-04-24 08:23:05 -0600
commit140e1d7fc3a5634e8a3971b5c6bf9b0239591eb0 (patch)
tree4335efde9007c542f0c737f34866f181e0436c72 /test/py/tests/test_spi.py
parent8327aa9af4be32b4236dfd25c8cefe568e9b3641 (diff)
test/py: spi: Prevent to overwrite the reserved memory
Update SPI negative tests to prevent SF command from overwriting the reserved memory area. Signed-off-by: Love Kumar <love.kumar@amd.com>
Diffstat (limited to 'test/py/tests/test_spi.py')
-rw-r--r--test/py/tests/test_spi.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/py/tests/test_spi.py b/test/py/tests/test_spi.py
index dd767528dbf..09174f91e98 100644
--- a/test/py/tests/test_spi.py
+++ b/test/py/tests/test_spi.py
@@ -703,4 +703,33 @@ def test_spi_negative(ubman):
ubman, 'read', start, size, res_area, 1, error_msg, EXPECTED_READ
)
+ # Start reading from the reserved area
+ m = re.search(r'reserved\[0\]\s*\[(0x.+)-(0x.+)\]', output)
+ if not m or int(m.group(1), 16) == 0:
+ ubman.log.info('No reserved area is defined or start addr is 0x0!')
+ else:
+ rstart_area = int(m.group(1), 16)
+ rend_area = int(m.group(2), 16)
+
+ # Case 1: Start reading from the middle of the reserved area
+ r_size = rend_area - rstart_area
+ r_area = rstart_area + r_size
+ flash_ops(
+ ubman, 'read', start, size, r_area, 1, error_msg, EXPECTED_READ
+ )
+
+ # Case 2: Start reading from before the reserved area to cross-over
+ # the reserved area
+ rstart_area = rstart_area - int(size/2)
+ flash_ops(
+ ubman, 'read', start, size, rstart_area, 1, error_msg, EXPECTED_READ
+ )
+
+ # Case 3: Start reading till after the reserved area to cross-over
+ # the reserved area
+ rend_area = rend_area - int(size/2)
+ flash_ops(
+ ubman, 'read', start, size, rend_area, 1, error_msg, EXPECTED_READ
+ )
+
i = i + 1