Commit 5e5432b7 authored by Thomas Huth's avatar Thomas Huth Committed by Peter Maydell
Browse files

tests/boot-serial-test: Fix problem with timeout due to dropped characters



Commit 92b540da 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: 92b540da
Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
Message-id: 1518761564-9899-1-git-send-email-thuth@redhat.com
[PMM: added initializer for nbd to silence false-positive warning
 from OpenBSD 6 compiler]
Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parent cc5a0ae0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -111,13 +111,13 @@ 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 */
    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') {