diff options
author | Amit Shah <amit.shah@redhat.com> | 2010-08-26 09:39:21 +0530 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2010-08-26 09:43:58 +0530 |
commit | 5c468270518dac6fd083f7527ae3a9992d154f0f (patch) | |
tree | ec133007c70e782037cc63c6cbfa22cef6030acd /auto-virtserial.c | |
parent | 6978ab579482e055bd679893491f74392b84e6ed (diff) | |
download | test-virtserial-5c468270518dac6fd083f7527ae3a9992d154f0f.tar.gz test-virtserial-5c468270518dac6fd083f7527ae3a9992d154f0f.tar.xz test-virtserial-5c468270518dac6fd083f7527ae3a9992d154f0f.zip |
auto-test: Add a test to check for blocking poll with SIGIO being invoked
With the process now capable of getting a SIGIO on incoming data, check
if a poll() for POLLIN that was blocked behaves properly.
This checks for both, the SIGIO delivery as well as poll output.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'auto-virtserial.c')
-rw-r--r-- | auto-virtserial.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/auto-virtserial.c b/auto-virtserial.c index ccd35e9..cb3f419 100644 --- a/auto-virtserial.c +++ b/auto-virtserial.c @@ -1241,6 +1241,7 @@ out: */ static int test_sigio_handler(int nr) { + struct guest_packet gpkt; int ret, err; guest_open_port(nr); @@ -1316,6 +1317,42 @@ static int test_sigio_handler(int nr) guest_close_port(3); guest_close_port(4); + /* + * Now for the poll test: poll for pollin, send data, both + * sigio and pollin should get set. + */ + ret = guest_open_port(nr); + err = result(__func__, true, "guest open", ret, -1, -1, OP_GT, false); + if (err) + return err; + + host_connect_chardev(nr); + + sleep(2); + guest_set_poll_events(nr, POLLIN); + + gpkt.key = KEY_POLL; + gpkt.value = -1; + guest_cmd_only(&gpkt); + sleep(2); + + /* Now the guest is blocking on data from us. */ + write(chardevs[nr].sock, &ret, sizeof(ret)); + sleep(2); + + /* Guest should have now come out of poll and also received SIGIO */ + get_guest_response(&gpkt); + err = result(__func__, true, "poll", gpkt.value, + POLLIN, POLLIN, OP_EQ, false); + + ret = guest_get_sigio_poll_result(nr); + err = result(__func__, true, "poll-sigio", + ret, POLLIN|POLLOUT, POLLIN|POLLOUT, OP_EQ, true); + + guest_read(nr, sizeof(ret)); + guest_close_port(nr); + host_close_chardev(nr); + return err; } |