diff mbox series

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

Message ID 20220823215300.1485789-7-quic_jaehyoo@quicinc.com
State Superseded
Delegated to: Michal Simek
Headers show
Series cmd/fru: move FRU handling support to common region | expand

Commit Message

Jae Hyun Yoo Aug. 23, 2022, 9:52 p.m. UTC
Add a simple test for the 'fru' command.

Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@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

Comments

Simon Glass Aug. 25, 2022, 1:25 a.m. UTC | #1
Hi,

On Tue, 23 Aug 2022 at 14:53, Jae Hyun Yoo <quic_jaehyoo@quicinc.com> wrote:
>
> Add a simple test for the 'fru' command.
>
> Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@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

Can you just rely on the C test and not have this?

Regards,
Simon
Jae Hyun Yoo Aug. 25, 2022, 2:35 p.m. UTC | #2
On 8/24/2022 6:25 PM, Simon Glass wrote:
> Hi,
> 
> On Tue, 23 Aug 2022 at 14:53, Jae Hyun Yoo <quic_jaehyoo@quicinc.com> wrote:
>>
>> Add a simple test for the 'fru' command.
>>
>> Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@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
> 
> Can you just rely on the C test and not have this?

Sure, I'll drop this python test script in the next spin.
Thanks for your review!

Regards,
Jae
diff mbox series

Patch

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
+
+@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)
+
+@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)