test_api_base: run the test for more than one file
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 26 Nov 2012 11:41:39 +0000 (13:41 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 26 Nov 2012 12:05:45 +0000 (14:05 +0200)
Instead of running the test of one file of 64MiB, run it 3 times for files of
the following sizes:

1. 8MiB
2. 8MiB + 1 byte
3. 8MiB - 1 byte

This gives better coverage.

Change-Id: I4ea4f5f92dc32c1d8fbf9ea0173b7c39a294968d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
tests/test_api_base.py

index d8ea72b..7aab982 100644 (file)
@@ -125,10 +125,18 @@ class TestCreateCopy(unittest.TestCase):
         # Create and open a temporary file for the image
         f_image = tempfile.NamedTemporaryFile("wb+")
 
-        # Create a 64MiB random sparse file
-        test_helpers.create_random_sparse_file(f_image, 64 * 1024 * 1024)
+        # Create a 8MiB random sparse file
+        size = 8 * 1024 * 1024
+        test_helpers.create_random_sparse_file(f_image, size)
 
         # Execute the test on this file
         self._do_test(f_image)
 
+        # Do the same for random sparse files of size 8MiB +/- 1 byte
+        test_helpers.create_random_sparse_file(f_image, size + 1)
+        self._do_test(f_image)
+
+        test_helpers.create_random_sparse_file(f_image, size - 1)
+        self._do_test(f_image)
+
         f_image.close()