selftest: Specifically remove files generated by provision
authorAndrew Bartlett <abartlet@samba.org>
Fri, 31 May 2019 01:06:59 +0000 (13:06 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 7 Jun 2019 19:50:11 +0000 (19:50 +0000)
This allows the changes in 74d15c9bf76f0a2fb5fa7b7b1d80971d10c4fe45 to
be reverted, and aligns this test with others that use TestCaseInTempDir.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13978

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/tests/blackbox/downgradedatabase.py

index b0becacc068f8baad3253442722460f3e71fa966..a5e540c13541287f149752e6c6a9e8cd83432aa1 100644 (file)
@@ -19,6 +19,7 @@ from __future__ import print_function
 from samba.tests import BlackboxTestCase
 import os
 import ldb
+import shutil
 from subprocess import check_output
 from samba.samdb import SamDB
 
@@ -34,9 +35,6 @@ class DowngradeTestBase(BlackboxTestCase):
         if not hasattr(self, "backend"):
             self.fail("Subclass this class and set 'backend'")
 
-        # Don't assert on empty tempdir contents on tearDown
-        self.check_tempdir_empty = False
-
         prov_cmd = "samba-tool domain provision " +\
                    "--domain FOO --realm foo.example.com " +\
                    "--targetdir {self.tempdir} " +\
@@ -59,6 +57,16 @@ class DowngradeTestBase(BlackboxTestCase):
                     for p in partitions]
         self.dbs.append(self.sam_path)
 
+    def tearDown(self):
+        shutil.rmtree(os.path.join(self.tempdir, "private"))
+        shutil.rmtree(os.path.join(self.tempdir, "etc"))
+        shutil.rmtree(os.path.join(self.tempdir, "state"))
+        shutil.rmtree(os.path.join(self.tempdir, "bind-dns"))
+        shutil.rmtree(os.path.join(self.tempdir, "msg.lock"))
+        os.unlink(os.path.join(self.tempdir, "names.tdb"))
+        os.unlink(os.path.join(self.tempdir, "gencache.tdb"))
+        super(DowngradeTestBase, self).tearDown()
+
     # Parse out the comments above each record that ldbdump produces
     # containing pack format version and KV level key for each record.
     # Return all GUID keys and DN keys (without @attrs), and the set