From Mageia wiki
Packages to test
- libxml2-utils-2.7.8-9.3.mga1
- lib(64)xml2_2-2.7.8-9.3.mga1
- libxml2-python-2.7.8-9.3.mga1
- lib(64)xml2-devel-2.7.8-9.3.mga1
SRPM: libxml2-2.7.8-9.3.mga1.src.rpm
To test libxml2-python you need some data and some python. The script previously given actually used expat, not libxml2, and has been transferred to a new Wiki page for testing expat. This script uses libxml2.
Save the follow python as testxml.py
import libxml2 def getStatus(case): prop = case.properties props={} props['name']="" props['classname']="" props['status']="" while prop: props[prop.name]=prop.content prop=prop.next if props['name'] == 'VHDL_BUILD_Passthrough' and props['classname'] == 'TestOne': return props['status'] return None x = libxml2.parseFile("testdata.xml") allcases=[c for c in x.children if c.name == 'testcase'] cases = [c for c in allcases if getStatus(c) != None] print(getStatus(cases[0]))
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 testxml.py Tested OK
For testing libxml2-utils..
$ xmllint --auto <?xml version="1.0"?> <info>abc</info> $ xmlcatalog --create <?xml version="1.0"?> <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"/>
Chromium-browser uses libxml2 and running under strace will show it is loading it. Viewing some xml files you can find online should be enough to show it is working.
$ strace -o strace.out chromium-browser $ grep xml strace.out open("/usr/lib64/libxml2.so.2", O_RDONLY) = 3 $ rpm -qif /usr/lib64/libxml2.so.2 Name : lib64xml2_2 Relocations: (not relocatable) Version : 2.7.8 Vendor: Mageia.Org Release : 9.3.mga1 Build Date: Thu 15 Dec 2011 20:20:12 GMT Install Date: Mon 09 Jan 2012 12:09:39 GMT Build Host: jonund Group : System/Libraries Source RPM: libxml2-2.7.8-9.3.mga1.src.rpm