aboutsummaryrefslogtreecommitdiff
path: root/tools/dtoc/test_fdt.py
diff options
context:
space:
mode:
authorSimon Glass2019-07-20 12:23:49 -0600
committerSimon Glass2019-07-29 09:38:06 -0600
commita004f29464d14f3535ed8db22e5dfed02c8fc9d8 (patch)
tree0451f714cdca079bad5d1d99e08d26b32b45fe80 /tools/dtoc/test_fdt.py
parent02fd463cfeeb3ec693539885dbc58e0439d3b4de (diff)
binman: Tidy up _SetupDtb() to use its own temporary file
At present EnsureCompiled() uses an file from the 'output' directory (in the tools module) when compiling the device tree. This is fine in most cases, allowing useful inspection of the output files from binman. However in functional tests, _SetupDtb() creates an output directory and immediately removes it afterwards. This serves no benefit and just confuses things, since the 'official' output directory is supposed to be created and destroyed in control.Binman(). Add a new parameter for the optional temporary directory to use, and use a separate temporary directory in _SetupDtb(). Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/test_fdt.py')
-rwxr-xr-xtools/dtoc/test_fdt.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index ed2d982a8fc..16a4430892e 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -9,7 +9,9 @@ from __future__ import print_function
from optparse import OptionParser
import glob
import os
+import shutil
import sys
+import tempfile
import unittest
# Bring in the patman libraries
@@ -540,10 +542,23 @@ class TestFdtUtil(unittest.TestCase):
self.assertEqual(0x12345678, fdt_util.fdt_cells_to_cpu(val, 1))
def testEnsureCompiled(self):
- """Test a degenerate case of this function"""
+ """Test a degenerate case of this function (file already compiled)"""
dtb = fdt_util.EnsureCompiled('tools/dtoc/dtoc_test_simple.dts')
self.assertEqual(dtb, fdt_util.EnsureCompiled(dtb))
+ def testEnsureCompiledTmpdir(self):
+ """Test providing a temporary directory"""
+ try:
+ old_outdir = tools.outdir
+ tools.outdir= None
+ tmpdir = tempfile.mkdtemp(prefix='test_fdt.')
+ dtb = fdt_util.EnsureCompiled('tools/dtoc/dtoc_test_simple.dts',
+ tmpdir)
+ self.assertEqual(tmpdir, os.path.dirname(dtb))
+ shutil.rmtree(tmpdir)
+ finally:
+ tools.outdir= old_outdir
+
def RunTestCoverage():
"""Run the tests and check that we get 100% coverage"""