* [Qemu-devel] [PATCH] tests/boot-serial-test: Fix problem with timeout due to dropped characters @ 2018-02-16 6:12 Thomas Huth 2018-02-16 10:15 ` Peter Maydell 2018-02-21 11:05 ` Paolo Bonzini 0 siblings, 2 replies; 6+ messages in thread From: Thomas Huth @ 2018-02-16 6:12 UTC (permalink / raw) To: qemu-devel, Peter Maydell Cc: Philippe Mathieu-Daudé, Dr. David Alan Gilbert, Richard Henderson, Paolo Bonzini Commit 92b540dac9fc3a5 introduce a counter to handle the timeouts in a better way. But in case ccnt reaches 512, the current read character is ignored - and if that character is part of the string that we are looking for, the test fails to match the string. Almost all of the tests look for a string within the first 512 bytes of firmware output, so the problem never triggered there. But the hppa test that has been added recently looks for a longer string at the very end of a long output, thus there's a chance that we miss a character there so that the test fails unexpectedly. Fix it by *not* reading and dropping a character if the counter reaches 512. Fixes: 92b540dac9fc3a572c7342edd0b073000f5a6abf Signed-off-by: Thomas Huth <thuth@redhat.com> --- @Peter: Since this fixes the problem with running "make check", could you maybe apply this directly to the master branch? Thanks, and sorry for the inconvenience! tests/boot-serial-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index ea87a80..696f7a3 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -101,7 +101,7 @@ static void check_guest_output(const testdef_t *test, int fd) /* Poll serial output... Wait at most 60 seconds */ for (i = 0; i < 6000; ++i) { ccnt = 0; - while ((nbr = read(fd, &ch, 1)) == 1 && ccnt++ < 512) { + while (ccnt++ < 512 && (nbr = read(fd, &ch, 1)) == 1) { if (ch == test->expect[pos]) { pos += 1; if (test->expect[pos] == '\0') { -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] tests/boot-serial-test: Fix problem with timeout due to dropped characters 2018-02-16 6:12 [Qemu-devel] [PATCH] tests/boot-serial-test: Fix problem with timeout due to dropped characters Thomas Huth @ 2018-02-16 10:15 ` Peter Maydell 2018-02-16 10:25 ` Thomas Huth 2018-02-21 11:05 ` Paolo Bonzini 1 sibling, 1 reply; 6+ messages in thread From: Peter Maydell @ 2018-02-16 10:15 UTC (permalink / raw) To: Thomas Huth Cc: QEMU Developers, Philippe Mathieu-Daudé, Dr. David Alan Gilbert, Richard Henderson, Paolo Bonzini On 16 February 2018 at 06:12, Thomas Huth <thuth@redhat.com> wrote: > Commit 92b540dac9fc3a5 introduce a counter to handle the timeouts in a > better way. But in case ccnt reaches 512, the current read character is > ignored - and if that character is part of the string that we are looking > for, the test fails to match the string. > > Almost all of the tests look for a string within the first 512 bytes of > firmware output, so the problem never triggered there. But the hppa test > that has been added recently looks for a longer string at the very end of > a long output, thus there's a chance that we miss a character there so > that the test fails unexpectedly. Fix it by *not* reading and dropping a > character if the counter reaches 512. > > Fixes: 92b540dac9fc3a572c7342edd0b073000f5a6abf > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > @Peter: Since this fixes the problem with running "make check", could > you maybe apply this directly to the master branch? Thanks, and sorry > for the inconvenience! > > tests/boot-serial-test.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c > index ea87a80..696f7a3 100644 > --- a/tests/boot-serial-test.c > +++ b/tests/boot-serial-test.c > @@ -101,7 +101,7 @@ static void check_guest_output(const testdef_t *test, int fd) > /* Poll serial output... Wait at most 60 seconds */ > for (i = 0; i < 6000; ++i) { > ccnt = 0; > - while ((nbr = read(fd, &ch, 1)) == 1 && ccnt++ < 512) { > + while (ccnt++ < 512 && (nbr = read(fd, &ch, 1)) == 1) { > if (ch == test->expect[pos]) { > pos += 1; > if (test->expect[pos] == '\0') { I did a test build with this, but OpenBSD's compiler now complains: /home/qemu/tests/boot-serial-test.c: In function 'test_machine': /usr/local/include/glib-2.0/glib/gmacros.h:370:7: warning: 'nbr' may be used uninitialized in this function [-Wmaybe-uninitialized] if (expr) \ ^ /home/qemu/tests/boot-serial-test.c:114:12: note: 'nbr' was declared here int i, nbr, pos = 0, ccnt; ^ This is obviously a false positive, but we can silence it by --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -111,7 +111,7 @@ static testdef_t tests[] = { static void check_guest_output(const testdef_t *test, int fd) { bool output_ok = false; - int i, nbr, pos = 0, ccnt; + int i, nbr = 0, pos = 0, ccnt; char ch; /* Poll serial output... Wait at most 60 seconds */ so I'll just squash that change in if that's ok? thanks -- PMM ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] tests/boot-serial-test: Fix problem with timeout due to dropped characters 2018-02-16 10:15 ` Peter Maydell @ 2018-02-16 10:25 ` Thomas Huth 2018-02-16 11:19 ` Peter Maydell 0 siblings, 1 reply; 6+ messages in thread From: Thomas Huth @ 2018-02-16 10:25 UTC (permalink / raw) To: Peter Maydell Cc: QEMU Developers, Philippe Mathieu-Daudé, Dr. David Alan Gilbert, Richard Henderson, Paolo Bonzini On 16.02.2018 11:15, Peter Maydell wrote: > On 16 February 2018 at 06:12, Thomas Huth <thuth@redhat.com> wrote: >> Commit 92b540dac9fc3a5 introduce a counter to handle the timeouts in a >> better way. But in case ccnt reaches 512, the current read character is >> ignored - and if that character is part of the string that we are looking >> for, the test fails to match the string. >> >> Almost all of the tests look for a string within the first 512 bytes of >> firmware output, so the problem never triggered there. But the hppa test >> that has been added recently looks for a longer string at the very end of >> a long output, thus there's a chance that we miss a character there so >> that the test fails unexpectedly. Fix it by *not* reading and dropping a >> character if the counter reaches 512. >> >> Fixes: 92b540dac9fc3a572c7342edd0b073000f5a6abf >> Signed-off-by: Thomas Huth <thuth@redhat.com> >> --- >> @Peter: Since this fixes the problem with running "make check", could >> you maybe apply this directly to the master branch? Thanks, and sorry >> for the inconvenience! >> >> tests/boot-serial-test.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c >> index ea87a80..696f7a3 100644 >> --- a/tests/boot-serial-test.c >> +++ b/tests/boot-serial-test.c >> @@ -101,7 +101,7 @@ static void check_guest_output(const testdef_t *test, int fd) >> /* Poll serial output... Wait at most 60 seconds */ >> for (i = 0; i < 6000; ++i) { >> ccnt = 0; >> - while ((nbr = read(fd, &ch, 1)) == 1 && ccnt++ < 512) { >> + while (ccnt++ < 512 && (nbr = read(fd, &ch, 1)) == 1) { >> if (ch == test->expect[pos]) { >> pos += 1; >> if (test->expect[pos] == '\0') { > > I did a test build with this, but OpenBSD's compiler > now complains: > > /home/qemu/tests/boot-serial-test.c: In function 'test_machine': > /usr/local/include/glib-2.0/glib/gmacros.h:370:7: warning: 'nbr' may > be used uninitialized in this function [-Wmaybe-uninitialized] > if (expr) \ > ^ > /home/qemu/tests/boot-serial-test.c:114:12: note: 'nbr' was declared here > int i, nbr, pos = 0, ccnt; > ^ > > This is obviously a false positive, but we can silence it by > --- a/tests/boot-serial-test.c > +++ b/tests/boot-serial-test.c > @@ -111,7 +111,7 @@ static testdef_t tests[] = { > static void check_guest_output(const testdef_t *test, int fd) > { > bool output_ok = false; > - int i, nbr, pos = 0, ccnt; > + int i, nbr = 0, pos = 0, ccnt; > char ch; > > /* Poll serial output... Wait at most 60 seconds */ > > so I'll just squash that change in if that's ok? Sure! Thanks, Thomas PS: I think the OpenBSD compiler is wrong here, nbr should get initialized at least once before the g_assert(nbr >= 0) check ... ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] tests/boot-serial-test: Fix problem with timeout due to dropped characters 2018-02-16 10:25 ` Thomas Huth @ 2018-02-16 11:19 ` Peter Maydell 0 siblings, 0 replies; 6+ messages in thread From: Peter Maydell @ 2018-02-16 11:19 UTC (permalink / raw) To: Thomas Huth Cc: QEMU Developers, Philippe Mathieu-Daudé, Dr. David Alan Gilbert, Richard Henderson, Paolo Bonzini On 16 February 2018 at 10:25, Thomas Huth <thuth@redhat.com> wrote: > PS: I think the OpenBSD compiler is wrong here, nbr should get > initialized at least once before the g_assert(nbr >= 0) check ... Yes, I agree, but it does require some intelligence on the part of the compiler to figure out that the ccnt++ < 512 condition can't trigger first time round the loop. (It's a gcc 4.9.3, so presumably newer gcc are indeed smarter.) Applied to master. thanks -- PMM ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] tests/boot-serial-test: Fix problem with timeout due to dropped characters 2018-02-16 6:12 [Qemu-devel] [PATCH] tests/boot-serial-test: Fix problem with timeout due to dropped characters Thomas Huth 2018-02-16 10:15 ` Peter Maydell @ 2018-02-21 11:05 ` Paolo Bonzini 2018-02-21 11:10 ` Thomas Huth 1 sibling, 1 reply; 6+ messages in thread From: Paolo Bonzini @ 2018-02-21 11:05 UTC (permalink / raw) To: Thomas Huth, qemu-devel, Peter Maydell Cc: Philippe Mathieu-Daudé, Dr. David Alan Gilbert, Richard Henderson On 16/02/2018 07:12, Thomas Huth wrote: > Commit 92b540dac9fc3a5 introduce a counter to handle the timeouts in a > better way. But in case ccnt reaches 512, the current read character is > ignored - and if that character is part of the string that we are looking > for, the test fails to match the string. > > Almost all of the tests look for a string within the first 512 bytes of > firmware output, so the problem never triggered there. But the hppa test > that has been added recently looks for a longer string at the very end of > a long output, thus there's a chance that we miss a character there so > that the test fails unexpectedly. Fix it by *not* reading and dropping a > character if the counter reaches 512. > > Fixes: 92b540dac9fc3a572c7342edd0b073000f5a6abf > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > @Peter: Since this fixes the problem with running "make check", could > you maybe apply this directly to the master branch? Thanks, and sorry > for the inconvenience! > > tests/boot-serial-test.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c > index ea87a80..696f7a3 100644 > --- a/tests/boot-serial-test.c > +++ b/tests/boot-serial-test.c > @@ -101,7 +101,7 @@ static void check_guest_output(const testdef_t *test, int fd) > /* Poll serial output... Wait at most 60 seconds */ > for (i = 0; i < 6000; ++i) { > ccnt = 0; > - while ((nbr = read(fd, &ch, 1)) == 1 && ccnt++ < 512) { > + while (ccnt++ < 512 && (nbr = read(fd, &ch, 1)) == 1) { > if (ch == test->expect[pos]) { > pos += 1; > if (test->expect[pos] == '\0') { > Queued in the meanwhile, thanks. Paolo ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] tests/boot-serial-test: Fix problem with timeout due to dropped characters 2018-02-21 11:05 ` Paolo Bonzini @ 2018-02-21 11:10 ` Thomas Huth 0 siblings, 0 replies; 6+ messages in thread From: Thomas Huth @ 2018-02-21 11:10 UTC (permalink / raw) To: Paolo Bonzini, qemu-devel, Peter Maydell Cc: Philippe Mathieu-Daudé, Dr. David Alan Gilbert, Richard Henderson On 21.02.2018 12:05, Paolo Bonzini wrote: > On 16/02/2018 07:12, Thomas Huth wrote: >> Commit 92b540dac9fc3a5 introduce a counter to handle the timeouts in a >> better way. But in case ccnt reaches 512, the current read character is >> ignored - and if that character is part of the string that we are looking >> for, the test fails to match the string. >> >> Almost all of the tests look for a string within the first 512 bytes of >> firmware output, so the problem never triggered there. But the hppa test >> that has been added recently looks for a longer string at the very end of >> a long output, thus there's a chance that we miss a character there so >> that the test fails unexpectedly. Fix it by *not* reading and dropping a >> character if the counter reaches 512. >> >> Fixes: 92b540dac9fc3a572c7342edd0b073000f5a6abf >> Signed-off-by: Thomas Huth <thuth@redhat.com> >> --- >> @Peter: Since this fixes the problem with running "make check", could >> you maybe apply this directly to the master branch? Thanks, and sorry >> for the inconvenience! >> >> tests/boot-serial-test.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c >> index ea87a80..696f7a3 100644 >> --- a/tests/boot-serial-test.c >> +++ b/tests/boot-serial-test.c >> @@ -101,7 +101,7 @@ static void check_guest_output(const testdef_t *test, int fd) >> /* Poll serial output... Wait at most 60 seconds */ >> for (i = 0; i < 6000; ++i) { >> ccnt = 0; >> - while ((nbr = read(fd, &ch, 1)) == 1 && ccnt++ < 512) { >> + while (ccnt++ < 512 && (nbr = read(fd, &ch, 1)) == 1) { >> if (ch == test->expect[pos]) { >> pos += 1; >> if (test->expect[pos] == '\0') { >> > > Queued in the meanwhile, thanks. Thanks, but Peter already applied it to fix the "make check" failures: https://git.qemu.org/?p=qemu.git;a=commit;h=5e5432b766c424a5d1 Thomas ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-02-21 11:10 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-02-16 6:12 [Qemu-devel] [PATCH] tests/boot-serial-test: Fix problem with timeout due to dropped characters Thomas Huth 2018-02-16 10:15 ` Peter Maydell 2018-02-16 10:25 ` Thomas Huth 2018-02-16 11:19 ` Peter Maydell 2018-02-21 11:05 ` Paolo Bonzini 2018-02-21 11:10 ` Thomas Huth
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).