diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2016-08-17 14:31:25 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2016-08-22 16:43:26 +0000 |
commit | 60f9d69e016b11c468c98ea75ba0a60c44afbbc4 (patch) | |
tree | ecb49581a9e41a37943c22cd9ef3f63451b20ee7 /import-layers/yocto-poky/scripts/pybootchartgui/pybootchartgui/tests/process_tree_test.py | |
parent | e18c61205e0234b03697129c20cc69c9b3940efc (diff) | |
download | blackbird-openbmc-60f9d69e016b11c468c98ea75ba0a60c44afbbc4.tar.gz blackbird-openbmc-60f9d69e016b11c468c98ea75ba0a60c44afbbc4.zip |
yocto-poky: Move to import-layers subdir
We are going to import additional layers, so create a subdir to
hold all of the layers that we import with git-subtree.
Change-Id: I6f732153a22be8ca663035c518837e3cc5ec0799
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Diffstat (limited to 'import-layers/yocto-poky/scripts/pybootchartgui/pybootchartgui/tests/process_tree_test.py')
-rw-r--r-- | import-layers/yocto-poky/scripts/pybootchartgui/pybootchartgui/tests/process_tree_test.py | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/import-layers/yocto-poky/scripts/pybootchartgui/pybootchartgui/tests/process_tree_test.py b/import-layers/yocto-poky/scripts/pybootchartgui/pybootchartgui/tests/process_tree_test.py new file mode 100644 index 000000000..6f46a1c03 --- /dev/null +++ b/import-layers/yocto-poky/scripts/pybootchartgui/pybootchartgui/tests/process_tree_test.py @@ -0,0 +1,92 @@ +import sys +import os +import unittest + +sys.path.insert(0, os.getcwd()) + +import pybootchartgui.parsing as parsing +import pybootchartgui.process_tree as process_tree +import pybootchartgui.main as main + +if sys.version_info >= (3, 0): + long = int + +class TestProcessTree(unittest.TestCase): + + def setUp(self): + self.name = "Process tree unittest" + self.rootdir = os.path.join(os.path.dirname(sys.argv[0]), '../../examples/1/') + + parser = main._mk_options_parser() + options, args = parser.parse_args(['--q', self.rootdir]) + writer = main._mk_writer(options) + trace = parsing.Trace(writer, args, options) + + parsing.parse_file(writer, trace, self.mk_fname('proc_ps.log')) + trace.compile(writer) + self.processtree = process_tree.ProcessTree(writer, None, trace.ps_stats, \ + trace.ps_stats.sample_period, None, options.prune, None, None, False, for_testing = True) + + def mk_fname(self,f): + return os.path.join(self.rootdir, f) + + def flatten(self, process_tree): + flattened = [] + for p in process_tree: + flattened.append(p) + flattened.extend(self.flatten(p.child_list)) + return flattened + + def checkAgainstJavaExtract(self, filename, process_tree): + test_data = open(filename) + for expected, actual in zip(test_data, self.flatten(process_tree)): + tokens = expected.split('\t') + self.assertEqual(int(tokens[0]), actual.pid // 1000) + self.assertEqual(tokens[1], actual.cmd) + self.assertEqual(long(tokens[2]), 10 * actual.start_time) + self.assert_(long(tokens[3]) - 10 * actual.duration < 5, "duration") + self.assertEqual(int(tokens[4]), len(actual.child_list)) + self.assertEqual(int(tokens[5]), len(actual.samples)) + test_data.close() + + def testBuild(self): + process_tree = self.processtree.process_tree + self.checkAgainstJavaExtract(self.mk_fname('extract.processtree.1.log'), process_tree) + + def testMergeLogger(self): + self.processtree.merge_logger(self.processtree.process_tree, 'bootchartd', None, False) + process_tree = self.processtree.process_tree + self.checkAgainstJavaExtract(self.mk_fname('extract.processtree.2.log'), process_tree) + + def testPrune(self): + self.processtree.merge_logger(self.processtree.process_tree, 'bootchartd', None, False) + self.processtree.prune(self.processtree.process_tree, None) + process_tree = self.processtree.process_tree + self.checkAgainstJavaExtract(self.mk_fname('extract.processtree.3b.log'), process_tree) + + def testMergeExploders(self): + self.processtree.merge_logger(self.processtree.process_tree, 'bootchartd', None, False) + self.processtree.prune(self.processtree.process_tree, None) + self.processtree.merge_exploders(self.processtree.process_tree, set(['hwup'])) + process_tree = self.processtree.process_tree + self.checkAgainstJavaExtract(self.mk_fname('extract.processtree.3c.log'), process_tree) + + def testMergeSiblings(self): + self.processtree.merge_logger(self.processtree.process_tree, 'bootchartd', None, False) + self.processtree.prune(self.processtree.process_tree, None) + self.processtree.merge_exploders(self.processtree.process_tree, set(['hwup'])) + self.processtree.merge_siblings(self.processtree.process_tree) + process_tree = self.processtree.process_tree + self.checkAgainstJavaExtract(self.mk_fname('extract.processtree.3d.log'), process_tree) + + def testMergeRuns(self): + self.processtree.merge_logger(self.processtree.process_tree, 'bootchartd', None, False) + self.processtree.prune(self.processtree.process_tree, None) + self.processtree.merge_exploders(self.processtree.process_tree, set(['hwup'])) + self.processtree.merge_siblings(self.processtree.process_tree) + self.processtree.merge_runs(self.processtree.process_tree) + process_tree = self.processtree.process_tree + self.checkAgainstJavaExtract(self.mk_fname('extract.processtree.3e.log'), process_tree) + +if __name__ == '__main__': + unittest.main() |