binman: Fix up removal of temporary directories
authorSimon Glass <sjg@chromium.org>
Tue, 2 Oct 2018 03:12:41 +0000 (21:12 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 8 Oct 2018 13:34:34 +0000 (07:34 -0600)
At present 'make check' leaves some temporary directories around. Part of
this is because we call tools.PrepareOutputDir() twice in some cases,
without calling tools.FinaliseOutputDir() in between.

Fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/elf_test.py
tools/binman/entry_test.py
tools/binman/fdt_test.py
tools/binman/ftest.py
tools/dtoc/test_fdt.py

index c16f71401d1c92be88e0d53979e5b2ba16b1fffc..b68530c19ba6e6c724bed6d970a5dfcc203049d3 100644 (file)
@@ -10,6 +10,7 @@ import unittest
 
 import elf
 import test_util
+import tools
 
 binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
 
@@ -46,6 +47,10 @@ class FakeSection:
 
 
 class TestElf(unittest.TestCase):
+    @classmethod
+    def setUpClass(self):
+        tools.SetInputDirs(['.'])
+
     def testAllSymbols(self):
         """Test that we can obtain a symbol from the ELF file"""
         fname = os.path.join(binman_dir, 'test', 'u_boot_ucode_ptr')
index 69d85b4cedb13b23c64519a8e619e08cc51d0dbb..a8bc938f9e9c54ec66d86ddeb902f22c960faccb 100644 (file)
@@ -14,9 +14,14 @@ import fdt_util
 import tools
 
 class TestEntry(unittest.TestCase):
+    def setUp(self):
+        tools.PrepareOutputDir(None)
+
+    def tearDown(self):
+        tools.FinaliseOutputDir()
+
     def GetNode(self):
         binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
-        tools.PrepareOutputDir(None)
         fname = fdt_util.EnsureCompiled(
             os.path.join(binman_dir,('test/05_simple.dts')))
         dtb = fdt.FdtScan(fname)
@@ -35,7 +40,6 @@ class TestEntry(unittest.TestCase):
         global entry
         reload(entry)
         entry.Entry.Create(None, self.GetNode(), 'u-boot-spl')
-        tools._RemoveOutputDir()
         del entry
 
     def testEntryContents(self):
index 8ea098f38aec7d630b9c9a45495efc9fd5e1fc88..b9167012d25d96ee1e1a31b9c6f404469798eadc 100644 (file)
@@ -21,6 +21,10 @@ class TestFdt(unittest.TestCase):
         self._indir = tempfile.mkdtemp(prefix='binmant.')
         tools.PrepareOutputDir(self._indir, True)
 
+    @classmethod
+    def tearDownClass(self):
+        tools._FinaliseForTest()
+
     def TestFile(self, fname):
         return os.path.join(self._binman_dir, 'test', fname)
 
index 57725c928e70afda6f4b3cb6cad19cefb20a5753..9ef259a699b0bc66333e3dae7690af848576cc45 100644 (file)
@@ -115,7 +115,6 @@ class TestFunctional(unittest.TestCase):
         TestFunctional._MakeInputFile('ecrw.bin', CROS_EC_RW_DATA)
         TestFunctional._MakeInputDir('devkeys')
         TestFunctional._MakeInputFile('bmpblk.bin', BMPBLK_DATA)
-        self._output_setup = False
 
         # ELF file with a '_dt_ucode_base_size' symbol
         with open(self.TestFile('u_boot_ucode_ptr')) as fd:
@@ -230,14 +229,13 @@ class TestFunctional(unittest.TestCase):
         Returns:
             Contents of device-tree binary
         """
-        if not self._output_setup:
-            tools.PrepareOutputDir(self._indir, True)
-            self._output_setup = True
+        tools.PrepareOutputDir(None)
         dtb = fdt_util.EnsureCompiled(self.TestFile(fname))
         with open(dtb) as fd:
             data = fd.read()
             TestFunctional._MakeInputFile(outfile, data)
-            return data
+        tools.FinaliseOutputDir()
+        return data
 
     def _GetDtbContentsForSplTpl(self, dtb_data, name):
         """Create a version of the main DTB for SPL or SPL
index d2597020500c7667bdab888efb890b31dd4f39fc..2e6febe8f380285da6ca9c01204a1bf49a23be19 100755 (executable)
@@ -60,7 +60,7 @@ class TestFdt(unittest.TestCase):
 
     @classmethod
     def tearDownClass(cls):
-        tools._FinaliseForTest()
+        tools.FinaliseOutputDir()
 
     def setUp(self):
         self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
@@ -128,7 +128,7 @@ class TestNode(unittest.TestCase):
 
     @classmethod
     def tearDownClass(cls):
-        tools._FinaliseForTest()
+        tools.FinaliseOutputDir()
 
     def setUp(self):
         self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
@@ -209,7 +209,7 @@ class TestProp(unittest.TestCase):
 
     @classmethod
     def tearDownClass(cls):
-        tools._FinaliseForTest()
+        tools.FinaliseOutputDir()
 
     def setUp(self):
         self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
@@ -427,6 +427,10 @@ class TestFdtUtil(unittest.TestCase):
     def setUpClass(cls):
         tools.PrepareOutputDir(None)
 
+    @classmethod
+    def tearDownClass(cls):
+        tools.FinaliseOutputDir()
+
     def setUp(self):
         self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
         self.node = self.dtb.GetNode('/spl-test')