summaryrefslogtreecommitdiffstats
path: root/auto-virtserial.c
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-09-28 16:51:53 +0530
committerAmit Shah <amit.shah@redhat.com>2010-09-28 16:51:53 +0530
commitda4085786b76598d279996c8e6ee87d3fa6a8da1 (patch)
tree84fe02e95349d217efc797553ed188c49ae638c9 /auto-virtserial.c
parentf3963acf119801118d585df35e8d51c0cd384f54 (diff)
downloadtest-virtserial-da4085786b76598d279996c8e6ee87d3fa6a8da1.tar.gz
test-virtserial-da4085786b76598d279996c8e6ee87d3fa6a8da1.tar.xz
test-virtserial-da4085786b76598d279996c8e6ee87d3fa6a8da1.zip
auto-test: Add test for lseek()
lseek() on console ports should fail with -ESPIPE. (This behaviour will be seen from kernel 2.6.37 onwards. Older kernels just returned success without seeking.) Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'auto-virtserial.c')
-rw-r--r--auto-virtserial.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/auto-virtserial.c b/auto-virtserial.c
index d11dd28..fb3f40f 100644
--- a/auto-virtserial.c
+++ b/auto-virtserial.c
@@ -232,6 +232,15 @@ static int guest_poll(int nr, int events, int timeout)
return guest_cmd(&gpkt);
}
+static int guest_lseek(int nr)
+{
+ struct guest_packet gpkt;
+
+ gpkt.key = KEY_LSEEK;
+ gpkt.value = nr;
+ return guest_cmd(&gpkt);
+}
+
static int guest_set_port_nonblocking(int nr, int value)
{
struct guest_packet gpkt;
@@ -662,6 +671,24 @@ out:
return err;
}
+/* lseek in guest - -ESPIPE is the desired result. */
+static int test_lseek(int nr)
+{
+ int err, ret;
+
+ ret = guest_open_port(nr);
+ err = result(__func__, true, "open", ret, -1, -1, OP_GT, false);
+ if (err)
+ return err;
+
+ ret = guest_lseek(nr);
+ err = result(__func__, true, "lseek",
+ ret, -ESPIPE, -ESPIPE, OP_EQ, true);
+
+ guest_close_port(nr);
+ return err;
+}
+
/*
* Tests if writes to guest get throttled after sending 1M data
* The invert parameter specifies the test should pass for ports
@@ -1398,6 +1425,7 @@ enum {
TEST_BLOCKING_WRITE,
TEST_NONBLOCK_WRITE,
TEST_POLL,
+ TEST_LSEEK,
TEST_G_THROTTLE,
TEST_H_THROTTLE,
TEST_G_CACHING,
@@ -1456,6 +1484,10 @@ static struct test_parameters {
.needs_guestok = true,
},
{
+ .test_function = test_lseek,
+ .needs_guestok = true,
+ },
+ {
.test_function = test_guest_throttle,
.needs_guestok = true,
},
@@ -1582,6 +1614,8 @@ static int start_tests(void)
run_test(TEST_POLL, 2);
+ run_test(TEST_LSEEK, 2);
+
#if 0
/*
* Guest throttling isn't needed anymore after design changes