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

Jae Hyun Yoo quic_jaehyoo at quicinc.com
Tue Aug 16 23:42:32 CEST 2022


Hi Simon,

On 8/16/2022 1:42 PM, Simon Glass wrote:
> Hi Jae,
> 
> On Mon, 15 Aug 2022 at 16:58, Jae Hyun Yoo <quic_jaehyoo at quicinc.com> wrote:
>>
>> Add a simple test for the 'fru' command.
>>
>> Signed-off-by: Jae Hyun Yoo <quic_jaehyoo at quicinc.com>
>> ---
>> Changes from v1:
>>   * Newly added in v2. (Heinrich)
>>
>>   configs/sandbox64_defconfig        |  1 +
>>   configs/sandbox_defconfig          |  1 +
>>   configs/sandbox_flattree_defconfig |  1 +
>>   configs/sandbox_noinst_defconfig   |  1 +
>>   configs/sandbox_spl_defconfig      |  1 +
>>   configs/sandbox_vpl_defconfig      |  1 +
>>   test/py/tests/test_fru.py          | 47 ++++++++++++++++++++++++++++++
>>   7 files changed, 53 insertions(+)
>>   create mode 100644 test/py/tests/test_fru.py
> 
> Could this be written in C? Also, enabling it in just
> sandbox_defconfig should be enough.

Okay. I'll try to write it in C and will touch just sandbox_defconfig
in the next version.

Thanks,
Jae

> 
> https://u-boot.readthedocs.io/en/latest/develop/tests_writing.html
> 
> Regards,
> Simon
> 
> 
>>
>> diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
>> index 6553568e7684..9059e3c1c91d 100644
>> --- a/configs/sandbox64_defconfig
>> +++ b/configs/sandbox64_defconfig
>> @@ -83,6 +83,7 @@ CONFIG_CMD_CBFS=y
>>   CONFIG_CMD_CRAMFS=y
>>   CONFIG_CMD_EXT4_WRITE=y
>>   CONFIG_CMD_MTDPARTS=y
>> +CONFIG_CMD_FRU=y
>>   CONFIG_MAC_PARTITION=y
>>   CONFIG_AMIGA_PARTITION=y
>>   CONFIG_OF_CONTROL=y
>> 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/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
>> index 6d62feeb08a9..e71379599140 100644
>> --- a/configs/sandbox_flattree_defconfig
>> +++ b/configs/sandbox_flattree_defconfig
>> @@ -66,6 +66,7 @@ CONFIG_CMD_REGULATOR=y
>>   CONFIG_CMD_TPM=y
>>   CONFIG_CMD_TPM_TEST=y
>>   CONFIG_CMD_EXT4_WRITE=y
>> +CONFIG_CMD_FRU=y
>>   CONFIG_MAC_PARTITION=y
>>   CONFIG_AMIGA_PARTITION=y
>>   CONFIG_OF_CONTROL=y
>> diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig
>> index 9ee70c29c1a5..0b7f8bd9b3cc 100644
>> --- a/configs/sandbox_noinst_defconfig
>> +++ b/configs/sandbox_noinst_defconfig
>> @@ -84,6 +84,7 @@ CONFIG_CMD_TPM_TEST=y
>>   CONFIG_CMD_CBFS=y
>>   CONFIG_CMD_CRAMFS=y
>>   CONFIG_CMD_EXT4_WRITE=y
>> +CONFIG_CMD_FRU=y
>>   CONFIG_MAC_PARTITION=y
>>   CONFIG_AMIGA_PARTITION=y
>>   CONFIG_OF_CONTROL=y
>> diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
>> index ec2d26d4436b..05235ec1c493 100644
>> --- a/configs/sandbox_spl_defconfig
>> +++ b/configs/sandbox_spl_defconfig
>> @@ -84,6 +84,7 @@ CONFIG_CMD_TPM_TEST=y
>>   CONFIG_CMD_CBFS=y
>>   CONFIG_CMD_CRAMFS=y
>>   CONFIG_CMD_EXT4_WRITE=y
>> +CONFIG_CMD_FRU=y
>>   CONFIG_MAC_PARTITION=y
>>   CONFIG_AMIGA_PARTITION=y
>>   CONFIG_OF_CONTROL=y
>> diff --git a/configs/sandbox_vpl_defconfig b/configs/sandbox_vpl_defconfig
>> index 0d946b4ad779..7d4b808a5b49 100644
>> --- a/configs/sandbox_vpl_defconfig
>> +++ b/configs/sandbox_vpl_defconfig
>> @@ -96,6 +96,7 @@ CONFIG_CMD_TPM_TEST=y
>>   CONFIG_CMD_CBFS=y
>>   CONFIG_CMD_CRAMFS=y
>>   CONFIG_CMD_EXT4_WRITE=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