* [PATCH] mtd-utils: tests: avoid using only one block in nandpagetest
@ 2017-08-23 13:57 Miquel Raynal
2017-08-24 8:40 ` David Oberhollenzer
0 siblings, 1 reply; 3+ messages in thread
From: Miquel Raynal @ 2017-08-23 13:57 UTC (permalink / raw)
To: linux-mtd; +Cc: David Oberhollenzer, Miquel Raynal
Forbid the use of -c1 in nandpagetest which limits the number of blocks
to use at one. In that case, get_first_and_last_block() will return the
same id for both the first and the last blocks. In erasecrosstest(),
the logic is:
- erase/write/read/verify first block
- erase/write again first block
- erase *last* block
- read/verify first block
The case 'first == last' leads to erasing the block before reading it.
Hence the test will fail with no actual reason.
The patch does not forbid the use of -c1 as it could do it in
process_options() with a errmsg_die(). Instead, it warns the user and
uses a second block in order to avoid risking to break existing scripts.
Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
---
tests/mtd-tests/nandpagetest.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/mtd-tests/nandpagetest.c b/tests/mtd-tests/nandpagetest.c
index 4145ef7..ef6c126 100644
--- a/tests/mtd-tests/nandpagetest.c
+++ b/tests/mtd-tests/nandpagetest.c
@@ -452,6 +452,12 @@ int main(int argc, char **argv)
if (ebcnt < 0)
ebcnt = (mtd.eb_cnt - peb) / (skip + 1);
+ if (ebcnt == 1) {
+ fprintf(stderr, PROGRAM_NAME
+ " cannot run on a single block, will use 2 instead.\n");
+ ebcnt = 2;
+ }
+
if (peb >= mtd.eb_cnt)
return errmsg("physical erase block %d is out of range!", peb);
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd-utils: tests: avoid using only one block in nandpagetest
2017-08-23 13:57 [PATCH] mtd-utils: tests: avoid using only one block in nandpagetest Miquel Raynal
@ 2017-08-24 8:40 ` David Oberhollenzer
2017-08-24 9:01 ` Miquel RAYNAL
0 siblings, 1 reply; 3+ messages in thread
From: David Oberhollenzer @ 2017-08-24 8:40 UTC (permalink / raw)
To: Miquel Raynal, linux-mtd
Hi,
On 08/23/2017 03:57 PM, Miquel Raynal wrote:
> Forbid the use of -c1 in nandpagetest which limits the number of blocks
> to use at one. In that case, get_first_and_last_block() will return the
> same id for both the first and the last blocks. In erasecrosstest(),
> the logic is:
> - erase/write/read/verify first block
> - erase/write again first block
> - erase *last* block
> - read/verify first block
> The case 'first == last' leads to erasing the block before reading it.
> Hence the test will fail with no actual reason.
>
So if some existing automated test setup were to use this, it would
(as of right now) *always* fail and terminate with EXIT_FAILURE.
> The patch does not forbid the use of -c1 as it could do it in
> process_options() with a errmsg_die(). Instead, it warns the user and
> uses a second block in order to avoid risking to break existing scripts.
>
But wouldn't exactly that change the behavior of such a setup by suddenly
having all tests succeed?
If this combination of options always fails anyway, wouldn't it be more
appropriate to terminate with an error message in process_options instead?
Thanks,
David
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd-utils: tests: avoid using only one block in nandpagetest
2017-08-24 8:40 ` David Oberhollenzer
@ 2017-08-24 9:01 ` Miquel RAYNAL
0 siblings, 0 replies; 3+ messages in thread
From: Miquel RAYNAL @ 2017-08-24 9:01 UTC (permalink / raw)
To: David Oberhollenzer; +Cc: linux-mtd
Hi David,
> > The case 'first == last' leads to erasing the block before reading
> > it. Hence the test will fail with no actual reason.
> >
> So if some existing automated test setup were to use this, it would
> (as of right now) *always* fail and terminate with EXIT_FAILURE.
>
> > The patch does not forbid the use of -c1 as it could do it in
> > process_options() with a errmsg_die(). Instead, it warns the user
> > and uses a second block in order to avoid risking to break existing
> > scripts.
> But wouldn't exactly that change the behavior of such a setup by
> suddenly having all tests succeed?
>
> If this combination of options always fails anyway, wouldn't it be
> more appropriate to terminate with an error message in
> process_options instead?
I though you would prefer to do not exit with an error but I it is ok
for me, I will resend the patch, with an error thrown in
process_options().
Regards,
Miquèl
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-24 9:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-23 13:57 [PATCH] mtd-utils: tests: avoid using only one block in nandpagetest Miquel Raynal
2017-08-24 8:40 ` David Oberhollenzer
2017-08-24 9:01 ` Miquel RAYNAL
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.