From patchwork Mon Dec 6 12:24:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?THVrw6HFoSBEb2t0b3I=?= X-Patchwork-Id: 377592 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 oB6COWqk026740 for ; Mon, 6 Dec 2010 12:24:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751023Ab0LFMYb (ORCPT ); Mon, 6 Dec 2010 07:24:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58360 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750888Ab0LFMYa (ORCPT ); Mon, 6 Dec 2010 07:24:30 -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 oB6COUhm017157 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Dec 2010 07:24:30 -0500 Received: from dhcp-27-189.brq.redhat.com (dhcp-27-189.brq.redhat.com [10.34.27.189]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oB6COPtH002648; Mon, 6 Dec 2010 07:24:28 -0500 From: Lukas Doktor To: autotest@test.kernel.org, kvm@vger.kernel.org, kvm-autotest@redhat.com, akong@redhat.com, lmr@redhat.com, ldoktor@redhat.com, jzupka@redhat.com Subject: [PATCH 1/2] * Add lseek test Date: Mon, 6 Dec 2010 13:24:20 +0100 Message-Id: <1291638261-19784-2-git-send-email-ldoktor@redhat.com> In-Reply-To: <1291638261-19784-1-git-send-email-ldoktor@redhat.com> References: <1291638261-19784-1-git-send-email-ldoktor@redhat.com> 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 12:24:32 +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 d8d2143..30bdcbf 100644 --- a/client/tests/kvm/tests/virtio_console.py +++ b/client/tests/kvm/tests/virtio_console.py @@ -671,6 +671,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): """ @@ -818,6 +828,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])