diff options
author | Amit Shah <amit.shah@redhat.com> | 2010-10-19 16:29:25 +0530 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2010-10-19 16:29:25 +0530 |
commit | 1565d95ef9a9256c3067cc8e8da96d2f4415b5b5 (patch) | |
tree | 27fe614f7f3ee7b37388631bc322b8c3ef933fc8 | |
parent | 50135f0856137f6eb9a0ce3bb8dc244311cc804c (diff) | |
download | test-virtserial-1565d95ef9a9256c3067cc8e8da96d2f4415b5b5.tar.gz test-virtserial-1565d95ef9a9256c3067cc8e8da96d2f4415b5b5.tar.xz test-virtserial-1565d95ef9a9256c3067cc8e8da96d2f4415b5b5.zip |
virtio: console: Enable non-blocking write "flooding" test
This test was added to test the case where a guest keeps writing to the
host while the host doesn't consume any of the data. Without the
nonblock patches, the guest used to freeze. Now, with the port fd
opened in nonblocking mode, the guest returns -EAGAIN. This wasn't
enabled so far as the guest just froze. All current kernels have this
patch now, so enable it.
Also ensure POLLOUT is set when some data from the host is consumed.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r-- | auto-virtserial.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/auto-virtserial.c b/auto-virtserial.c index 1428f0d..4b346f6 100644 --- a/auto-virtserial.c +++ b/auto-virtserial.c @@ -575,6 +575,7 @@ static int test_blocking_write(int nr) static int test_nonblocking_write(int nr) { + void *buf; unsigned int i; int err, ret; bool test_done; @@ -595,7 +596,8 @@ static int test_nonblocking_write(int nr) /* * We currently have 128 buffers in a virtqueue -- * hw/virtio-serial-bus.c, so this while loop should stop when - * i is 128. + * i is 128. However, the loop actually stops when i is 158 + * -- the qemu chardev itself can buffer some data. */ for (i = 0; i < 200 && !test_done; i++) { ret = guest_poll(nr, 0, 0); @@ -618,10 +620,26 @@ static int test_nonblocking_write(int nr) goto out; } + buf = malloc(BUF_LENGTH); + for (i = 0; i < 32; i++) { + /* + * One last thing: read out some buffers from host + * (more than the qemu-chardev buffer limit). See if + * guest gets POLLOUT set. + */ + read(chardevs[nr].sock, buf, BUF_LENGTH); + } + free(buf); + + sleep(2); + + ret = guest_poll(nr, 0, 0); + err = result(__func__, true, "read-poll", + ret, POLLOUT, POLLOUT, OP_EQ, true); out: ret = guest_set_port_nonblocking(nr, false); if (!err) - err = result(__func__, true, "blocking", ret, 0, 0, OP_EQ, true); + err = result(__func__, true, "non-block", ret, 0, 0, OP_EQ, true); host_close_chardev(nr); guest_close_port(nr); return err; @@ -1596,7 +1614,7 @@ static int start_tests(void) if (ret) return ret; -// run_test(TEST_NONBLOCK_WRITE, 2); + run_test(TEST_NONBLOCK_WRITE, 2); run_test(TEST_POLL, 2); |