From: LukÃÅ Doktor <ldoktor@xxxxxxxxxx> Signed-off-by: Lukas Doktor <ldoktor@xxxxxxxxxx> --- client/tests/kvm/scripts/virtio_guest.py | 23 +++++++++++++++++++++++ client/tests/kvm/tests/virtio_console.py | 11 +++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/scripts/virtio_guest.py b/client/tests/kvm/scripts/virtio_guest.py index b039ec9..bc86624 100755 --- a/client/tests/kvm/scripts/virtio_guest.py +++ b/client/tests/kvm/scripts/virtio_guest.py @@ -300,6 +300,29 @@ class VirtioGuest: print "FAIL: Events: " + str + " Expected: " + estr + def lseek(self, port, pos, how): + """ + Use lseek on the device. The device is unseekable so PASS is returned + when lseek command fails and vice versa. + + @param port: Name of the port + @param pos: Offset + @param how: Relativ offset os.SEEK_{SET,CUR,END} + """ + fd = self._open([port])[0] + + try: + os.lseek(fd, pos, how) + except Exception, inst: + if inst.errno == 29: + print "PASS: the lseek failed as expected" + else: + print inst + print "FAIL: unknown error" + else: + print "FAIL: the lseek unexpectedly passed" + + def blocking(self, port, mode=False): """ Set port function mode blocking/nonblocking diff --git a/client/tests/kvm/tests/virtio_console.py b/client/tests/kvm/tests/virtio_console.py index d083783..cf5665b 100644 --- a/client/tests/kvm/tests/virtio_console.py +++ b/client/tests/kvm/tests/virtio_console.py @@ -675,6 +675,16 @@ def run_virtio_console(test, params, env): on_guest("virt.poll('%s', %s)" % (port.name, select.POLLOUT), vm, 2) + def tlseek(vm, port): + """ + Tests the correct handling of lseek (expected fail) + + @param vm: Target virtual machine [vm, session, tmp_dir]. + @param port: Port used in test. + """ + # The virt.lseek returns PASS when the seek fails + on_guest("virt.lseek('%s', 0, 0)" % (port.name), vm, 2) + def trw_host_offline(vm, port): """ @@ -822,6 +832,7 @@ def run_virtio_console(test, params, env): test.do_test(tclose, [vm, send_pt], True) test.do_test(tmulti_open, [vm, send_pt], True) test.do_test(tpooling, [vm, send_pt]) + test.do_test(tlseek, [vm, send_pt]) test.do_test(trw_host_offline, [vm, send_pt]) test.do_test(trw_nonblocking_mode, [vm, send_pt]) test.do_test(trw_blocking_mode, [vm, send_pt]) -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html