[PATCH] test/py: spi: prevent overwriting relocation memory

Update spi negative test case to prevent SF command from overwriting relocation memory area.
Signed-off-by: Padmarao Begari padmarao.begari@amd.com --- test/py/tests/test_spi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/test/py/tests/test_spi.py b/test/py/tests/test_spi.py index 3160d58540..caca930327 100644 --- a/test/py/tests/test_spi.py +++ b/test/py/tests/test_spi.py @@ -693,4 +693,16 @@ def test_spi_negative(u_boot_console): u_boot_console, 'read', offset, size, addr, 1, error_msg, EXPECTED_READ )
+ # Read to relocation address + output = u_boot_console.run_command('bdinfo') + m = re.search('relocaddr\s*= (.+)', output) + res_area = int(m.group(1), 16) + + start = 0 + size = 0x2000 + error_msg = 'ERROR: trying to overwrite reserved memory' + flash_ops( + u_boot_console, 'read', start, size, res_area, 1, error_msg, EXPECTED_READ + ) + i = i + 1

On Tue, Oct 29, 2024 at 05:17:09PM +0530, Padmarao Begari wrote:
Update spi negative test case to prevent SF command from overwriting relocation memory area.
Signed-off-by: Padmarao Begari padmarao.begari@amd.com
test/py/tests/test_spi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/test/py/tests/test_spi.py b/test/py/tests/test_spi.py index 3160d58540..caca930327 100644 --- a/test/py/tests/test_spi.py +++ b/test/py/tests/test_spi.py @@ -693,4 +693,16 @@ def test_spi_negative(u_boot_console): u_boot_console, 'read', offset, size, addr, 1, error_msg, EXPECTED_READ )
# Read to relocation address
output = u_boot_console.run_command('bdinfo')
m = re.search('relocaddr\s*= (.+)', output)
res_area = int(m.group(1), 16)
start = 0
size = 0x2000
error_msg = 'ERROR: trying to overwrite reserved memory'
flash_ops(
u_boot_console, 'read', start, size, res_area, 1, error_msg, EXPECTED_READ
)
i = i + 1
This got me looking at test/py/tests/test_spi.py more closely and this test is fine, so:
Reviewed-by: Tom Rini trini@konsulko.com
However, the error message 'No env file to read for SPI family device test' should really say that it's no test device configured (and similar change for env__spi_lock_unlock). A follow-up to rephrase those error messages would be appreciated.

From: Tom Rini trini@konsulko.com Sent: Wednesday, October 30, 2024 12:43 AM To: Begari, Padmarao Padmarao.Begari@amd.com Cc: u-boot@lists.denx.de; git (AMD-Xilinx) git@amd.com; Simek, Michal michal.simek@amd.com; Kumar, Love love.kumar@amd.com Subject: Re: [PATCH] test/py: spi: prevent overwriting relocation memory
On Tue, Oct 29, 2024 at 05:17:09PM +0530, Padmarao Begari wrote:
Update spi negative test case to prevent SF command from overwriting relocation memory area.
Signed-off-by: Padmarao Begari padmarao.begari@amd.com
test/py/tests/test_spi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/test/py/tests/test_spi.py b/test/py/tests/test_spi.py index 3160d58540..caca930327 100644 --- a/test/py/tests/test_spi.py +++ b/test/py/tests/test_spi.py @@ -693,4 +693,16 @@ def test_spi_negative(u_boot_console): u_boot_console, 'read', offset, size, addr, 1, error_msg,
EXPECTED_READ
)
# Read to relocation address
output = u_boot_console.run_command('bdinfo')
m = re.search('relocaddr\s*= (.+)', output)
res_area = int(m.group(1), 16)
start = 0
size = 0x2000
error_msg = 'ERROR: trying to overwrite reserved memory'
flash_ops(
u_boot_console, 'read', start, size, res_area, 1, error_msg,
EXPECTED_READ
)
i = i + 1
This got me looking at test/py/tests/test_spi.py more closely and this test is fine, so:
Reviewed-by: Tom Rini trini@konsulko.com
However, the error message 'No env file to read for SPI family device test' should really say that it's no test device configured (and similar change for env__spi_lock_unlock). A follow-up to rephrase those error messages would be appreciated.
Sure Tom, we will do.
Regards Padmarao
-- Tom

Hi Tom,
On 30/10/24 12:42 am, Tom Rini wrote:
On Tue, Oct 29, 2024 at 05:17:09PM +0530, Padmarao Begari wrote:
Update spi negative test case to prevent SF command from overwriting relocation memory area.
Signed-off-by: Padmarao Begari padmarao.begari@amd.com
test/py/tests/test_spi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/test/py/tests/test_spi.py b/test/py/tests/test_spi.py index 3160d58540..caca930327 100644 --- a/test/py/tests/test_spi.py +++ b/test/py/tests/test_spi.py @@ -693,4 +693,16 @@ def test_spi_negative(u_boot_console): u_boot_console, 'read', offset, size, addr, 1, error_msg, EXPECTED_READ )
# Read to relocation address
output = u_boot_console.run_command('bdinfo')
m = re.search('relocaddr\s*= (.+)', output)
res_area = int(m.group(1), 16)
start = 0
size = 0x2000
error_msg = 'ERROR: trying to overwrite reserved memory'
flash_ops(
u_boot_console, 'read', start, size, res_area, 1, error_msg, EXPECTED_READ
)
i = i + 1
This got me looking at test/py/tests/test_spi.py more closely and this test is fine, so:
Reviewed-by: Tom Rini trini@konsulko.com
However, the error message 'No env file to read for SPI family device test' should really say that it's no test device configured (and similar change for env__spi_lock_unlock). A follow-up to rephrase those error messages would be appreciated.
Thanks for looking it. We'll send the separate patch for the above.
Regards, Love Kumar

On 29/10/24 5:17 pm, Padmarao Begari wrote:
Update spi negative test case to prevent SF command from overwriting relocation memory area.
Signed-off-by: Padmarao Begari padmarao.begari@amd.com
test/py/tests/test_spi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/test/py/tests/test_spi.py b/test/py/tests/test_spi.py index 3160d58540..caca930327 100644 --- a/test/py/tests/test_spi.py +++ b/test/py/tests/test_spi.py @@ -693,4 +693,16 @@ def test_spi_negative(u_boot_console): u_boot_console, 'read', offset, size, addr, 1, error_msg, EXPECTED_READ )
# Read to relocation address
output = u_boot_console.run_command('bdinfo')
m = re.search('relocaddr\s*= (.+)', output)
res_area = int(m.group(1), 16)
start = 0
size = 0x2000
error_msg = 'ERROR: trying to overwrite reserved memory'
flash_ops(
u_boot_console, 'read', start, size, res_area, 1, error_msg, EXPECTED_READ
)
i = i + 1
Reviewed-by: Love Kumar love.kumar@amd.com
participants (4)
-
Begari, Padmarao
-
Love Kumar
-
Padmarao Begari
-
Tom Rini