test_api_base: fix the test
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Fri, 23 Nov 2012 11:26:51 +0000 (13:26 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Fri, 23 Nov 2012 12:12:20 +0000 (14:12 +0200)
The test apparently was half-broken because:

1. It did not check results of 'filecmp'.
2. It did not seek the bmap file descriptor so the bmap comparison did not
   work.

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

index 09f6520..6976ff1 100644 (file)
@@ -136,7 +136,7 @@ class TestCreateCopy(unittest.TestCase):
         writer.copy(False, True)
 
         # Compare the original file and the copy are identical
-        filecmp.cmp(self._image_path, self._copy_path, False)
+        assert filecmp.cmp(self._image_path, self._copy_path, False)
 
         #
         # Pass 2: same as pass 1, but use file objects instead of paths
@@ -148,22 +148,24 @@ class TestCreateCopy(unittest.TestCase):
         writer = BmapCopy.BmapCopy(self._f_image, self._f_copy, self._f_bmap2)
         writer.copy(False, True)
 
-        filecmp.cmp(self._image_path, self._copy_path, False)
+        assert filecmp.cmp(self._image_path, self._copy_path, False)
 
         # Make sure the bmap files generated at pass 1 and pass 2 are identical
-        filecmp.cmp(self._bmap1_path, self._bmap2_path, False)
+        assert filecmp.cmp(self._bmap1_path, self._bmap2_path, False)
 
         #
         # Pass 3: repeat pass 2 to make sure the same 'BmapCreate' and
         # 'BmapCopy' objects can be used more than once.
         #
+        self._f_bmap2.seek(0)
         creator.generate()
+        self._f_bmap2.seek(0)
         creator.generate()
         writer.copy(True, False)
         writer.copy(False, True)
         writer.sync()
-        filecmp.cmp(self._image_path, self._copy_path, False)
-        filecmp.cmp(self._bmap1_path, self._bmap2_path, False)
+        assert filecmp.cmp(self._image_path, self._copy_path, False)
+        assert filecmp.cmp(self._bmap1_path, self._bmap2_path, False)
 
         #
         # Pass 4: copy the sparse file without bmap and make sure it is
@@ -171,8 +173,8 @@ class TestCreateCopy(unittest.TestCase):
         #
         writer = BmapCopy.BmapCopy(self._f_image, self._copy_path)
         writer.copy(True, True)
-        filecmp.cmp(self._image_path, self._copy_path, False)
+        assert filecmp.cmp(self._image_path, self._copy_path, False)
 
         writer = BmapCopy.BmapCopy(self._f_image, self._f_copy)
         writer.copy(False, True)
-        filecmp.cmp(self._image_path, self._copy_path, False)
+        assert filecmp.cmp(self._image_path, self._copy_path, False)