binman: Set up 'entry' to permit full test coverage
[oweals/u-boot.git] / tools / binman / binman.py
index 7fb67cb25f9c65dc58f7441ecb5a365bfef88d50..963d43a3761a6953a5116d7e6a1afd4919199550 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
 
 # Copyright (c) 2016 Google, Inc
 # Written by Simon Glass <sjg@chromium.org>
@@ -17,11 +17,14 @@ import unittest
 
 # Bring in the patman and dtoc libraries
 our_path = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.join(our_path, '../patman'))
-sys.path.append(os.path.join(our_path, '../dtoc'))
+for dirname in ['../patman', '../dtoc', '..']:
+    sys.path.insert(0, os.path.join(our_path, dirname))
+
+# Bring in the libfdt module
+sys.path.insert(0, 'scripts/dtc/pylibfdt')
 
 # Also allow entry-type modules to be brought in from the etype directory.
-sys.path.append(os.path.join(our_path, 'etype'))
+sys.path.insert(0, os.path.join(our_path, 'etype'))
 
 import cmdline
 import command
@@ -31,7 +34,7 @@ def RunTests():
     """Run the functional tests and any embedded doctests"""
     import entry_test
     import fdt_test
-    import func_test
+    import ftest
     import test
     import doctest
 
@@ -41,7 +44,7 @@ def RunTests():
         suite.run(result)
 
     sys.argv = [sys.argv[0]]
-    for module in (func_test.TestFunctional, fdt_test.TestFdt,
+    for module in (ftest.TestFunctional, fdt_test.TestFdt,
                    entry_test.TestEntry):
         suite = unittest.TestLoader().loadTestsFromTestCase(module)
         suite.run(result)
@@ -55,7 +58,7 @@ def RunTests():
 def RunTestCoverage():
     """Run the tests and check that we get 100% coverage"""
     # This uses the build output from sandbox_spl to get _libfdt.so
-    cmd = ('PYTHONPATH=%s/sandbox_spl/tools coverage run '
+    cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools coverage run '
             '--include "tools/binman/*.py" --omit "*test*,*binman.py" '
             'tools/binman/binman.py -t' % options.build_dir)
     os.system(cmd)