public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v3] test/py: reset: Add a test for reset command
@ 2024-02-20  7:41 Love Kumar
  2024-02-20 20:04 ` Tom Rini
  2024-03-02 15:18 ` Tom Rini
  0 siblings, 2 replies; 18+ messages in thread
From: Love Kumar @ 2024-02-20  7:41 UTC (permalink / raw)
  To: u-boot; +Cc: michal.simek, git

Add a test for reset commands which performs resetting of CPU, It does
COLD reset by default and WARM reset with -w option.

Signed-off-by: Love Kumar <love.kumar@amd.com>
---
Changes in v2:
 - Set bootmode through boardenv if modeboot is not defined
Changes in v3:
 - Fix the issue with bad pattern found on console
---
 test/py/tests/test_reset.py | 61 +++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 test/py/tests/test_reset.py

diff --git a/test/py/tests/test_reset.py b/test/py/tests/test_reset.py
new file mode 100644
index 000000000000..0178b1dc40a3
--- /dev/null
+++ b/test/py/tests/test_reset.py
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0
+# (C) Copyright 2023, Advanced Micro Devices, Inc.
+
+"""
+Note: This test doesn't rely on boardenv_* configuration value but they can
+change test behavior.
+
+For example:
+
+# Setup env__reset_test_skip to True if reset test is not possible or desired
+# and should be skipped.
+env__reset_test_skip = True
+
+# Setup env__reset_test to set the bootmode if 'modeboot' u-boot environment
+# variable is not set. Test will be skipped if bootmode is not set in both
+# places i.e, boardenv and modeboot u-boot environment variable
+env__reset_test = {
+    'bootmode': 'qspiboot',
+}
+
+# This test will be also skipped if the bootmode is detected to JTAG.
+"""
+
+import pytest
+import test_000_version
+
+def setup_reset_env(u_boot_console):
+    if u_boot_console.config.env.get('env__reset_test_skip', False):
+        pytest.skip('reset test is not enabled')
+
+    output = u_boot_console.run_command('echo $modeboot')
+    if output:
+        bootmode = output
+    else:
+        f = u_boot_console.config.env.get('env__reset_test', None)
+        if not f:
+            pytest.skip('bootmode cannot be determined')
+        bootmode = f.get('bootmode', 'jtagboot')
+
+    if 'jtag' in bootmode:
+        pytest.skip('skipping reset test due to jtag bootmode')
+
+def test_reset(u_boot_console):
+    """Test the reset command in non-JTAG bootmode.
+    It does COLD reset, which resets CPU, DDR and peripherals
+    """
+    setup_reset_env(u_boot_console)
+    u_boot_console.run_command('reset', wait_for_reboot=True)
+
+    # Checks the u-boot command prompt's functionality after reset
+    test_000_version.test_version(u_boot_console)
+
+def test_reset_w(u_boot_console):
+    """Test the reset -w command in non-JTAG bootmode.
+    It does WARM reset, which resets CPU but keep DDR/peripherals active.
+    """
+    setup_reset_env(u_boot_console)
+    u_boot_console.run_command('reset -w', wait_for_reboot=True)
+
+    # Checks the u-boot command prompt's functionality after reset
+    test_000_version.test_version(u_boot_console)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-03-11 15:15 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20  7:41 [PATCH v3] test/py: reset: Add a test for reset command Love Kumar
2024-02-20 20:04 ` Tom Rini
2024-03-02 15:18 ` Tom Rini
2024-03-03 21:58   ` Angelo Dureghello
2024-03-05 12:34     ` Michal Simek
2024-03-06 23:36       ` Angelo Dureghello
2024-03-07  0:10         ` Tom Rini
2024-03-07  7:56           ` Angelo Dureghello
2024-03-07  8:26             ` Michal Simek
2024-03-07 12:55               ` Tom Rini
2024-03-08  6:40                 ` Angelo Dureghello
2024-03-11  8:41                 ` Angelo Dureghello
2024-03-11  9:10                   ` Love Kumar
2024-03-11 14:39                     ` Tom Rini
2024-03-11 14:52                       ` Michal Simek
2024-03-11 15:09                         ` Tom Rini
2024-03-11 15:14                           ` Michal Simek
2024-03-11 15:15                             ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox