qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] runner: Expand the list of default test command


From: Maria Kustova
Subject: [Qemu-devel] [PATCH 1/2] runner: Expand the list of default test commands
Date: Tue, 19 Aug 2014 01:38:22 +0400

Additional commands were added to the default runner list to cover all qcow2
related code. This qcow2 specificity is selected to reduce number of
non-relevant tests. After implementation of a fuzzer for a new format the
default list should be updated.

Signed-off-by: Maria Kustova <address@hidden>
---
 tests/image-fuzzer/runner.py | 75 ++++++++++++++++++++++++++++++++------------
 1 file changed, 55 insertions(+), 20 deletions(-)

diff --git a/tests/image-fuzzer/runner.py b/tests/image-fuzzer/runner.py
index 2e1bd51..fd97c40 100755
--- a/tests/image-fuzzer/runner.py
+++ b/tests/image-fuzzer/runner.py
@@ -30,6 +30,9 @@ import getopt
 import StringIO
 import resource
 
+# All formats supported by the 'qemu-img create' command.
+WRITABLE_FORMATS = ['raw', 'vmdk', 'vdi', 'cow', 'qcow2', 'file', 'qed', 'vpc']
+
 try:
     import json
 except ImportError:
@@ -137,24 +140,57 @@ class TestEnv(object):
         self.qemu_img = os.environ.get('QEMU_IMG', 'qemu-img')\
                                   .strip().split(' ')
         self.qemu_io = os.environ.get('QEMU_IO', 'qemu-io').strip().split(' ')
-        self.commands = [['qemu-img', 'check', '-f', 'qcow2', '$test_img'],
-                         ['qemu-img', 'info', '-f', 'qcow2', '$test_img'],
-                         ['qemu-io', '$test_img', '-c', 'read $off $len'],
-                         ['qemu-io', '$test_img', '-c', 'write $off $len'],
-                         ['qemu-io', '$test_img', '-c',
-                          'aio_read $off $len'],
-                         ['qemu-io', '$test_img', '-c',
-                          'aio_write $off $len'],
-                         ['qemu-io', '$test_img', '-c', 'flush'],
-                         ['qemu-io', '$test_img', '-c',
-                          'discard $off $len'],
-                         ['qemu-io', '$test_img', '-c',
-                          'truncate $off']]
-        for fmt in ['raw', 'vmdk', 'vdi', 'cow', 'qcow2', 'file',
-                    'qed', 'vpc']:
+        strings = ['%s%p%x%d', '.1024d', '%.2049d', '%p%p%p%p', '%x%x%x%x',
+                   '%d%d%d%d', '%s%s%s%s', '%99999999999s', '%08x', '%%20d',
+                   '%%20n', '%%20x', '%%20s', '%s%s%s%s%s%s%s%s%s%s',
+                   '%p%p%p%p%p%p%p%p%p%p',
+                   '%#0123456x%08x%x%s%p%d%n%o%u%c%h%l%q%j%z%Z%t%i%e%g%f%a%C' +
+                   '%S%08x%%', '%s x 129', '%x x 257']
+        self.commands = [
+            ['qemu-img', 'check', '-f', 'qcow2', '$test_img'],
+            ['qemu-img', 'check', '-f', 'qcow2', '-r', 'leaks', '$test_img'],
+            ['qemu-img', 'check', '-f', 'qcow2', '-r', 'all', '$test_img'],
+            ['qemu-img', 'snapshot', '-c', 'new', '$test_img'],
+            ['qemu-img', 'info', '-f', 'qcow2', '$test_img'],
+            ['qemu-img', 'convert', '-c', '-f', 'qcow2', '-O', 'qcow2',
+             '$test_img', 'converted_image.qcow2'],
+            ['qemu-img', 'amend', '-o', 'compat=0.10', '-f', 'qcow2',
+             '$test_img'],
+            ['qemu-img', 'amend', '-o', 'lazy_refcounts=on', '-f', 'qcow2',
+             '$test_img'],
+            ['qemu-img', 'amend', '-o', 'lazy_refcounts=off', '-f', 'qcow2',
+             '$test_img'],
+            ['qemu-img', 'amend', '-o',
+             'backing_file=' + random.choice(strings), '-f', 'qcow2',
+             '$test_img'],
+            ['qemu-img', 'amend', '-o', 'backing_fmt=' + 
random.choice(strings),
+             '-f', 'qcow2', '$test_img'],
+            ['qemu-io', '$test_img', '-c', 'read $off $len'],
+            ['qemu-io', '$test_img', '-c', 'read -p $off $len'],
+            ['qemu-io', '$test_img', '-c', 'write $off $len'],
+            ['qemu-io', '$test_img', '-c', 'write -c $off $len'],
+            ['qemu-io', '$test_img', '-c', 'write -p $off $len'],
+            ['qemu-io', '$test_img', '-c', 'write -z $off $len'],
+            ['qemu-io', '$test_img', '-c', 'aio_read $off $len'],
+            ['qemu-io', '$test_img', '-c', 'aio_write $off $len'],
+            ['qemu-io', '$test_img', '-c', 'flush'],
+            ['qemu-io', '$test_img', '-c', 'discard $off $len'],
+            ['qemu-io', '$test_img', '-c', 'truncate $off'],
+            ['qemu-io', '$test_img', '-c', 'info'],
+            ['qemu-io', '$test_img', '-c', 'map']
+        ]
+
+        for fmt in WRITABLE_FORMATS:
+            cache_opt = random.choice([
+                [], ['-t', 'unsafe'],
+                ['-t', 'writethrough'],
+                ['-t', 'writeback'],
+                ['-t', 'none']
+            ])
+
             self.commands.append(
-                ['qemu-img', 'convert', '-f', 'qcow2', '-O', fmt,
-                 '$test_img', 'converted_image.' + fmt])
+                ['qemu-img', 'convert', '-f', 'qcow2', '-O', fmt] + cache_opt +
+                ['$test_img', 'converted_image.' + fmt])
 
         try:
             os.makedirs(self.current_dir)
@@ -177,9 +213,8 @@ class TestEnv(object):
         Format of a backing file is randomly chosen from all formats supported
         by 'qemu-img create'.
         """
-        # All formats supported by the 'qemu-img create' command.
-        backing_file_fmt = random.choice(['raw', 'vmdk', 'vdi', 'cow', 'qcow2',
-                                          'file', 'qed', 'vpc'])
+
+        backing_file_fmt = random.choice(WRITABLE_FORMATS)
         backing_file_name = 'backing_img.' + backing_file_fmt
         backing_file_size = random.randint(MIN_BACKING_FILE_SIZE,
                                            MAX_BACKING_FILE_SIZE) * (1 << 20)
-- 
1.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]