freebsd / kyua

Port/Package build and test system
https://github.com/freebsd/kyua/wiki
BSD 3-Clause "New" or "Revised" License
149 stars 42 forks source link

Kyua doesn't escape NULs in stdout in the jenkins.xml output #166

Open asomers opened 7 years ago

asomers commented 7 years ago

Issue #136 escaped a bunch of non-printable characters that could cause a junit.xml file to not be well-formed. But it didn't escape NUL. A single test that prints a NUL to stdout will screw up the entire junit.xml file. Here's an example:

Kyuafile:

syntax(2)
test_suite("FreeBSD")
atf_test_program{name="nul_test", }

nul_test

#! /usr/libexec/atf-sh
atf_test_case nul
nul_body()
{
        dd if=/dev/zero bs=1 count=1
        true
}
atf_init_test_cases()
{
        atf_add_test_case nul
}
$ kyua test
nul_test:nul  ->  passed  [0.058s]

Results file id is tmp.20170213-175011-880144
Results saved to /usr/home/alans/.kyua/store/results.tmp.20170213-175011-880144.db

1/1 passed (0 failed)
$ kyua report-junit --output=/tmp/junit.xml
$ xmlwf junit.xml 
junit.xml:28:12: not well-formed (invalid token)
brooksdavis commented 7 years ago

I ended up working around this in our test infrastructure (where I suspect a hardware or pmap bug due to the symptom being a full page of 0s in a long output) by running the junit file though vis -os.