[PATCH v3 6/7] test: py: fru: add a test for the fru command

Jae Hyun Yoo quic_jaehyoo at quicinc.com
Tue Aug 23 23:52:59 CEST 2022


Add a simple test for the 'fru' command.

Signed-off-by: Jae Hyun Yoo <quic_jaehyoo at quicinc.com>
---
Changes from v2:
 * Added CONFIG_CMD_FRU=y only into the sandbox_defconfig. (Simon)

Changes from v1:
 * Newly added in v2. (Heinrich)

 configs/sandbox_defconfig |  1 +
 test/py/tests/test_fru.py | 47 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 test/py/tests/test_fru.py

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index eba7bcbb483b..293e39706cf2 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -115,6 +115,7 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_STACKPROTECTOR_TEST=y
+CONFIG_CMD_FRU=y
 CONFIG_MAC_PARTITION=y
 CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
diff --git a/test/py/tests/test_fru.py b/test/py/tests/test_fru.py
new file mode 100644
index 000000000000..e5e1d7d00639
--- /dev/null
+++ b/test/py/tests/test_fru.py
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+
+import pytest
+import u_boot_utils
+
+ at pytest.mark.buildconfigspec('cmd_fru')
+def test_fru_board(u_boot_console):
+    """Test that fru command generates and captures board FRU information as
+    expected."""
+
+    ram_base = u_boot_utils.find_ram_base(u_boot_console)
+    addr = '0x%x' % ram_base
+    expected_response = 'rc:0'
+    response = u_boot_console.run_command('fru generate -b ' + addr + ' abcd efgh ijkl mnop qrst uvwx; echo rc:$?')
+    assert(expected_response in response)
+    response = u_boot_console.run_command('fru capture ' + addr + '; echo rc:$?')
+    assert(expected_response in response)
+    response = u_boot_console.run_command('fru display')
+    assert('Manufacturer Name: abcd' in response)
+    assert('Product Name: efgh' in response)
+    assert('Serial Number: ijkl' in response)
+    assert('Part Number: mnop' in response)
+    assert('File ID: qrst' in response)
+    assert('Custom Type/Length: 0xc4' in response)
+
+ at pytest.mark.buildconfigspec('cmd_fru')
+def test_fru_product(u_boot_console):
+    """Test that fru command generates and captures product FRU information as
+    expected."""
+
+    ram_base = u_boot_utils.find_ram_base(u_boot_console)
+    addr = '0x%x' % ram_base
+    expected_response = 'rc:0'
+    response = u_boot_console.run_command('fru generate -p ' + addr + ' abcd efgh ijkl mnop qrst uvwx yz01 2345; echo rc:$?')
+    assert(expected_response in response)
+    response = u_boot_console.run_command('fru capture ' + addr + '; echo rc:$?')
+    assert(expected_response in response)
+    response = u_boot_console.run_command('fru display')
+    assert('Manufacturer Name: abcd' in response)
+    assert('Product Name: efgh' in response)
+    assert('Part Number: ijkl' in response)
+    assert('Version Number: mnop' in response)
+    assert('Serial Number: qrst' in response)
+    assert('Asset Number: uvwx' in response)
+    assert('File ID: yz01' in response)
+    assert('Custom Type/Length: 0xc4' in response)
-- 
2.25.1



More information about the U-Boot mailing list