From patchwork Mon Dec 6 22:13:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 380242 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB6MAZSU006517 for ; Mon, 6 Dec 2010 22:10:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754192Ab0LFWJu (ORCPT ); Mon, 6 Dec 2010 17:09:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57365 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754109Ab0LFWJt (ORCPT ); Mon, 6 Dec 2010 17:09:49 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB6M9lN0015595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Dec 2010 17:09:47 -0500 Received: from virtlab105.virt.bos.redhat.com (virtlab105.virt.bos.redhat.com [10.16.72.124]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oB6M9kwd025134; Mon, 6 Dec 2010 17:09:47 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Subject: [PATCH 1/3] KVM test: virtio_guest: Add lseek test Date: Mon, 6 Dec 2010 17:13:29 -0500 Message-Id: <1291673611-10617-1-git-send-email-lmr@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 06 Dec 2010 22:10:35 +0000 (UTC) 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])