* [U-Boot] [PATCH v1] test/py: add MMC/SD block write test
@ 2019-06-17 15:49 Jean-Jacques Hiblot
2019-06-17 16:44 ` Stephen Warren
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jean-Jacques Hiblot @ 2019-06-17 15:49 UTC (permalink / raw)
To: u-boot
Add a standalone MMC block write test. This allows direct testing of MMC
access rather than relying on doing so as a side-effect of e.g. DFU or
UMS testing, which may not be enabled on all platforms.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
This patch relies on patch "cmd: mem: Add a command to fill the memory
with random data".
test/py/tests/test_mmc_wr.py | 105 +++++++++++++++++++++++++++++++++++
1 file changed, 105 insertions(+)
create mode 100644 test/py/tests/test_mmc_wr.py
diff --git a/test/py/tests/test_mmc_wr.py b/test/py/tests/test_mmc_wr.py
new file mode 100644
index 0000000000..601279a6a4
--- /dev/null
+++ b/test/py/tests/test_mmc_wr.py
@@ -0,0 +1,105 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019, Texas Instrument
+# Author: Jean-Jacques Hiblot <jjhiblot@ti.com>
+
+# Test U-Boot's "mmc write" command. The test generates random data, writes it
+# to the eMMC or SD card, then reads it back and performs a comparison.
+
+import pytest
+import u_boot_utils
+
+"""
+This test relies on boardenv_* to containing configuration values to define
+which MMC devices should be tested. For example:
+
+env__mmc_wr_configs = (
+ {
+ "fixture_id": "emmc-boot0",
+ "is_emmc": True,
+ "devid": 1,
+ "partid": 1,
+ "sector": 0x10,
+ "count": 100,
+ "test_iterations": 50,
+ },
+ {
+ "fixture_id": "emmc-boot1",
+ "is_emmc": True,
+ "devid": 1,
+ "partid": 2,
+ "sector": 0x10,
+ "count": 100,
+ "test_iterations": 50,
+ },
+)
+
+"""
+
+ at pytest.mark.buildconfigspec('cmd_mmc','cmd_memory')
+def test_mmc_wr(u_boot_console, env__mmc_wr_config):
+ """Test the "mmc write" command.
+
+ Args:
+ u_boot_console: A U-Boot console connection.
+ env__mmc_wr_config: The single MMC configuration on which
+ to run the test. See the file-level comment above for details
+ of the format.
+
+ Returns:
+ Nothing.
+ """
+
+ is_emmc = env__mmc_wr_config['is_emmc']
+ devid = env__mmc_wr_config['devid']
+ partid = env__mmc_wr_config.get('partid', 0)
+ sector = env__mmc_wr_config.get('sector', 0)
+ count_sectors = env__mmc_wr_config.get('count', 1)
+ test_iterations = env__mmc_wr_config.get('test_iterations', 1)
+
+
+ count_bytes = count_sectors * 512
+ bcfg = u_boot_console.config.buildconfig
+ ram_base = u_boot_utils.find_ram_base(u_boot_console)
+ src_addr = '0x%08x' % ram_base
+ dst_addr = '0x%08x' % (ram_base + count_bytes)
+
+
+ for i in range(test_iterations):
+ # Generate random data
+ cmd = 'random %s %x' % (src_addr, count_bytes)
+ response = u_boot_console.run_command(cmd)
+ good_response = '%d bytes filled with random data' % (count_bytes)
+ assert good_response in response
+
+ # Select MMC device
+ cmd = 'mmc dev %d' % devid
+ if is_emmc:
+ cmd += ' %d' % partid
+ response = u_boot_console.run_command(cmd)
+ assert 'no card present' not in response
+ if is_emmc:
+ partid_response = "(part %d)" % partid
+ else:
+ partid_response = ""
+ good_response = 'mmc%d%s is current device' % (devid, partid_response)
+ assert good_response in response
+
+ # Write data
+ cmd = 'mmc write %s %x %x' % (src_addr, sector, count_sectors)
+ response = u_boot_console.run_command(cmd)
+ good_response = 'MMC write: dev # %d, block # %d, count %d ... %d blocks written: OK' % (
+ devid, sector, count_sectors, count_sectors)
+ assert good_response in response
+
+ # Read data
+ cmd = 'mmc read %s %x %x' % (dst_addr, sector, count_sectors)
+ response = u_boot_console.run_command(cmd)
+ good_response = 'MMC read: dev # %d, block # %d, count %d ... %d blocks read: OK' % (
+ devid, sector, count_sectors, count_sectors)
+ assert good_response in response
+
+ # Compare src and dst data
+ cmd = 'cmp.b %s %s %x' % (src_addr, dst_addr, count_bytes)
+ response = u_boot_console.run_command(cmd)
+ good_response = 'Total of %d byte(s) were the same' % (count_bytes)
+ assert good_response in response
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v1] test/py: add MMC/SD block write test
2019-06-17 15:49 [U-Boot] [PATCH v1] test/py: add MMC/SD block write test Jean-Jacques Hiblot
@ 2019-06-17 16:44 ` Stephen Warren
2019-07-02 8:03 ` Peng Fan
2019-07-24 2:27 ` Peng Fan
2 siblings, 0 replies; 7+ messages in thread
From: Stephen Warren @ 2019-06-17 16:44 UTC (permalink / raw)
To: u-boot
On 6/17/19 9:49 AM, Jean-Jacques Hiblot wrote:
> Add a standalone MMC block write test. This allows direct testing of MMC
> access rather than relying on doing so as a side-effect of e.g. DFU or
> UMS testing, which may not be enabled on all platforms.
Reviewed-by: Stephen Warren <swarren@nvidia.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v1] test/py: add MMC/SD block write test
2019-06-17 15:49 [U-Boot] [PATCH v1] test/py: add MMC/SD block write test Jean-Jacques Hiblot
2019-06-17 16:44 ` Stephen Warren
@ 2019-07-02 8:03 ` Peng Fan
2019-07-02 8:16 ` Jean-Jacques Hiblot
2019-07-02 8:34 ` Jean-Jacques Hiblot
2019-07-24 2:27 ` Peng Fan
2 siblings, 2 replies; 7+ messages in thread
From: Peng Fan @ 2019-07-02 8:03 UTC (permalink / raw)
To: u-boot
> Subject: [PATCH v1] test/py: add MMC/SD block write test
>
> Add a standalone MMC block write test. This allows direct testing of MMC
> access rather than relying on doing so as a side-effect of e.g. DFU or UMS
> testing, which may not be enabled on all platforms.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>
> ---
> This patch relies on patch "cmd: mem: Add a command to fill the memory
> with random data".
I not able to find "cmd: mem: Add a xx" in patchwork/mailbox, has this been applied?
I have taken this current patch into mmc-next.
Regards,
Peng
>
> test/py/tests/test_mmc_wr.py | 105
> +++++++++++++++++++++++++++++++++++
> 1 file changed, 105 insertions(+)
> create mode 100644 test/py/tests/test_mmc_wr.py
>
> diff --git a/test/py/tests/test_mmc_wr.py b/test/py/tests/test_mmc_wr.py
> new file mode 100644 index 0000000000..601279a6a4
> --- /dev/null
> +++ b/test/py/tests/test_mmc_wr.py
> @@ -0,0 +1,105 @@
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2019, Texas Instrument
> +# Author: Jean-Jacques Hiblot <jjhiblot@ti.com>
> +
> +# Test U-Boot's "mmc write" command. The test generates random data,
> +writes it # to the eMMC or SD card, then reads it back and performs a
> comparison.
> +
> +import pytest
> +import u_boot_utils
> +
> +"""
> +This test relies on boardenv_* to containing configuration values to
> +define which MMC devices should be tested. For example:
> +
> +env__mmc_wr_configs = (
> + {
> + "fixture_id": "emmc-boot0",
> + "is_emmc": True,
> + "devid": 1,
> + "partid": 1,
> + "sector": 0x10,
> + "count": 100,
> + "test_iterations": 50,
> + },
> + {
> + "fixture_id": "emmc-boot1",
> + "is_emmc": True,
> + "devid": 1,
> + "partid": 2,
> + "sector": 0x10,
> + "count": 100,
> + "test_iterations": 50,
> + },
> +)
> +
> +"""
> +
> + at pytest.mark.buildconfigspec('cmd_mmc','cmd_memory')
> +def test_mmc_wr(u_boot_console, env__mmc_wr_config):
> + """Test the "mmc write" command.
> +
> + Args:
> + u_boot_console: A U-Boot console connection.
> + env__mmc_wr_config: The single MMC configuration on which
> + to run the test. See the file-level comment above for details
> + of the format.
> +
> + Returns:
> + Nothing.
> + """
> +
> + is_emmc = env__mmc_wr_config['is_emmc']
> + devid = env__mmc_wr_config['devid']
> + partid = env__mmc_wr_config.get('partid', 0)
> + sector = env__mmc_wr_config.get('sector', 0)
> + count_sectors = env__mmc_wr_config.get('count', 1)
> + test_iterations = env__mmc_wr_config.get('test_iterations', 1)
> +
> +
> + count_bytes = count_sectors * 512
> + bcfg = u_boot_console.config.buildconfig
> + ram_base = u_boot_utils.find_ram_base(u_boot_console)
> + src_addr = '0x%08x' % ram_base
> + dst_addr = '0x%08x' % (ram_base + count_bytes)
> +
> +
> + for i in range(test_iterations):
> + # Generate random data
> + cmd = 'random %s %x' % (src_addr, count_bytes)
> + response = u_boot_console.run_command(cmd)
> + good_response = '%d bytes filled with random data' % (count_bytes)
> + assert good_response in response
> +
> + # Select MMC device
> + cmd = 'mmc dev %d' % devid
> + if is_emmc:
> + cmd += ' %d' % partid
> + response = u_boot_console.run_command(cmd)
> + assert 'no card present' not in response
> + if is_emmc:
> + partid_response = "(part %d)" % partid
> + else:
> + partid_response = ""
> + good_response = 'mmc%d%s is current device' % (devid,
> partid_response)
> + assert good_response in response
> +
> + # Write data
> + cmd = 'mmc write %s %x %x' % (src_addr, sector, count_sectors)
> + response = u_boot_console.run_command(cmd)
> + good_response = 'MMC write: dev # %d, block # %d, count %d ... %d
> blocks written: OK' % (
> + devid, sector, count_sectors, count_sectors)
> + assert good_response in response
> +
> + # Read data
> + cmd = 'mmc read %s %x %x' % (dst_addr, sector, count_sectors)
> + response = u_boot_console.run_command(cmd)
> + good_response = 'MMC read: dev # %d, block # %d, count %d ... %d
> blocks read: OK' % (
> + devid, sector, count_sectors, count_sectors)
> + assert good_response in response
> +
> + # Compare src and dst data
> + cmd = 'cmp.b %s %s %x' % (src_addr, dst_addr, count_bytes)
> + response = u_boot_console.run_command(cmd)
> + good_response = 'Total of %d byte(s) were the same' % (count_bytes)
> + assert good_response in response
> --
> 2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v1] test/py: add MMC/SD block write test
2019-07-02 8:03 ` Peng Fan
@ 2019-07-02 8:16 ` Jean-Jacques Hiblot
2019-07-02 8:27 ` Peng Fan
2019-07-02 8:34 ` Jean-Jacques Hiblot
1 sibling, 1 reply; 7+ messages in thread
From: Jean-Jacques Hiblot @ 2019-07-02 8:16 UTC (permalink / raw)
To: u-boot
On 02/07/2019 10:03, Peng Fan wrote:
>> Subject: [PATCH v1] test/py: add MMC/SD block write test
>>
>> Add a standalone MMC block write test. This allows direct testing of MMC
>> access rather than relying on doing so as a side-effect of e.g. DFU or UMS
>> testing, which may not be enabled on all platforms.
>>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>>
>> ---
>> This patch relies on patch "cmd: mem: Add a command to fill the memory
>> with random data".
> I not able to find "cmd: mem: Add a xx" in patchwork/mailbox, has this been applied?
You can get it from patchwork. I don't think it has been applied yet.
https://patchwork.ozlabs.org/patch/1116086/
> I have taken this current patch into mmc-next.
>
> Regards,
> Peng
>> test/py/tests/test_mmc_wr.py | 105
>> +++++++++++++++++++++++++++++++++++
>> 1 file changed, 105 insertions(+)
>> create mode 100644 test/py/tests/test_mmc_wr.py
>>
>> diff --git a/test/py/tests/test_mmc_wr.py b/test/py/tests/test_mmc_wr.py
>> new file mode 100644 index 0000000000..601279a6a4
>> --- /dev/null
>> +++ b/test/py/tests/test_mmc_wr.py
>> @@ -0,0 +1,105 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2019, Texas Instrument
>> +# Author: Jean-Jacques Hiblot <jjhiblot@ti.com>
>> +
>> +# Test U-Boot's "mmc write" command. The test generates random data,
>> +writes it # to the eMMC or SD card, then reads it back and performs a
>> comparison.
>> +
>> +import pytest
>> +import u_boot_utils
>> +
>> +"""
>> +This test relies on boardenv_* to containing configuration values to
>> +define which MMC devices should be tested. For example:
>> +
>> +env__mmc_wr_configs = (
>> + {
>> + "fixture_id": "emmc-boot0",
>> + "is_emmc": True,
>> + "devid": 1,
>> + "partid": 1,
>> + "sector": 0x10,
>> + "count": 100,
>> + "test_iterations": 50,
>> + },
>> + {
>> + "fixture_id": "emmc-boot1",
>> + "is_emmc": True,
>> + "devid": 1,
>> + "partid": 2,
>> + "sector": 0x10,
>> + "count": 100,
>> + "test_iterations": 50,
>> + },
>> +)
>> +
>> +"""
>> +
>> + at pytest.mark.buildconfigspec('cmd_mmc','cmd_memory')
>> +def test_mmc_wr(u_boot_console, env__mmc_wr_config):
>> + """Test the "mmc write" command.
>> +
>> + Args:
>> + u_boot_console: A U-Boot console connection.
>> + env__mmc_wr_config: The single MMC configuration on which
>> + to run the test. See the file-level comment above for details
>> + of the format.
>> +
>> + Returns:
>> + Nothing.
>> + """
>> +
>> + is_emmc = env__mmc_wr_config['is_emmc']
>> + devid = env__mmc_wr_config['devid']
>> + partid = env__mmc_wr_config.get('partid', 0)
>> + sector = env__mmc_wr_config.get('sector', 0)
>> + count_sectors = env__mmc_wr_config.get('count', 1)
>> + test_iterations = env__mmc_wr_config.get('test_iterations', 1)
>> +
>> +
>> + count_bytes = count_sectors * 512
>> + bcfg = u_boot_console.config.buildconfig
>> + ram_base = u_boot_utils.find_ram_base(u_boot_console)
>> + src_addr = '0x%08x' % ram_base
>> + dst_addr = '0x%08x' % (ram_base + count_bytes)
>> +
>> +
>> + for i in range(test_iterations):
>> + # Generate random data
>> + cmd = 'random %s %x' % (src_addr, count_bytes)
>> + response = u_boot_console.run_command(cmd)
>> + good_response = '%d bytes filled with random data' % (count_bytes)
>> + assert good_response in response
>> +
>> + # Select MMC device
>> + cmd = 'mmc dev %d' % devid
>> + if is_emmc:
>> + cmd += ' %d' % partid
>> + response = u_boot_console.run_command(cmd)
>> + assert 'no card present' not in response
>> + if is_emmc:
>> + partid_response = "(part %d)" % partid
>> + else:
>> + partid_response = ""
>> + good_response = 'mmc%d%s is current device' % (devid,
>> partid_response)
>> + assert good_response in response
>> +
>> + # Write data
>> + cmd = 'mmc write %s %x %x' % (src_addr, sector, count_sectors)
>> + response = u_boot_console.run_command(cmd)
>> + good_response = 'MMC write: dev # %d, block # %d, count %d ... %d
>> blocks written: OK' % (
>> + devid, sector, count_sectors, count_sectors)
>> + assert good_response in response
>> +
>> + # Read data
>> + cmd = 'mmc read %s %x %x' % (dst_addr, sector, count_sectors)
>> + response = u_boot_console.run_command(cmd)
>> + good_response = 'MMC read: dev # %d, block # %d, count %d ... %d
>> blocks read: OK' % (
>> + devid, sector, count_sectors, count_sectors)
>> + assert good_response in response
>> +
>> + # Compare src and dst data
>> + cmd = 'cmp.b %s %s %x' % (src_addr, dst_addr, count_bytes)
>> + response = u_boot_console.run_command(cmd)
>> + good_response = 'Total of %d byte(s) were the same' % (count_bytes)
>> + assert good_response in response
>> --
>> 2.17.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v1] test/py: add MMC/SD block write test
2019-07-02 8:16 ` Jean-Jacques Hiblot
@ 2019-07-02 8:27 ` Peng Fan
0 siblings, 0 replies; 7+ messages in thread
From: Peng Fan @ 2019-07-02 8:27 UTC (permalink / raw)
To: u-boot
> Subject: Re: [PATCH v1] test/py: add MMC/SD block write test
>
>
> On 02/07/2019 10:03, Peng Fan wrote:
> >> Subject: [PATCH v1] test/py: add MMC/SD block write test
> >>
> >> Add a standalone MMC block write test. This allows direct testing of
> >> MMC access rather than relying on doing so as a side-effect of e.g.
> >> DFU or UMS testing, which may not be enabled on all platforms.
> >>
> >> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> >>
> >> ---
> >> This patch relies on patch "cmd: mem: Add a command to fill the
> >> memory with random data".
> > I not able to find "cmd: mem: Add a xx" in patchwork/mailbox, has this been
> applied?
> You can get it from patchwork. I don't think it has been applied yet.
>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatch
> work.ozlabs.org%2Fpatch%2F1116086%2F&data=02%7C01%7Cpeng.fan
> %40nxp.com%7C0e988d7eca804682fe9908d6fec5a031%7C686ea1d3bc2b4c
> 6fa92cd99c5c301635%7C0%7C0%7C636976522093072876&sdata=fMlF
> x85MAQBqJWjwyLdJymNyoXvVKX4gcgCINAI%2By%2FI%3D&reserved=0
Thanks, then I'll wait Tom apply that patch.
-Peng.
>
>
> > I have taken this current patch into mmc-next.
> >
> > Regards,
> > Peng
> >> test/py/tests/test_mmc_wr.py | 105
> >> +++++++++++++++++++++++++++++++++++
> >> 1 file changed, 105 insertions(+)
> >> create mode 100644 test/py/tests/test_mmc_wr.py
> >>
> >> diff --git a/test/py/tests/test_mmc_wr.py
> >> b/test/py/tests/test_mmc_wr.py new file mode 100644 index
> >> 0000000000..601279a6a4
> >> --- /dev/null
> >> +++ b/test/py/tests/test_mmc_wr.py
> >> @@ -0,0 +1,105 @@
> >> +# SPDX-License-Identifier: GPL-2.0
> >> +# Copyright (c) 2019, Texas Instrument # Author: Jean-Jacques Hiblot
> >> +<jjhiblot@ti.com>
> >> +
> >> +# Test U-Boot's "mmc write" command. The test generates random data,
> >> +writes it # to the eMMC or SD card, then reads it back and performs
> >> +a
> >> comparison.
> >> +
> >> +import pytest
> >> +import u_boot_utils
> >> +
> >> +"""
> >> +This test relies on boardenv_* to containing configuration values to
> >> +define which MMC devices should be tested. For example:
> >> +
> >> +env__mmc_wr_configs = (
> >> + {
> >> + "fixture_id": "emmc-boot0",
> >> + "is_emmc": True,
> >> + "devid": 1,
> >> + "partid": 1,
> >> + "sector": 0x10,
> >> + "count": 100,
> >> + "test_iterations": 50,
> >> + },
> >> + {
> >> + "fixture_id": "emmc-boot1",
> >> + "is_emmc": True,
> >> + "devid": 1,
> >> + "partid": 2,
> >> + "sector": 0x10,
> >> + "count": 100,
> >> + "test_iterations": 50,
> >> + },
> >> +)
> >> +
> >> +"""
> >> +
> >> + at pytest.mark.buildconfigspec('cmd_mmc','cmd_memory')
> >> +def test_mmc_wr(u_boot_console, env__mmc_wr_config):
> >> + """Test the "mmc write" command.
> >> +
> >> + Args:
> >> + u_boot_console: A U-Boot console connection.
> >> + env__mmc_wr_config: The single MMC configuration on which
> >> + to run the test. See the file-level comment above for
> details
> >> + of the format.
> >> +
> >> + Returns:
> >> + Nothing.
> >> + """
> >> +
> >> + is_emmc = env__mmc_wr_config['is_emmc']
> >> + devid = env__mmc_wr_config['devid']
> >> + partid = env__mmc_wr_config.get('partid', 0)
> >> + sector = env__mmc_wr_config.get('sector', 0)
> >> + count_sectors = env__mmc_wr_config.get('count', 1)
> >> + test_iterations = env__mmc_wr_config.get('test_iterations', 1)
> >> +
> >> +
> >> + count_bytes = count_sectors * 512
> >> + bcfg = u_boot_console.config.buildconfig
> >> + ram_base = u_boot_utils.find_ram_base(u_boot_console)
> >> + src_addr = '0x%08x' % ram_base
> >> + dst_addr = '0x%08x' % (ram_base + count_bytes)
> >> +
> >> +
> >> + for i in range(test_iterations):
> >> + # Generate random data
> >> + cmd = 'random %s %x' % (src_addr, count_bytes)
> >> + response = u_boot_console.run_command(cmd)
> >> + good_response = '%d bytes filled with random data' % (count_bytes)
> >> + assert good_response in response
> >> +
> >> + # Select MMC device
> >> + cmd = 'mmc dev %d' % devid
> >> + if is_emmc:
> >> + cmd += ' %d' % partid
> >> + response = u_boot_console.run_command(cmd)
> >> + assert 'no card present' not in response
> >> + if is_emmc:
> >> + partid_response = "(part %d)" % partid
> >> + else:
> >> + partid_response = ""
> >> + good_response = 'mmc%d%s is current device' % (devid,
> >> partid_response)
> >> + assert good_response in response
> >> +
> >> + # Write data
> >> + cmd = 'mmc write %s %x %x' % (src_addr, sector, count_sectors)
> >> + response = u_boot_console.run_command(cmd)
> >> + good_response = 'MMC write: dev # %d, block # %d, count %d ... %d
> >> blocks written: OK' % (
> >> + devid, sector, count_sectors, count_sectors)
> >> + assert good_response in response
> >> +
> >> + # Read data
> >> + cmd = 'mmc read %s %x %x' % (dst_addr, sector, count_sectors)
> >> + response = u_boot_console.run_command(cmd)
> >> + good_response = 'MMC read: dev # %d, block # %d, count %d ... %d
> >> blocks read: OK' % (
> >> + devid, sector, count_sectors, count_sectors)
> >> + assert good_response in response
> >> +
> >> + # Compare src and dst data
> >> + cmd = 'cmp.b %s %s %x' % (src_addr, dst_addr, count_bytes)
> >> + response = u_boot_console.run_command(cmd)
> >> + good_response = 'Total of %d byte(s) were the same' % (count_bytes)
> >> + assert good_response in response
> >> --
> >> 2.17.1
> >
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v1] test/py: add MMC/SD block write test
2019-07-02 8:03 ` Peng Fan
2019-07-02 8:16 ` Jean-Jacques Hiblot
@ 2019-07-02 8:34 ` Jean-Jacques Hiblot
1 sibling, 0 replies; 7+ messages in thread
From: Jean-Jacques Hiblot @ 2019-07-02 8:34 UTC (permalink / raw)
To: u-boot
On 02/07/2019 10:03, Peng Fan wrote:
>> Subject: [PATCH v1] test/py: add MMC/SD block write test
>>
>> Add a standalone MMC block write test. This allows direct testing of MMC
>> access rather than relying on doing so as a side-effect of e.g. DFU or UMS
>> testing, which may not be enabled on all platforms.
>>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>>
>> ---
>> This patch relies on patch "cmd: mem: Add a command to fill the memory
>> with random data".
> I not able to find "cmd: mem: Add a xx" in patchwork/mailbox, has this been applied?
> I have taken this current patch into mmc-next.
I've just posted a v2 to fix build breakage. I had not passed the v1
trough travis and it was a bad idea.
JJ
>
> Regards,
> Peng
>> test/py/tests/test_mmc_wr.py | 105
>> +++++++++++++++++++++++++++++++++++
>> 1 file changed, 105 insertions(+)
>> create mode 100644 test/py/tests/test_mmc_wr.py
>>
>> diff --git a/test/py/tests/test_mmc_wr.py b/test/py/tests/test_mmc_wr.py
>> new file mode 100644 index 0000000000..601279a6a4
>> --- /dev/null
>> +++ b/test/py/tests/test_mmc_wr.py
>> @@ -0,0 +1,105 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2019, Texas Instrument
>> +# Author: Jean-Jacques Hiblot <jjhiblot@ti.com>
>> +
>> +# Test U-Boot's "mmc write" command. The test generates random data,
>> +writes it # to the eMMC or SD card, then reads it back and performs a
>> comparison.
>> +
>> +import pytest
>> +import u_boot_utils
>> +
>> +"""
>> +This test relies on boardenv_* to containing configuration values to
>> +define which MMC devices should be tested. For example:
>> +
>> +env__mmc_wr_configs = (
>> + {
>> + "fixture_id": "emmc-boot0",
>> + "is_emmc": True,
>> + "devid": 1,
>> + "partid": 1,
>> + "sector": 0x10,
>> + "count": 100,
>> + "test_iterations": 50,
>> + },
>> + {
>> + "fixture_id": "emmc-boot1",
>> + "is_emmc": True,
>> + "devid": 1,
>> + "partid": 2,
>> + "sector": 0x10,
>> + "count": 100,
>> + "test_iterations": 50,
>> + },
>> +)
>> +
>> +"""
>> +
>> + at pytest.mark.buildconfigspec('cmd_mmc','cmd_memory')
>> +def test_mmc_wr(u_boot_console, env__mmc_wr_config):
>> + """Test the "mmc write" command.
>> +
>> + Args:
>> + u_boot_console: A U-Boot console connection.
>> + env__mmc_wr_config: The single MMC configuration on which
>> + to run the test. See the file-level comment above for details
>> + of the format.
>> +
>> + Returns:
>> + Nothing.
>> + """
>> +
>> + is_emmc = env__mmc_wr_config['is_emmc']
>> + devid = env__mmc_wr_config['devid']
>> + partid = env__mmc_wr_config.get('partid', 0)
>> + sector = env__mmc_wr_config.get('sector', 0)
>> + count_sectors = env__mmc_wr_config.get('count', 1)
>> + test_iterations = env__mmc_wr_config.get('test_iterations', 1)
>> +
>> +
>> + count_bytes = count_sectors * 512
>> + bcfg = u_boot_console.config.buildconfig
>> + ram_base = u_boot_utils.find_ram_base(u_boot_console)
>> + src_addr = '0x%08x' % ram_base
>> + dst_addr = '0x%08x' % (ram_base + count_bytes)
>> +
>> +
>> + for i in range(test_iterations):
>> + # Generate random data
>> + cmd = 'random %s %x' % (src_addr, count_bytes)
>> + response = u_boot_console.run_command(cmd)
>> + good_response = '%d bytes filled with random data' % (count_bytes)
>> + assert good_response in response
>> +
>> + # Select MMC device
>> + cmd = 'mmc dev %d' % devid
>> + if is_emmc:
>> + cmd += ' %d' % partid
>> + response = u_boot_console.run_command(cmd)
>> + assert 'no card present' not in response
>> + if is_emmc:
>> + partid_response = "(part %d)" % partid
>> + else:
>> + partid_response = ""
>> + good_response = 'mmc%d%s is current device' % (devid,
>> partid_response)
>> + assert good_response in response
>> +
>> + # Write data
>> + cmd = 'mmc write %s %x %x' % (src_addr, sector, count_sectors)
>> + response = u_boot_console.run_command(cmd)
>> + good_response = 'MMC write: dev # %d, block # %d, count %d ... %d
>> blocks written: OK' % (
>> + devid, sector, count_sectors, count_sectors)
>> + assert good_response in response
>> +
>> + # Read data
>> + cmd = 'mmc read %s %x %x' % (dst_addr, sector, count_sectors)
>> + response = u_boot_console.run_command(cmd)
>> + good_response = 'MMC read: dev # %d, block # %d, count %d ... %d
>> blocks read: OK' % (
>> + devid, sector, count_sectors, count_sectors)
>> + assert good_response in response
>> +
>> + # Compare src and dst data
>> + cmd = 'cmp.b %s %s %x' % (src_addr, dst_addr, count_bytes)
>> + response = u_boot_console.run_command(cmd)
>> + good_response = 'Total of %d byte(s) were the same' % (count_bytes)
>> + assert good_response in response
>> --
>> 2.17.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v1] test/py: add MMC/SD block write test
2019-06-17 15:49 [U-Boot] [PATCH v1] test/py: add MMC/SD block write test Jean-Jacques Hiblot
2019-06-17 16:44 ` Stephen Warren
2019-07-02 8:03 ` Peng Fan
@ 2019-07-24 2:27 ` Peng Fan
2 siblings, 0 replies; 7+ messages in thread
From: Peng Fan @ 2019-07-24 2:27 UTC (permalink / raw)
To: u-boot
> Subject: [PATCH v1] test/py: add MMC/SD block write test
>
> Add a standalone MMC block write test. This allows direct testing of MMC
> access rather than relying on doing so as a side-effect of e.g. DFU or UMS
> testing, which may not be enabled on all platforms.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>
> ---
> This patch relies on patch "cmd: mem: Add a command to fill the memory
> with random data".
>
> test/py/tests/test_mmc_wr.py | 105
> +++++++++++++++++++++++++++++++++++
> 1 file changed, 105 insertions(+)
> create mode 100644 test/py/tests/test_mmc_wr.py
>
> diff --git a/test/py/tests/test_mmc_wr.py b/test/py/tests/test_mmc_wr.py
> new file mode 100644 index 0000000000..601279a6a4
> --- /dev/null
> +++ b/test/py/tests/test_mmc_wr.py
> @@ -0,0 +1,105 @@
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2019, Texas Instrument
> +# Author: Jean-Jacques Hiblot <jjhiblot@ti.com>
> +
> +# Test U-Boot's "mmc write" command. The test generates random data,
> +writes it # to the eMMC or SD card, then reads it back and performs a
> comparison.
> +
> +import pytest
> +import u_boot_utils
> +
> +"""
> +This test relies on boardenv_* to containing configuration values to
> +define which MMC devices should be tested. For example:
> +
> +env__mmc_wr_configs = (
> + {
> + "fixture_id": "emmc-boot0",
> + "is_emmc": True,
> + "devid": 1,
> + "partid": 1,
> + "sector": 0x10,
> + "count": 100,
> + "test_iterations": 50,
> + },
> + {
> + "fixture_id": "emmc-boot1",
> + "is_emmc": True,
> + "devid": 1,
> + "partid": 2,
> + "sector": 0x10,
> + "count": 100,
> + "test_iterations": 50,
> + },
> +)
> +
> +"""
> +
> + at pytest.mark.buildconfigspec('cmd_mmc','cmd_memory')
> +def test_mmc_wr(u_boot_console, env__mmc_wr_config):
> + """Test the "mmc write" command.
> +
> + Args:
> + u_boot_console: A U-Boot console connection.
> + env__mmc_wr_config: The single MMC configuration on which
> + to run the test. See the file-level comment above for details
> + of the format.
> +
> + Returns:
> + Nothing.
> + """
> +
> + is_emmc = env__mmc_wr_config['is_emmc']
> + devid = env__mmc_wr_config['devid']
> + partid = env__mmc_wr_config.get('partid', 0)
> + sector = env__mmc_wr_config.get('sector', 0)
> + count_sectors = env__mmc_wr_config.get('count', 1)
> + test_iterations = env__mmc_wr_config.get('test_iterations', 1)
> +
> +
> + count_bytes = count_sectors * 512
> + bcfg = u_boot_console.config.buildconfig
> + ram_base = u_boot_utils.find_ram_base(u_boot_console)
> + src_addr = '0x%08x' % ram_base
> + dst_addr = '0x%08x' % (ram_base + count_bytes)
> +
> +
> + for i in range(test_iterations):
> + # Generate random data
> + cmd = 'random %s %x' % (src_addr, count_bytes)
> + response = u_boot_console.run_command(cmd)
> + good_response = '%d bytes filled with random data' % (count_bytes)
> + assert good_response in response
> +
> + # Select MMC device
> + cmd = 'mmc dev %d' % devid
> + if is_emmc:
> + cmd += ' %d' % partid
> + response = u_boot_console.run_command(cmd)
> + assert 'no card present' not in response
> + if is_emmc:
> + partid_response = "(part %d)" % partid
> + else:
> + partid_response = ""
> + good_response = 'mmc%d%s is current device' % (devid,
> partid_response)
> + assert good_response in response
> +
> + # Write data
> + cmd = 'mmc write %s %x %x' % (src_addr, sector, count_sectors)
> + response = u_boot_console.run_command(cmd)
> + good_response = 'MMC write: dev # %d, block # %d, count %d ... %d
> blocks written: OK' % (
> + devid, sector, count_sectors, count_sectors)
> + assert good_response in response
> +
> + # Read data
> + cmd = 'mmc read %s %x %x' % (dst_addr, sector, count_sectors)
> + response = u_boot_console.run_command(cmd)
> + good_response = 'MMC read: dev # %d, block # %d, count %d ... %d
> blocks read: OK' % (
> + devid, sector, count_sectors, count_sectors)
> + assert good_response in response
> +
> + # Compare src and dst data
> + cmd = 'cmp.b %s %s %x' % (src_addr, dst_addr, count_bytes)
> + response = u_boot_console.run_command(cmd)
> + good_response = 'Total of %d byte(s) were the same' % (count_bytes)
> + assert good_response in response
Applied to mmc/master.
Thanks,
Peng
> --
> 2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-07-24 2:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 15:49 [U-Boot] [PATCH v1] test/py: add MMC/SD block write test Jean-Jacques Hiblot
2019-06-17 16:44 ` Stephen Warren
2019-07-02 8:03 ` Peng Fan
2019-07-02 8:16 ` Jean-Jacques Hiblot
2019-07-02 8:27 ` Peng Fan
2019-07-02 8:34 ` Jean-Jacques Hiblot
2019-07-24 2:27 ` Peng Fan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.