diff mbox series

[v2,3/3] test: dm: mmc: Check block erasing boundaries

Message ID 20230126092419.534514-3-loic.poulain@linaro.org
State Accepted
Commit 94f40b94506397d4927c800f38e96a95e5c50c71
Headers show
Series [v2,1/3] mmc: Check support for TRIM operations | expand

Commit Message

Loic Poulain Jan. 26, 2023, 9:24 a.m. UTC
Verify that erasing blocks does not impact adjacent ones.
- Write four blocks [0 1 2 3]
- Erase two blocks [ 1 2 ]
- Verify [0 1 2 3 ]

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
v2: Add this change to the series

 test/dm/mmc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Simon Glass Jan. 27, 2023, 2:30 p.m. UTC | #1
Hi Loic,

On Thu, 26 Jan 2023 at 02:24, Loic Poulain <loic.poulain@linaro.org> wrote:
>
> Verify that erasing blocks does not impact adjacent ones.
> - Write four blocks [0 1 2 3]
> - Erase two blocks [ 1 2 ]
> - Verify [0 1 2 3 ]
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> ---
> v2: Add this change to the series
>
>  test/dm/mmc.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

This looks good, but can you add the trim command to
sandbox_mmc_send_cmd()? Then you can test that as well.


>
> diff --git a/test/dm/mmc.c b/test/dm/mmc.c
> index f744452ff2..b1eb8bee2f 100644
> --- a/test/dm/mmc.c
> +++ b/test/dm/mmc.c
> @@ -30,7 +30,7 @@ static int dm_test_mmc_blk(struct unit_test_state *uts)
>         struct udevice *dev;
>         struct blk_desc *dev_desc;
>         int i;
> -       char write[1024], read[1024];
> +       char write[4 * 512], read[4 * 512];
>
>         ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
>         ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));
> @@ -39,14 +39,14 @@ static int dm_test_mmc_blk(struct unit_test_state *uts)
>         ut_asserteq(512, dev_desc->blksz);
>         for (i = 0; i < sizeof(write); i++)
>                 write[i] = i;
> -       ut_asserteq(2, blk_dwrite(dev_desc, 0, 2, write));
> -       ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
> +       ut_asserteq(4, blk_dwrite(dev_desc, 0, 4, write));
> +       ut_asserteq(4, blk_dread(dev_desc, 0, 4, read));
>         ut_asserteq_mem(write, read, sizeof(write));
>
> -       /* Now erase them */
> -       memset(write, '\0', sizeof(write));
> -       ut_asserteq(2, blk_derase(dev_desc, 0, 2));
> -       ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
> +       /* Now erase two of them [1 - 2] and verify all blocks */
> +       memset(&write[512], '\0', 2 * 512);
> +       ut_asserteq(2, blk_derase(dev_desc, 1, 2));
> +       ut_asserteq(4, blk_dread(dev_desc, 0, 4, read));
>         ut_asserteq_mem(write, read, sizeof(write));
>
>         return 0;
> --
> 2.34.1
>

Regards,
Simon
Loic Poulain Feb. 8, 2023, 8:13 a.m. UTC | #2
On Fri, 27 Jan 2023 at 15:30, Simon Glass <sjg@chromium.org> wrote:
>
> Hi Loic,
>
> On Thu, 26 Jan 2023 at 02:24, Loic Poulain <loic.poulain@linaro.org> wrote:
> >
> > Verify that erasing blocks does not impact adjacent ones.
> > - Write four blocks [0 1 2 3]
> > - Erase two blocks [ 1 2 ]
> > - Verify [0 1 2 3 ]
> >
> > Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> > ---
> > v2: Add this change to the series
> >
> >  test/dm/mmc.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
>
> This looks good, but can you add the trim command to
> sandbox_mmc_send_cmd()? Then you can test that as well.

The TRIM option is not exposed, it is internally managed inside mmc
depending on the need for it. So from a testing perspective, I can
only test that the mmc erase is doing what we ask correctly.

Regards,
Loic
Jaehoon Chung March 10, 2023, 2:32 a.m. UTC | #3
On 1/26/23 18:24, Loic Poulain wrote:
> Verify that erasing blocks does not impact adjacent ones.
> - Write four blocks [0 1 2 3]
> - Erase two blocks [ 1 2 ]
> - Verify [0 1 2 3 ]
> 
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>


Applied to u-boot-mmc/master.

Best Regards,
Jaehoon Chung

> ---
> v2: Add this change to the series
> 
>  test/dm/mmc.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/test/dm/mmc.c b/test/dm/mmc.c
> index f744452ff2..b1eb8bee2f 100644
> --- a/test/dm/mmc.c
> +++ b/test/dm/mmc.c
> @@ -30,7 +30,7 @@ static int dm_test_mmc_blk(struct unit_test_state *uts)
>  	struct udevice *dev;
>  	struct blk_desc *dev_desc;
>  	int i;
> -	char write[1024], read[1024];
> +	char write[4 * 512], read[4 * 512];
>  
>  	ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
>  	ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));
> @@ -39,14 +39,14 @@ static int dm_test_mmc_blk(struct unit_test_state *uts)
>  	ut_asserteq(512, dev_desc->blksz);
>  	for (i = 0; i < sizeof(write); i++)
>  		write[i] = i;
> -	ut_asserteq(2, blk_dwrite(dev_desc, 0, 2, write));
> -	ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
> +	ut_asserteq(4, blk_dwrite(dev_desc, 0, 4, write));
> +	ut_asserteq(4, blk_dread(dev_desc, 0, 4, read));
>  	ut_asserteq_mem(write, read, sizeof(write));
>  
> -	/* Now erase them */
> -	memset(write, '\0', sizeof(write));
> -	ut_asserteq(2, blk_derase(dev_desc, 0, 2));
> -	ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
> +	/* Now erase two of them [1 - 2] and verify all blocks */
> +	memset(&write[512], '\0', 2 * 512);
> +	ut_asserteq(2, blk_derase(dev_desc, 1, 2));
> +	ut_asserteq(4, blk_dread(dev_desc, 0, 4, read));
>  	ut_asserteq_mem(write, read, sizeof(write));
>  
>  	return 0;
diff mbox series

Patch

diff --git a/test/dm/mmc.c b/test/dm/mmc.c
index f744452ff2..b1eb8bee2f 100644
--- a/test/dm/mmc.c
+++ b/test/dm/mmc.c
@@ -30,7 +30,7 @@  static int dm_test_mmc_blk(struct unit_test_state *uts)
 	struct udevice *dev;
 	struct blk_desc *dev_desc;
 	int i;
-	char write[1024], read[1024];
+	char write[4 * 512], read[4 * 512];
 
 	ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
 	ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));
@@ -39,14 +39,14 @@  static int dm_test_mmc_blk(struct unit_test_state *uts)
 	ut_asserteq(512, dev_desc->blksz);
 	for (i = 0; i < sizeof(write); i++)
 		write[i] = i;
-	ut_asserteq(2, blk_dwrite(dev_desc, 0, 2, write));
-	ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
+	ut_asserteq(4, blk_dwrite(dev_desc, 0, 4, write));
+	ut_asserteq(4, blk_dread(dev_desc, 0, 4, read));
 	ut_asserteq_mem(write, read, sizeof(write));
 
-	/* Now erase them */
-	memset(write, '\0', sizeof(write));
-	ut_asserteq(2, blk_derase(dev_desc, 0, 2));
-	ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
+	/* Now erase two of them [1 - 2] and verify all blocks */
+	memset(&write[512], '\0', 2 * 512);
+	ut_asserteq(2, blk_derase(dev_desc, 1, 2));
+	ut_asserteq(4, blk_dread(dev_desc, 0, 4, read));
 	ut_asserteq_mem(write, read, sizeof(write));
 
 	return 0;