libbtrfsutil: use local mkfs.btrfs for tests if it exists
authorOmar Sandoval <osandov@fb.com>
Thu, 29 Mar 2018 07:53:55 +0000 (00:53 -0700)
committerDavid Sterba <dsterba@suse.com>
Fri, 30 Mar 2018 20:54:41 +0000 (22:54 +0200)
The system might not have mkfs installed at all.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Makefile
libbtrfsutil/python/tests/__init__.py

index 8afc8f6..699f864 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -357,7 +357,7 @@ testsuite: btrfs-corrupt-block fssum
        $(Q)cd tests && ./export-testsuite.sh
 
 ifeq ($(PYTHON_BINDINGS),1)
-test-libbtrfsutil: libbtrfsutil_python
+test-libbtrfsutil: libbtrfsutil_python mkfs.btrfs
        $(Q)cd libbtrfsutil/python; \
                LD_LIBRARY_PATH=../.. $(PYTHON) -m unittest discover -v tests
 
index d2c6ff2..35550e0 100644 (file)
@@ -37,8 +37,12 @@ class BtrfsTestCase(unittest.TestCase):
             os.rmdir(self.mountpoint)
             raise e
 
+        if os.path.exists('../../mkfs.btrfs'):
+            mkfs = '../../mkfs.btrfs'
+        else:
+            mkfs = 'mkfs.btrfs'
         try:
-            subprocess.check_call(['mkfs.btrfs', '-q', self.image])
+            subprocess.check_call([mkfs, '-q', self.image])
             subprocess.check_call(['mount', '-o', 'loop', '--', self.image, self.mountpoint])
         except Exception as e:
             os.remove(self.image)