Skip to contentSkip to conversation

virtio_console: add lseek test

PATCH New Lukas Doktor 1 participant 3 messages Dec 6, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio_console: add lseek test

Hello,

The first patch adds an lseek test. The second one is just a mirror corrections of critical flags for some of the smoke_test subtests.

The lseek test do what is expected. The result of lseek on virtconsole/virtserialport should be -ESPIPE or err 29 in python.

Regards,
Lukáš

#1 lore raw

PATCH 1/2 * Add lseek test

---
 client/tests/kvm/scripts/virtio_guest.py |   23 +++++++++++++++++++++++
 client/tests/kvm/tests/virtio_console.py |   11 +++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
client/tests/kvm/scripts/virtio_guest.py +23 -0
index b039ec9..bc86624 100755
@@ -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
client/tests/kvm/tests/virtio_console.py +11 -0
index d8d2143..30bdcbf 100644
@@ -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])
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 2/2 FIX tbasic_loopback execution FIX critical tests; multioupen is not critical; basic_loopback is critical test

In reply to Lukas Doktor
---
 client/tests/kvm/tests/virtio_console.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
client/tests/kvm/tests/virtio_console.py +2 -2
index 30bdcbf..144aca3 100644
@@ -826,13 +826,13 @@ def run_virtio_console(test, params, env):
 
             test.do_test(topen, [vm, send_pt] , True)
             test.do_test(tclose, [vm, send_pt], True)
-            test.do_test(tmulti_open, [vm, send_pt], True)
+            test.do_test(tmulti_open, [vm, send_pt])
             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])
-            test.do_test(tbasic_loopback, [vm, send_pt, recv_pt], data)
+            test.do_test(tbasic_loopback, [vm, send_pt, recv_pt, data], True)
 
 
 
Signature · 1 line
1.7.2.3