def test_SADParser_affinityconfig(self):
sad = parsers.SADParser.parse("sdr/parser_tests/affinity.sad.xml")
self.assertEqual(sad.get_id(), "device_requires_multicolor")
self.assertEqual(sad.get_name(), "device_requires_multicolor")
self.assertEqual(len(sad.componentfiles.get_componentfile()), 1)
self.assertEqual(len(sad.partitioning.get_componentplacement()), 1)
comp_place=sad.partitioning.get_componentplacement()[0]
comp_in=comp_place.get_componentinstantiation()[0]
self.assertEqual(comp_place.componentfileref.refid, "SimpleComponent_SPD_1")
self.assertEqual(comp_in.id_, "SimpleComponent_Red")
self.assertEqual(comp_in.get_usagename(), "SimpleComponent_Red")
self.assertEqual(comp_in.loggingconfig.level, "ERROR")
self.assertEqual(comp_in.loggingconfig.value, "path/to/my/log/file")
self.assertEqual(len(comp_in.affinity.get_simpleref()),2)
self.assertEqual(comp_in.affinity.get_simpleref()[0].refid, "affinity::exec_directive_class")
self.assertEqual(comp_in.affinity.get_simpleref()[0].value, "socket")
self.assertEqual(comp_in.affinity.get_simpleref()[1].refid, "affinity::exec_directive_value")
self.assertEqual(comp_in.affinity.get_simpleref()[1].value, "0")
# Verify that we can write the output and still be DTD valid
tmpfile = tempfile.mktemp()
try:
tmp = open(tmpfile, "w")
sad.export(tmp, 0)
tmp.close()
status = self._xmllint(tmpfile, "SAD")
self.assertEqual(status, 0, "Python parser did not emit DTD compliant XML")
finally:
try:
os.remove(tmpfile)
except OSError:
pass
test_07_PythonParsers.py 文件源码
python
阅读 36
收藏 0
点赞 0
评论 0
评论列表
文章目录