diff options
author | Amit Shah <amit.shah@redhat.com> | 2010-08-26 09:36:29 +0530 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2010-08-26 09:43:58 +0530 |
commit | 6978ab579482e055bd679893491f74392b84e6ed (patch) | |
tree | 266b9b73b103b0e5215bca9e7896c5d94e6463df /auto-virtserial.c | |
parent | 875796bff9d5d1aea84648b1b634a6f374ad0c7f (diff) | |
download | test-virtserial-6978ab579482e055bd679893491f74392b84e6ed.tar.gz test-virtserial-6978ab579482e055bd679893491f74392b84e6ed.tar.xz test-virtserial-6978ab579482e055bd679893491f74392b84e6ed.zip |
auto-test: Add a key to specify poll events to poll for
We always invoked a guest poll with POLLIN|POLLOUT events. There's a
case where custom events might be necessary -- the sigio handler test,
for example. Add a new key to set the poll events.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'auto-virtserial.c')
-rw-r--r-- | auto-virtserial.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/auto-virtserial.c b/auto-virtserial.c index e0a61f6..ccd35e9 100644 --- a/auto-virtserial.c +++ b/auto-virtserial.c @@ -212,10 +212,21 @@ static int guest_write(int nr, int len) return guest_cmd(&gpkt); } -static int guest_poll(int nr, int timeout) +static int guest_set_poll_events(int nr, int events) { struct guest_packet gpkt; + gpkt.key = KEY_POLL_EVENTS; + gpkt.value = events; + return guest_cmd(&gpkt); +} + +static int guest_poll(int nr, int events, int timeout) +{ + struct guest_packet gpkt; + + guest_set_poll_events(nr, events); + gpkt.key = KEY_POLL; gpkt.value = timeout; return guest_cmd(&gpkt); @@ -574,7 +585,7 @@ static int test_nonblocking_write(int nr) * i is 128. */ for (i = 0; i < 200 && !test_done; i++) { - ret = guest_poll(nr, 0); + ret = guest_poll(nr, 0, 0); if (i && ret == 0) { /* vq full. Nonblocking IO and poll for that works. */ @@ -608,7 +619,7 @@ static int test_poll(int nr) int err, ret; guest_open_port(nr); - ret = guest_poll(nr, 0); + ret = guest_poll(nr, 0, 0); err = result(__func__, true, "POLLHUP", ret, POLLHUP, 0, OP_EQ, true); if (err) goto out; @@ -622,7 +633,7 @@ static int test_poll(int nr) host_connect_chardev(nr); /* Give the guest a chance to be scheduled in and react */ sleep(2); - ret = guest_poll(nr, 0); + ret = guest_poll(nr, 0, 0); err = result(__func__, true, "POLLOUT", ret, POLLOUT, 0, OP_EQ, true); if (err) goto out_close; @@ -630,7 +641,7 @@ static int test_poll(int nr) write(chardevs[nr].sock, &ret, sizeof(ret)); /* Give the guest a chance to be scheduled in and react */ sleep(2); - ret = guest_poll(nr, 0); + ret = guest_poll(nr, 0, 0); err = result(__func__, true, "POLLIN", ret, POLLIN|POLLOUT, 0, OP_EQ, true); @@ -750,7 +761,7 @@ static int test_guest_caching(int nr) /* Make sure the data made its way to the port in the guest */ sleep(2); - ret = guest_poll(nr, 10000); + ret = guest_poll(nr, 0, 10000); err = result(__func__, chardevs[nr].caching, "guest poll", ret, POLLIN|POLLOUT, POLLIN|POLLOUT, OP_EQ, false); @@ -1426,7 +1437,7 @@ static void post_test_cleanup(int nr) ret = guest_open_port(nr); if (ret < 0) goto skip_guest; - while ((ret = guest_poll(nr, 0))) { + while ((ret = guest_poll(nr, 0, 0))) { if ((ret > 0) && (ret & POLLIN)) guest_read(nr, BUF_LENGTH); else |