qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Maria Kustova <maxa@catit.be>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com,
	Maria Kustova <maria.k@catit.be>,
	stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 2/4] runner: Make a copy of a test image for destructive test commands
Date: Thu, 24 Jul 2014 16:32:27 +0400	[thread overview]
Message-ID: <b41ee554fa72a6fd52d52fbd17b82ee3bdeeb58d.1406204552.git.maria.k@catit.be> (raw)
In-Reply-To: <cover.1406204552.git.maria.k@catit.be>
In-Reply-To: <cover.1406204552.git.maria.k@catit.be>

Signed-off-by: Maria Kustova <maria.k@catit.be>
---
 tests/image-fuzzer/runner/runner.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tests/image-fuzzer/runner/runner.py b/tests/image-fuzzer/runner/runner.py
index 3e9e65d..6ec40a4 100755
--- a/tests/image-fuzzer/runner/runner.py
+++ b/tests/image-fuzzer/runner/runner.py
@@ -21,8 +21,8 @@
 import sys, os, signal
 import subprocess
 import random
+import shutil
 from itertools import count
-from shutil import rmtree
 import getopt
 try:
     import json
@@ -107,7 +107,9 @@ class TestEnv(object):
                           'discard $off $len'],
                          ['qemu-io', '$test_img', '-c',
                           'truncate $off']]
-        for fmt in ['raw', 'vmdk', 'vdi', 'cow', 'qcow2', 'file',
+        # VMDK format is skipped because such conversion requires
+        # a pregenerated vmdk file
+        for fmt in ['raw', 'vdi', 'cow', 'qcow2', 'file',
                     'qed', 'vpc']:
             self.commands.append(
                          ['qemu-img', 'convert', '-f', 'qcow2', '-O', fmt,
@@ -146,7 +148,7 @@ class TestEnv(object):
                                           'file', 'qed', 'vpc'])
         backing_file_name = 'backing_img.' + backing_file_fmt
         # Size of the backing file varies from 1 to 10 MB
-        backing_file_size = random.randint(1, 10)*(1 << 20)
+        backing_file_size = random.randint(1, 10) * (1 << 20)
         cmd = self.qemu_img + ['create', '-f', backing_file_fmt,
                                backing_file_name, str(backing_file_size)]
         devnull = open('/dev/null', 'r+')
@@ -170,17 +172,18 @@ class TestEnv(object):
             commands = input_commands
         os.chdir(self.current_dir)
         backing_file_name, backing_file_fmt = self._create_backing_file()
-        img_size = image_generator.create_image('test_image',
+        img_size = image_generator.create_image('test.img',
                                                 backing_file_name,
                                                 backing_file_fmt,
                                                 fuzz_config)
         for item in commands:
+            shutil.copy('test.img', 'copy.img')
             start = random.randint(0, img_size)
             end = random.randint(start, img_size)
             current_cmd = list(self.__dict__[item[0].replace('-', '_')])
             # Replace all placeholders with their real values
             for v in item[1:]:
-                c = v.replace('$test_img', 'test_image').\
+                c = v.replace('$test_img', 'copy.img').\
                     replace('$off', str(start)).\
                     replace('$len', str(end - start))
                 current_cmd.append(c)
@@ -208,6 +211,7 @@ class TestEnv(object):
                     multilog(test_summary + "PASS: Application exited with" + \
                              " the code '%d'\n\n" % retcode, sys.stdout,
                              self.log, self.parent_log)
+            os.remove('copy.img')
 
     def finish(self):
         """ Restore environment after a test execution. Remove folders of
@@ -217,7 +221,7 @@ class TestEnv(object):
         self.parent_log.close()
         os.chdir(self.init_path)
         if self.cleanup and not self.failed:
-            rmtree(self.current_dir)
+            shutil.rmtree(self.current_dir)
 
 if __name__ == '__main__':
 
-- 
1.9.3

  parent reply	other threads:[~2014-07-24 12:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-24 12:32 [Qemu-devel] [PATCH 0/4] image-fuzzer: Support L1/L2 tables in the qcow2 image generator Maria Kustova
2014-07-24 12:32 ` [Qemu-devel] [PATCH 1/4] docs: Expand the list of supported image elements with L1/L2 tables Maria Kustova
2014-07-30  8:12   ` Fam Zheng
2014-07-24 12:32 ` Maria Kustova [this message]
2014-07-30  8:49   ` [Qemu-devel] [PATCH 2/4] runner: Make a copy of a test image for destructive test commands Fam Zheng
2014-07-24 12:32 ` [Qemu-devel] [PATCH 3/4] fuzz: Add fuzzing functions for L1/L2 table entries Maria Kustova
2014-07-24 12:32 ` [Qemu-devel] [PATCH 4/4] layout: Add generators of L1/L2 tables Maria Kustova
2014-08-01  5:34   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b41ee554fa72a6fd52d52fbd17b82ee3bdeeb58d.1406204552.git.maria.k@catit.be \
    --to=maxa@catit.be \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=maria.k@catit.be \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).