Checking out the libxml2 sources
path/to/examples/libxml2, initialize the git submodule:
git submodule update --init repo
Create a Makefile
autogen.sh currently runs this automatically,
so you're not required to).
Create a compile_commands.json
intercept-build make check
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.
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
./translate.py to translate all required c files (including tests) into the
Fix Known Translation Issues
./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
testReaderseems to be mostly working identically but with some slight differences. Try
testReader --valid test/japancrlf.xml. It produces an extra "Ns verBoom: Validation failed: no DTD found !, (null), (null)"
runtestseems to be consistently successful now
testRelaxseems to work equivalently with files as in C
testXPathseems to work equivalently with files as in C
xmllintseems to work equivalently with files as in C
testSAXprints out nothing on success, just like C version
testHTMLworks with input files from
test/HTMLand produces same output as C version
testRegexpworks with files from
test/regexpand produces same output as C version
testrecurseprints "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 from
testSchemasno longer crashes when provided a file from
testcharprints tests completed
testdictprints "dictionary tests succeeded 20000 strings"
testAutomatatakes a file from
test/automataand produces equivalent output to C run
testURIwaits on input from stdin, needs example input from
testcharall cross-checks match
testdictall cross-checks match
testapiall cross-checks match (345 million)
runtestall cross-checks match
testlimitsall cross-checks match, but requires
-fno-builtinas a compiler argument
testdso.so, doesn't work yet
testSchemasworks on all files from
testRelaxworks on all files from
testXPathworks on files under
testThreadsdeadlocks, still investigating
xmlllintdoes not compile