libxml2
Checking out the libxml2 sources
In path/to/examples/libxml2, initialize the git submodule:
git submodule update --init repo
Create a Makefile
in libxml2/repo:
./autogen.sh
and optionally ./configure (autogen.sh currently runs this automatically,
so you're not required to).
Create a compile_commands.json
in libxml2/repo:
intercept-build make check
If your compile_commands.json enables optimizations(-O2) you will need to remove them so that unsupported compiler_builtins are less likely to be generated and leave you in an uncompilable state.
Run rm .libs/*.o here to get rid of gcc generated staticlibs or else you may see CRITICAL:root:error: some ELF objects were not compiled with clang: in the next step
Generate Rust Code
in libxml2:
./translate.py to translate all required c files (including tests) into the libxml2/repo/rust/src and libxml2/repo/rust/examples directories.
Fix Known Translation Issues
in libxml2:
./patch_translated_code.py to apply patches to some known issues in the generated code.
Run Libxml2 C Tests
Since each of these tests have their own main file, we decided to move them to the rust examples directory instead of trying to wrap them in the test framework.
You can run a test like so: cargo run --example EXAMPLE where EXAMPLE is one of the files in libxml2/repo/rust/examples, not including the file extension.
Outstanding Test Issues
Runnable
testReaderseems to be mostly working identically but with some slight differences. TrytestReader --valid test/japancrlf.xml. It produces an extra "Ns verBoom: Validation failed: no DTD found !, (null), (null)"
Working
runtestseems to be consistently successful nowtestRelaxseems to work equivalently with files as in CtestXPathseems to work equivalently with files as in Cxmllintseems to work equivalently with files as in CtestSAXprints out nothing on success, just like C versiontestModuleprints "Success!"testHTMLworks with input files fromtest/HTMLand produces same output as C versiontestRegexpworks with files fromtest/regexpand produces same output as C versiontestrecurseprints "Total 9 tests, no errors"testlimitsprints "Total 514 tests, no errors"- Note: text output seems noticeably slower than the C version
testThreadsprints nothing (but no longer prints parsing errors)testapiruns successfully and prints "Total: 1172 functions, 280928 tests, 0 errors"testC14Nprints parsed output when given a file to read fromtest/c14ntestSchemasno longer crashes when provided a file fromtest/schemas/*.xsdtestcharprints tests completedtestdictprints "dictionary tests succeeded 20000 strings"testAutomatatakes a file fromtest/automataand produces equivalent output to C runtestURIwaits on input from stdin, needs example input fromtest/URI. SeeMakefile.amandresult/URI/uri.datafor examples
Working cross-checks
testcharall cross-checks matchtestdictall cross-checks matchtestapiall cross-checks match (345 million)runtestall cross-checks matchtestlimitsall cross-checks match, but requires-fno-builtinas a compiler argumenttestSAXworkstestHTMLworkstestRegexpworkstestModulerequirestestdso.so, doesn't work yettestAutomataworkstestSchemasworks on all files fromtest/schemastestRelaxworks on all files fromtest/relaxngtestURIworkstestC14NworkstestXPathworks on files undertest/XPath/exprandtest/xmlidtestThreadsdeadlocks, still investigatingxmlllintdoes not compile