From Mageia wiki
Packages to test
- expat
- lib[64]expat1
This script existed previously as a test for libxml2, but turned out to invoke 'expat'. To test expat you need some data and some python.
Save the follow python as testexpat.py
import xml.etree.ElementTree
x = xml.etree.ElementTree.ElementTree(file='testdata.xml')
allcases = x.findall(".//testcase")
cases = [c for c in allcases if c.get('classname') == 'TestOne' and
c.get('name') == 'VHDL_BUILD_Passthrough']
print(cases[0].attrib['status'])
Save the following xml data as testdata.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="10" failures="0" disabled="0" errors="0" time="0.001" name="AllTests">
<testsuite name="TestOne" tests="5" failures="0" disabled="0" errors="0" time="0.001">
<testcase name="DefaultConstructor" status="run" time="0" classname="TestOne" />
<testcase name="DefaultDestructor" status="run" time="0" classname="TestOne" />
<testcase name="VHDL_EMIT_Passthrough" status="run" time="0" classname="TestOne" />
<testcase name="VHDL_BUILD_Passthrough" status="Tested OK" time="0" classname="TestOne" />
<testcase name="VHDL_SIMULATE_Passthrough" status="run" time="0.001" classname="TestOne" />
</testsuite>
</testsuites>
Usage & expected output..
$ python testexpat.py Tested OK
A stand-alone test can use: xmlwf - Determines if an XML document is well-formed. If all is well, no output.
$ xmlwf /etc/xml/catalog $ xmlwf /etc/passwd /etc/passwd:1:16: not well-formed (invalid token)