diff options
-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); |