aboutsummaryrefslogtreecommitdiff
path: root/tools/dtoc/dtoc.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-06-18 22:09:06 -0600
committerSimon Glass <sjg@chromium.org>2017-07-11 10:08:20 -0600
commitc07919281c521c57d34eba8bfbac910c9632beda (patch)
tree114af204fea015c49875b1aa2ebd7a3a82ed677d /tools/dtoc/dtoc.py
parent2028cc59f7b904f8e91a99439aa630b20932baa5 (diff)
dtoc: Add tests
Add some tests of dtoc's functionality to make it easier to expand and enhance the tool. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/dtoc.py')
-rwxr-xr-xtools/dtoc/dtoc.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py
index 140a19e9d4..ce7bc054e5 100755
--- a/tools/dtoc/dtoc.py
+++ b/tools/dtoc/dtoc.py
@@ -29,6 +29,7 @@ see doc/driver-model/of-plat.txt
from optparse import OptionParser
import os
import sys
+import unittest
# Bring in the patman libraries
our_path = os.path.dirname(os.path.realpath(__file__))
@@ -36,9 +37,24 @@ sys.path.append(os.path.join(our_path, '../patman'))
import dtb_platdata
+def run_tests():
+ """Run all the test we have for dtoc"""
+ import test_dtoc
-if __name__ != "__main__":
- pass
+ result = unittest.TestResult()
+ sys.argv = [sys.argv[0]]
+ for module in (test_dtoc.TestDtoc,):
+ suite = unittest.TestLoader().loadTestsFromTestCase(module)
+ suite.run(result)
+
+ print result
+ for _, err in result.errors:
+ print err
+ for _, err in result.failures:
+ print err
+
+if __name__ != '__main__':
+ sys.exit(1)
parser = OptionParser()
parser.add_option('-d', '--dtb-file', action='store',
@@ -47,7 +63,14 @@ parser.add_option('--include-disabled', action='store_true',
help='Include disabled nodes')
parser.add_option('-o', '--output', action='store', default='-',
help='Select output filename')
+parser.add_option('-t', '--test', action='store_true', dest='test',
+ default=False, help='run tests')
(options, args) = parser.parse_args()
-dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled,
- options.output)
+# Run our meagre tests
+if options.test:
+ run_tests()
+
+else:
+ dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled,
+ options.output)