CI: Fixes for tools/tests and junit and other
cover CI: Fixes for tools/tests and junit and other
From: Anthony PERARD <[email protected]>
Patch series available in this git branch:
https://xenbits.xenproject.org/git-http/people/aperard/xen-unstable.git br.ci-tools-tests-junit-fixes-v1
All the *-tools-tests-* are currently only checking automatically if the machine as booted. The only way to find out if one of the tools/tests failed is to read the console output by hand.
Also, tests-rangeset always return success even if there's a failure.
Fix all that, and add some improvement, and add SELECTED_JOBS_ONLY to analyze.yaml
How it looks:
success:
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1850830262/test_report failure: https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1850830637/test_report
Cheers,
Anthony PERARD (9):
CI: Add SELECTED_JOBS_ONLY to analyze.yaml tools/tests: Fix return value of test-rangeset
CI: Fix status check for tools/tests
CI: Ignore run-tools-test return value
CI: Have the gitlab job fail on tools/tests failure
CI: Upload junit result as artefact
CI: Use CDATA avoid the need to escape tests outputs
CI: Workaround extra content in junit
CI: Add timing to junit
automation/gitlab-ci/analyze.yaml | 3 +++ automation/gitlab-ci/test.yaml | 1 + automation/scripts/qubes-x86-64.sh | 18 ++++++++++++++++-- automation/scripts/run-tools-tests | 11 +++++++---- tools/tests/rangeset/test-rangeset.c | 2 +- 5 files changed, 28 insertions(+), 7 deletions(-)
Signature · 1 line
Anthony PERARD
PATCH 1/9 CI: Add SELECTED_JOBS_ONLY to analyze.yaml
From: Anthony PERARD <[email protected]>
--- automation/gitlab-ci/analyze.yaml | 3 +++ 1 file changed, 3 insertions(+)
automation/gitlab-ci/analyze.yaml +3 -0
@@ -29,6 +29,9 @@ rules: - if: $CI_PIPELINE_SOURCE == "schedule" when: never + - if: $SELECTED_JOBS_ONLY && $CI_JOB_NAME =~ $SELECTED_JOBS_ONLY + - if: $SELECTED_JOBS_ONLY + when: never - if: $WTOKEN && $CI_PROJECT_PATH =~ /^xen-project\/people\/.*$/ when: manual allow_failure: true
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 1/9] CI: Add SELECTED_JOBS_ONLY to analyze.yaml
Quoted 3 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Signed-off-by Anthony PERARD <[email protected]>
Stefano Stabellini
Acked-byRe: [XEN PATCH 1/9] CI: Add SELECTED_JOBS_ONLY to analyze.yaml
Quoted 6 lines · Andrew Cooper
Quoted 3 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Signed-off-by Anthony PERARD <[email protected]>Acked-by Andrew Cooper <[email protected]>
PATCH 2/9 tools/tests: Fix return value of test-rangeset
In reply to Anthony PERARDFrom: Anthony PERARD <[email protected]>
Otherwise, failed tests are ignored by automated test.
--- tools/tests/rangeset/test-rangeset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tests/rangeset/test-rangeset.c +1 -1
@@ -215,7 +215,7 @@ int main(int argc, char **argv) } } -return 0 ; +return ret_code; }/*
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 2/9] tools/tests: Fix return value of test-rangeset
Quoted 3 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Otherwise, failed tests are ignored by automated test.
Fixes 7bf777b42cad
Quoted 1 line
Signed-off-by Anthony PERARD <[email protected]>
PATCH 3/9 CI: Fix status check for tools/tests
In reply to Anthony PERARDFrom: Anthony PERARD <[email protected]>
Without "pipefail", $? have the exit value of tee, which should always be 0. But instead of using "pipefail", do collect the value of from the test with $PIPESTATUS.
---
Notes:
Without the next patch "CI: Ignore run-tools-test return value", this just mean that if one test fail, the script qubes-x86-64.sh will detect a ERROR-Timeout because the expected string is never printed.
automation/scripts/run-tools-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
automation/scripts/run-tools-tests +1 -1
@@ -20,7 +20,7 @@ for f in "$1"/*; do echo "Running $f" printf ' <testcase name="%s">\n' "$f" >> "$xml_out" "$f" 2>&1 | tee /tmp/out - ret=$? + ret=${PIPESTATUS[0]} if [ "$ret" -ne 0 ]; then echo "FAILED: $f" failed+=" $f"
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 3/9] CI: Fix status check for tools/tests
Quoted 7 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Without "pipefail", $? have the exit value of
tee, which should always be 0. But instead of using "pipefail", do collect the value of from the test with $PIPESTATUS.Signed-off-by Anthony PERARD <[email protected]>
Stefano Stabellini
Acked-byRe: [XEN PATCH 3/9] CI: Fix status check for tools/tests
Quoted 10 lines · Andrew Cooper
Quoted 7 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Without "pipefail", $? have the exit value of
tee, which should always be 0. But instead of using "pipefail", do collect the value of from the test with $PIPESTATUS.Signed-off-by Anthony PERARD <[email protected]>Reviewed-by Andrew Cooper <[email protected]>
PATCH 4/9 CI: Ignore run-tools-test return value
In reply to Anthony PERARDFrom: Anthony PERARD <[email protected]>
The main script expect to find the string "$passed" or it just timeout. Then, it doesn't try to download the junit file. So ignore the return value of run-tools-test for now.
This mean the job will not fail, but at least we should have the junit files with the error messages.
---
Notes:
On failure from a tests after this patch, the gitlab job succeed. But the junit file is collected.
automation/scripts/qubes-x86-64.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
automation/scripts/qubes-x86-64.sh +3 -2
@@ -135,10 +135,11 @@ done ### tests: tools-tests-pv, tools-tests-pvh "tools-tests-pv"|"tools-tests-pvh") retrieve_xml=1 - passed="test passed" + passed="run-tools-test over" domU_check="" dom0_check=" -/root/run-tools-tests /usr/lib/xen/tests /tmp/tests-junit.xml && echo \"${passed}\" +/root/run-tools-tests /usr/lib/xen/tests /tmp/tests-junit.xml ||: +echo \"${passed}\" nc -l -p 8080 < /tmp/tests-junit.xml >/dev/null & " if [ "${test_variant}" = "tools-tests-pvh" ]; then
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 4/9] CI: Ignore run-tools-test return value
Quoted 8 lines · Anthony PERARD
automation/scripts/qubes-x86-64.sh +0
-0@@ -135,10 +135,11 @@ done ### tests: tools-tests-pv, tools-tests-pvh "tools-tests-pv"|"tools-tests-pvh") retrieve_xml=1
automation/scripts/qubes-x86-64.sh done · line 145
Quoted 10 lines
automation/scripts/qubes-x86-64.sh +3
-2- passed="test passed" + passed="run-tools-test over" domU_check="" dom0_check=" -/root/run-tools-tests /usr/lib/xen/tests /tmp/tests-junit.xml && echo \"${passed}\" +/root/run-tools-tests /usr/lib/xen/tests /tmp/tests-junit.xml ||: +echo \"${passed}\" nc -l -p 8080 < /tmp/tests-junit.xml >/dev/null & " if [ "${test_variant}" = "tools-tests-pvh" ]; then
I noticed this too while hacking on XTF support. Also of note, I'm not sure we want to be saying done to the expect script before sending the results.
The underlying problem is that ${passed} isn't really a pass message; it's a done+pass message, and there is no way to say "failed" to the expect script, leaving timeout as the only option of signalling a failure.
I don't think we want to be ignoring errors from run-tools-tests specifically, but arranging this is hard. You always need something at an outer level judging whether there was a good test result.
For XTF, the way I did this was to declare that anything didn't match "^(Success|Error|Crash|Fail).*" on the final line of the console log to be deemed to be Crash (because it's usually an uncaught exception).
For this, the best I can think of is to have a fixed outer script which runs "./test/script && echo $success || echo $failure". The internal set -e will cause most unexpected conditions to be an error.
~Andrew
Re: [XEN PATCH 4/9] CI: Ignore run-tools-test return value
Quoted 15 lines · Andrew Cooper
Quoted 14 lines · Anthony PERARD
automation/scripts/qubes-x86-64.sh +2
-2@@ -135,10 +135,11 @@ done ### tests: tools-tests-pv, tools-tests-pvh "tools-tests-pv"|"tools-tests-pvh") retrieve_xml=1 - passed="test passed" + passed="run-tools-test over" domU_check="" dom0_check=" -/root/run-tools-tests /usr/lib/xen/tests /tmp/tests-junit.xml && echo \"${passed}\" +/root/run-tools-tests /usr/lib/xen/tests /tmp/tests-junit.xml ||:
Quoted 8 lines
automation/scripts/qubes-x86-64.sh done · line 145
Quoted 4 lines
automation/scripts/qubes-x86-64.sh +1
-0+echo \"${passed}\" nc -l -p 8080 < /tmp/tests-junit.xml >/dev/null & " if [ "${test_variant}" = "tools-tests-pvh" ]; thenI noticed this too while hacking on XTF support. Also of note, I'm not sure we want to be saying done to the expect script before sending the results.
No, expect needs to be notified before, otherwise retrieving the file won't start.
Quoted 3 lines
The underlying problem is that ${passed} isn't really a pass message; it's a done+pass message, and there is no way to say "failed" to the expect script, leaving timeout as the only option of signalling a failure.
Well, that can be changed, by adding yet another message that it looks for, and handling it with exit 1 instead of exit 0.
Quoted 3 lines
I don't think we want to be ignoring errors from run-tools-tests specifically, but arranging this is hard. You always need something at an outer level judging whether there was a good test result.
For those tests specifically, if changing to always say success, you need to ensure that both finding "failure" in xml and not getting the xml at all (or getting it malformed) is treated as a failure.
Quoted 9 lines
For XTF, the way I did this was to declare that anything didn't match "^(Success|Error|Crash|Fail).*" on the final line of the console log to be deemed to be Crash (because it's usually an uncaught exception).
For this, the best I can think of is to have a fixed outer script which runs "./test/script && echo $success || echo $failure". The internal set -e will cause most unexpected conditions to be an error.
~Andrew
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
PATCH 5/9 CI: Have the gitlab job fail on tools/tests failure
In reply to Anthony PERARDFrom: Anthony PERARD <[email protected]>
We can't rely on an exit value from run-tools-tests since we only have the console output. console.exp only look for success or it times out. We could parse the console output, but the junit is more concise. Also check if we have it or fail as well.
--- automation/scripts/qubes-x86-64.sh | 7 +++++++ 1 file changed, 7 insertions(+)
automation/scripts/qubes-x86-64.sh +7 -0
@@ -298,6 +298,13 @@ TEST_RESULT=$? if [ -n "$retrieve_xml" ]; then nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/null + # Findout if one of the test failed + if ! grep -q '</testsuites>' tests-junit.xml; then + echo "ERROR: tests-junit.xml is incomplete or missing." + TEST_RESULT=1 + elif grep -q '</failure>' tests-junit.xml; then + TEST_RESULT=1 + fi fi exit "$TEST_RESULT"
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 5/9] CI: Have the gitlab job fail on tools/tests failure
Quoted 20 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
We can't rely on an exit value from
run-tools-testssince we only have the console output.console.exponly look for success or it times out. We could parse the console output, but the junit is more concise. Also check if we have it or fail as well.Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/qubes-x86-64.sh | 7 +++++++ 1 file changed, 7 insertions(+)automation/scripts/qubes-x86-64.sh +0
-0@@ -298,6 +298,13 @@ TEST_RESULT=$? if [ -n "$retrieve_xml" ]; then nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/null
automation/scripts/qubes-x86-64.sh TEST_RESULT=$? · line 310
Quoted 10 lines
automation/scripts/qubes-x86-64.sh +7
-0+ # Findout if one of the test failed + if ! grep -q '</testsuites>' tests-junit.xml; then + echo "ERROR: tests-junit.xml is incomplete or missing." + TEST_RESULT=1 + elif grep -q '</failure>' tests-junit.xml; then + TEST_RESULT=1 + fi fi exit "$TEST_RESULT"
A couple of things.
From my experimentation with junit,
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report?job_name=kbl-xtf-x86-64-gcc-debug
we can also use </error> for classification. I'm also very disappointed in Gitlab classifying <warning> as success.
Not for this patch, but for XTF I need to be able to express "tolerable failure". (All branches of Xen will run the same tests, and we don't have OSSTest to deem "fail never passed" as non-blocking.)
Even if the job passes overall, I want tolerable failures to show up in the UI, so I have to use <failure> in junit.xml. But that means needing to be more selective, and I don't have a good idea of how to do this. (I have one terrible idea, which is </failure type=tolerable"> which will escape that grep, but it feels like (ab)buse of XML.)
~Andrew
Re: [XEN PATCH 5/9] CI: Have the gitlab job fail on tools/tests failure
Quoted 43 lines · Andrew Cooper
Quoted 20 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
We can't rely on an exit value from
run-tools-testssince we only have the console output.console.exponly look for success or it times out. We could parse the console output, but the junit is more concise. Also check if we have it or fail as well.Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/qubes-x86-64.sh | 7 +++++++ 1 file changed, 7 insertions(+)automation/scripts/qubes-x86-64.sh +0
-0@@ -298,6 +298,13 @@ TEST_RESULT=$? if [ -n "$retrieve_xml" ]; then nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/nullautomation/scripts/qubes-x86-64.sh TEST_RESULT=$? · line 310
Quoted 10 lines
automation/scripts/qubes-x86-64.sh +7
-0+ # Findout if one of the test failed + if ! grep -q '</testsuites>' tests-junit.xml; then + echo "ERROR: tests-junit.xml is incomplete or missing." + TEST_RESULT=1 + elif grep -q '</failure>' tests-junit.xml; then + TEST_RESULT=1 + fi fi exit "$TEST_RESULT"A couple of things.
From my experimentation with junit,
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report?job_name=kbl-xtf-x86-64-gcc-debug
we can also use </error> for classification. I'm also very disappointed in Gitlab classifying <warning> as success.Not for this patch, but for XTF I need to be able to express "tolerable failure". (All branches of Xen will run the same tests, and we don't have OSSTest to deem "fail never passed" as non-blocking.)
Quoted 5 lines
Even if the job passes overall, I want tolerable failures to show up in the UI, so I have to use <failure> in junit.xml. But that means needing to be more selective, and I don't have a good idea of how to do this. (I have one terrible idea, which is </failure type=tolerable"> which will escape that grep, but it feels like (ab)buse of XML.)
But that automation/ dir (including the run-tools-tests script) is per-branch, so you can specify there which tests should be considered failure and which just warning, no? It will require few more bits in the script, but fundamentally shouldn't be a problem?
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Re: [XEN PATCH 5/9] CI: Have the gitlab job fail on tools/tests failure
Quoted 48 lines · Marek Marczykowski-Górecki
Quoted 42 lines · Andrew Cooper
Quoted 20 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
We can't rely on an exit value from
run-tools-testssince we only have the console output.console.exponly look for success or it times out. We could parse the console output, but the junit is more concise. Also check if we have it or fail as well.Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/qubes-x86-64.sh | 7 +++++++ 1 file changed, 7 insertions(+)automation/scripts/qubes-x86-64.sh +0
-0@@ -298,6 +298,13 @@ TEST_RESULT=$? if [ -n "$retrieve_xml" ]; then nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/nullautomation/scripts/qubes-x86-64.sh TEST_RESULT=$? · line 310
Quoted 10 lines
automation/scripts/qubes-x86-64.sh +7
-0+ # Findout if one of the test failed + if ! grep -q '</testsuites>' tests-junit.xml; then + echo "ERROR: tests-junit.xml is incomplete or missing." + TEST_RESULT=1 + elif grep -q '</failure>' tests-junit.xml; then + TEST_RESULT=1 + fi fi exit "$TEST_RESULT"A couple of things.
From my experimentation with junit,
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report?job_name=kbl-xtf-x86-64-gcc-debug
we can also use </error> for classification. I'm also very disappointed in Gitlab classifying <warning> as success.Not for this patch, but for XTF I need to be able to express "tolerable failure". (All branches of Xen will run the same tests, and we don't have OSSTest to deem "fail never passed" as non-blocking.)
Quoted 5 lines
Even if the job passes overall, I want tolerable failures to show up in the UI, so I have to use <failure> in junit.xml. But that means needing to be more selective, and I don't have a good idea of how to do this. (I have one terrible idea, which is </failure type=tolerable"> which will escape that grep, but it feels like (ab)buse of XML.)
Quoted 5 lines
But that automation/ dir (including the run-tools-tests script) is per-branch, so you can specify there which tests should be considered failure and which just warning, no? It will require few more bits in the script, but fundamentally shouldn't be a problem?
XTF is in a separate repo and does not have branches.
Now consider
https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=d965e2ee07c56c341d8896852550914d87ea5374,
and testing it.
Anything I put into XTF to test it will pass on staging but fail on the older stable-* trees. In due course it will get backported to the bugfix branches, but it likely won't get fixed on the security-only branches.
Furthermore, I need to not change xen.git to make this work, and older branches need to pick up newer XTF automatically. (XSA tests *are* expected to pass everywhere once the issue is public.)
My current plan is to have logic of the form:
if ( xenver >= $STAGING )
xtf_failure(...);
else
xtf_success("Expected Failure:" ...);
where $STAGING moves when backports get done. I still want the failures to show up in the Tests UI.
~Andrew
Re: [XEN PATCH 5/9] CI: Have the gitlab job fail on tools/tests failure
Quoted 71 lines · Andrew Cooper
Quoted 48 lines · Marek Marczykowski-Górecki
Quoted 42 lines · Andrew Cooper
Quoted 20 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
We can't rely on an exit value from
run-tools-testssince we only have the console output.console.exponly look for success or it times out. We could parse the console output, but the junit is more concise. Also check if we have it or fail as well.Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/qubes-x86-64.sh | 7 +++++++ 1 file changed, 7 insertions(+)automation/scripts/qubes-x86-64.sh +0
-0@@ -298,6 +298,13 @@ TEST_RESULT=$? if [ -n "$retrieve_xml" ]; then nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/nullautomation/scripts/qubes-x86-64.sh TEST_RESULT=$? · line 310
Quoted 10 lines
automation/scripts/qubes-x86-64.sh +7
-0+ # Findout if one of the test failed + if ! grep -q '</testsuites>' tests-junit.xml; then + echo "ERROR: tests-junit.xml is incomplete or missing." + TEST_RESULT=1 + elif grep -q '</failure>' tests-junit.xml; then + TEST_RESULT=1 + fi fi exit "$TEST_RESULT"A couple of things.
From my experimentation with junit,
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report?job_name=kbl-xtf-x86-64-gcc-debug
we can also use </error> for classification. I'm also very disappointed in Gitlab classifying <warning> as success.Not for this patch, but for XTF I need to be able to express "tolerable failure". (All branches of Xen will run the same tests, and we don't have OSSTest to deem "fail never passed" as non-blocking.)
Quoted 5 lines
Even if the job passes overall, I want tolerable failures to show up in the UI, so I have to use <failure> in junit.xml. But that means needing to be more selective, and I don't have a good idea of how to do this. (I have one terrible idea, which is </failure type=tolerable"> which will escape that grep, but it feels like (ab)buse of XML.)
Quoted 5 lines
But that automation/ dir (including the run-tools-tests script) is per-branch, so you can specify there which tests should be considered failure and which just warning, no? It will require few more bits in the script, but fundamentally shouldn't be a problem?
XTF is in a separate repo and does not have branches.
Now consider
https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=d965e2ee07c56c341d8896852550914d87ea5374,
and testing it.Anything I put into XTF to test it will pass on staging but fail on the older stable-* trees. In due course it will get backported to the bugfix branches, but it likely won't get fixed on the security-only branches.
Furthermore, I need to not change xen.git to make this work, and older branches need to pick up newer XTF automatically. (XSA tests *are* expected to pass everywhere once the issue is public.)
My current plan is to have logic of the form:
Quoted 7 lines
if ( xenver >= $STAGING )
xtf_failure(...);
else
xtf_success("Expected Failure:" ...);where $STAGING moves when backports get done. I still want the failures to show up in the Tests UI.
P.S. I'm planning to teach ./xtf-runner how to write out a junit.xml directly. I'm not interested in interpreting python's stdout and writing xml in shell...
~Andrew
Re: [XEN PATCH 5/9] CI: Have the gitlab job fail on tools/tests failure
In reply to Andrew CooperQuoted 12 lines · Andrew Cooper
Quoted 11 lines · Anthony PERARD
if [ -n "$retrieve_xml" ]; then
nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/nullautomation/scripts/qubes-x86-64.sh +7
-0+ # Findout if one of the test failed + if ! grep -q '</testsuites>' tests-junit.xml; then + echo "ERROR: tests-junit.xml is incomplete or missing." + TEST_RESULT=1 + elif grep -q '</failure>' tests-junit.xml; then + TEST_RESULT=1 + fi fi
Quoted 8 lines
Quoted 1 line
exit "$TEST_RESULT"
A couple of things.
From my experimentation with junit,
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report?job_name=kbl-xtf-x86-64-gcc-debug
we can also use </error> for classification. I'm also very disappointed in Gitlab classifying <warning> as success.
According to the documentation [1] which point to this junit xml format [2] the only elements (and path) are:
testsuites.testsuite.testcase.failure
"error" or "warning" don't exist.
There's the attributes type in <failure> but this isn't explained how it's used.
But I guess if we follow the link in [2], go through web.archive.org, we can find [3] which has "skipped", "error", "failure", but still no "warning".
[1] https://docs.gitlab.com/ci/testing/unit_test_reports/#unit-test-reporting-workflow
[2] https://www.ibm.com/docs/en/developer-for-zos/16.0?topic=formats-junit-xml-format
[3] https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
Quoted 3 lines
Not for this patch, but for XTF I need to be able to express "tolerable failure". (All branches of Xen will run the same tests, and we don't have OSSTest to deem "fail never passed" as non-blocking.)
According to [1], there's a notion of "Existing failures", but that might show up only on merge request.
Quoted 5 lines
Even if the job passes overall, I want tolerable failures to show up in the UI, so I have to use <failure> in junit.xml. But that means needing to be more selective, and I don't have a good idea of how to do this. (I have one terrible idea, which is </failure type=tolerable"> which will escape that grep, but it feels like (ab)buse of XML.)
At the moment, run-tools-tests write '<failure type="failure"' on failure, so we could grep on that instead event if it is sligtly more fragile. I've choosen to grep on '</failure>' at first because that's much less likely to be written differently, while the attributes in the tag could be written in a different order.
Then, we can always use sed and extract the "type" to check it:
sed -n 's/.*<failure \(\|.* \)type="\([^"]\+\)" .*/\2/p' tests-junit.xml | while read type; do
case $type in
failure) echo fail;;
tolerable) echo ok;;
*) echo error unknwon type $type;; esac
done
But that maybe going a bit too far :-)
Cheers,
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 5/9] CI: Have the gitlab job fail on tools/tests failure
Quoted 27 lines · Anthony PERARD
Quoted 12 lines · Andrew Cooper
Quoted 11 lines · Anthony PERARD
if [ -n "$retrieve_xml" ]; then
nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/nullautomation/scripts/qubes-x86-64.sh +7
-0+ # Findout if one of the test failed + if ! grep -q '</testsuites>' tests-junit.xml; then + echo "ERROR: tests-junit.xml is incomplete or missing." + TEST_RESULT=1 + elif grep -q '</failure>' tests-junit.xml; then + TEST_RESULT=1 + fi fiQuoted 7 lines
Quoted 1 line
exit "$TEST_RESULT"
A couple of things.
From my experimentation with junit,
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report?job_name=kbl-xtf-x86-64-gcc-debug
we can also use </error> for classification. I'm also very disappointed in Gitlab classifying <warning> as success.According to the documentation [1] which point to this junit xml format [2] the only elements (and path) are:
testsuites.testsuite.testcase.failure
"error" or "warning" don't exist.
There's the attributestypein <failure> but this isn't explained how it's used.
Quoted 8 lines
But I guess if we follow the link in [2], go through web.archive.org, we can find [3] which has "skipped", "error", "failure", but still no "warning".
[1] https://docs.gitlab.com/ci/testing/unit_test_reports/#unit-test-reporting-workflow
[2] https://www.ibm.com/docs/en/developer-for-zos/16.0?topic=formats-junit-xml-format
[3] https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
I was also very disappointed with the documentation, which seems to be almost non-existent.
But after some source diving:
https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/ci/parsers/test/junit.rb#L69-83
So anything which isn't recognised is deemed to be success. Lovely :(
I'm also still none the wiser as to why Skip's system_out is a formatted json blob, unlike the others.
Quoted 22 lines
Quoted 5 lines
Not for this patch, but for XTF I need to be able to express "tolerable failure". (All branches of Xen will run the same tests, and we don't have OSSTest to deem "fail never passed" as non-blocking.)
According to [1], there's a notion of "Existing failures", but that might show up only on merge request.
Quoted 5 lines
Even if the job passes overall, I want tolerable failures to show up in the UI, so I have to use <failure> in junit.xml. But that means needing to be more selective, and I don't have a good idea of how to do this. (I have one terrible idea, which is </failure type=tolerable"> which will escape that grep, but it feels like (ab)buse of XML.)
At the moment,
run-tools-testswrite '<failure type="failure"' on failure, so we could grep on that instead event if it is sligtly more fragile. I've choosen to grep on '</failure>' at first because that's much less likely to be written differently, while the attributes in the tag could be written in a different order.Then, we can always use
sedand extract the "type" to check it:
sed -n 's/.*<failure \(\|.* \)type="\([^"]\+\)" .*/\2/p' tests-junit.xml | while read type; do
case $type in
Quoted 6 lines
failure) echo fail;; tolerable) echo ok;; *) echo error unknwon type $type;;esac
done
But that maybe going a bit too far :-)
There's xq which might be able to do this more nicely, and is packaged in alpine.
~Andrew
PATCH 6/9 CI: Upload junit result as artefact
In reply to Anthony PERARDFrom: Anthony PERARD <[email protected]>
This allow to investigate the file in cases of error. Not all jobs that extend ".adl-x86-64" are creating a "tests-junit.xml" but Gitlab only produce a warning when the file isn't found.
--- automation/gitlab-ci/test.yaml | 1 + 1 file changed, 1 insertion(+)
automation/gitlab-ci/test.yaml +1 -0
@@ -155,6 +155,7 @@ paths: - smoke.serial - '*.log' + - tests-junit.xml when: always rules: - if: $SELECTED_JOBS_ONLY && $CI_JOB_NAME =~ $SELECTED_JOBS_ONLY
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 6/9] CI: Upload junit result as artefact
Quoted 5 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
This allow to investigate the file in cases of error. Not all jobs that extend ".adl-x86-64" are creating a "tests-junit.xml" but Gitlab only produce a warning when the file isn't found.
I'm not sure what you're trying to say here.
~Andrew
Re: [XEN PATCH 6/9] CI: Upload junit result as artefact
Quoted 8 lines · Andrew Cooper
Quoted 5 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
This allow to investigate the file in cases of error. Not all jobs that extend ".adl-x86-64" are creating a "tests-junit.xml" but Gitlab only produce a warning when the file isn't found.
I'm not sure what you're trying to say here.
I guess I can shorten the message to (with some rewording):
"This allows to investigate the junit file in cases of parse error."
I guess it doesn't matter if a gitlab job is expected to produce "tests-junit.xml" or not.
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 7/9 CI: Use CDATA avoid the need to escape tests outputs
In reply to Anthony PERARDFrom: Anthony PERARD <[email protected]>
This is easier than escaping individual characters, especially '&' and '<' which are problematic if present.
We might still need to escape ']]>' if this string is present in the test output, but hopefully not.
--- automation/scripts/run-tools-tests | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
automation/scripts/run-tools-tests +2 -2
@@ -25,9 +25,9 @@ for f in "$1"/*; do echo "FAILED: $f" failed+=" $f" printf ' <failure type="failure" message="binary %s exited with code %d">\n' "$f" "$ret" >> "$xml_out" - # TODO: could use xml escaping... but current tests seems to - # produce sane output + printf '<![CDATA[' >> "$xml_out" cat /tmp/out >> "$xml_out" + printf ']]>' >> "$xml_out" printf ' </failure>\n' >> "$xml_out" else echo "PASSED"
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 7/9] CI: Use CDATA avoid the need to escape tests outputs
automation/scripts/run-tools-tests for f in "$1"/*; do · line 30
Quoted 13 lines · Anthony PERARD
automation/scripts/run-tools-tests +2
-2@@ -25,9 +25,9 @@ for f in "$1"/*; do echo "FAILED: $f" failed+=" $f" printf ' <failure type="failure" message="binary %s exited with code %d">\n' "$f" "$ret" >> "$xml_out" - # TODO: could use xml escaping... but current tests seems to - # produce sane output + printf '<![CDATA[' >> "$xml_out" cat /tmp/out >> "$xml_out" + printf ']]>' >> "$xml_out"
I think you want a \n on this printf.
I'd also suggest leaving a TODO for "escape ]]> if necessary".
Otherwise, Reviewed-by: Andrew Cooper <[email protected]>
Stefano Stabellini
Acked-byRe: [XEN PATCH 7/9] CI: Use CDATA avoid the need to escape tests outputs
Quoted 17 lines · Andrew Cooper
automation/scripts/run-tools-tests for f in "$1"/*; do · line 30
Quoted 13 lines · Anthony PERARD
automation/scripts/run-tools-tests +2
-2@@ -25,9 +25,9 @@ for f in "$1"/*; do echo "FAILED: $f" failed+=" $f" printf ' <failure type="failure" message="binary %s exited with code %d">\n' "$f" "$ret" >> "$xml_out" - # TODO: could use xml escaping... but current tests seems to - # produce sane output + printf '<![CDATA[' >> "$xml_out" cat /tmp/out >> "$xml_out" + printf ']]>' >> "$xml_out"I think you want a \n on this printf.
Quoted 3 lines
I'd also suggest leaving a TODO for "escape ]]> if necessary".
Otherwise, Reviewed-by: Andrew Cooper <[email protected]>
PATCH 8/9 CI: Workaround extra content in junit
In reply to Anthony PERARDFrom: Anthony PERARD <[email protected]>
--- automation/scripts/qubes-x86-64.sh | 6 ++++++ 1 file changed, 6 insertions(+)
automation/scripts/qubes-x86-64.sh +6 -0
@@ -298,6 +298,12 @@ TEST_RESULT=$? if [ -n "$retrieve_xml" ]; then nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/null + # Workaround duplicated data been received + sed -i.old '/^<\/testsuites>/q' tests-junit.xml > /dev/null + extra_line_in_junit=$(($(wc -l < tests-junit.xml.old) - $(wc -l < tests-junit.xml))) + if [ $extra_line_in_junit -gt 0 ]; then + echo "WARNING: Found $extra_line_in_junit too many lines in junit." + fi # Findout if one of the test failed if ! grep -q '</testsuites>' tests-junit.xml; then echo "ERROR: tests-junit.xml is incomplete or missing."
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 8/9] CI: Workaround extra content in junit
Quoted 12 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/qubes-x86-64.sh | 6 ++++++ 1 file changed, 6 insertions(+)automation/scripts/qubes-x86-64.sh +0
-0
automation/scripts/qubes-x86-64.sh TEST_RESULT=$? · line 306
Quoted 9 lines
automation/scripts/qubes-x86-64.sh +6
-0@@ -298,6 +298,12 @@ TEST_RESULT=$? if [ -n "$retrieve_xml" ]; then nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/null + # Workaround duplicated data been received + sed -i.old '/^<\/testsuites>/q' tests-junit.xml > /dev/null + extra_line_in_junit=$(($(wc -l < tests-junit.xml.old) - $(wc -l < tests-junit.xml))) + if [ $extra_line_in_junit -gt 0 ]; then + echo "WARNING: Found $extra_line_in_junit too many lines in junit." + fi
Is this the cause of
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report
getting a row of 0's for ADL ?
Why are we getting duplicate data? nc is running in TCP mode, not UDP, so it's not that.
~Andrew
Re: [XEN PATCH 8/9] CI: Workaround extra content in junit
Quoted 10 lines · Andrew Cooper
automation/scripts/qubes-x86-64.sh TEST_RESULT=$? · line 306
Quoted 8 lines · Anthony PERARD
if [ -n "$retrieve_xml" ]; then
nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/nullautomation/scripts/qubes-x86-64.sh +6
-0+ # Workaround duplicated data been received + sed -i.old '/^<\/testsuites>/q' tests-junit.xml > /dev/null + extra_line_in_junit=$(($(wc -l < tests-junit.xml.old) - $(wc -l < tests-junit.xml))) + if [ $extra_line_in_junit -gt 0 ]; then + echo "WARNING: Found $extra_line_in_junit too many lines in junit." + fi
Quoted 3 lines
Is this the cause of
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report
getting a row of 0's for ADL ?
Well, the error I had was this one:
"FATAL: Extra content at the end of the document"
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1848598740/test_report
And indeed, when I managed to dl the junit.xml, there were the end of the document duplicated many times.
Quoted 2 lines
Why are we getting duplicate data? nc is running in TCP mode, not UDP, so it's not that.
I think Marek talked about some notwork equiment in the middle? I managed to find in matrix where they were talk about this duplication of data, well, with nc dl for ever, with lots of duplicated data:
from marmarek
Quoted 3 lines
So, it appears to be a bug in pasta - the thing that podman uses to proxy traffic out of the container's network namespace. You know, an additional network stack in userspace.
I have no idea if it is the same issue, but I had extra content in the junit file with nearly all my jobs.
Cheers,
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 8/9] CI: Workaround extra content in junit
Quoted 15 lines · Anthony PERARD
Quoted 10 lines · Andrew Cooper
automation/scripts/qubes-x86-64.sh TEST_RESULT=$? · line 306
Quoted 8 lines · Anthony PERARD
if [ -n "$retrieve_xml" ]; then
nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/nullautomation/scripts/qubes-x86-64.sh +6
-0+ # Workaround duplicated data been received + sed -i.old '/^<\/testsuites>/q' tests-junit.xml > /dev/null + extra_line_in_junit=$(($(wc -l < tests-junit.xml.old) - $(wc -l < tests-junit.xml))) + if [ $extra_line_in_junit -gt 0 ]; then + echo "WARNING: Found $extra_line_in_junit too many lines in junit." + fiQuoted 3 lines
Is this the cause of
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report
getting a row of 0's for ADL ?
Quoted 6 lines
Well, the error I had was this one:
"FATAL: Extra content at the end of the document"
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1848598740/test_reportAnd indeed, when I managed to dl the junit.xml, there were the end of the document duplicated many times.
Wouldn't it better to do |sort|uniq to dedup the file?
Re: [XEN PATCH 8/9] CI: Workaround extra content in junit
Quoted 16 lines · Stefano Stabellini
Quoted 15 lines · Anthony PERARD
Quoted 13 lines · Andrew Cooper
automation/scripts/qubes-x86-64.sh TEST_RESULT=$? · line 306
Quoted 8 lines · Anthony PERARD
if [ -n "$retrieve_xml" ]; then
nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/nullautomation/scripts/qubes-x86-64.sh +6
-0+ # Workaround duplicated data been received + sed -i.old '/^<\/testsuites>/q' tests-junit.xml > /dev/null + extra_line_in_junit=$(($(wc -l < tests-junit.xml.old) - $(wc -l < tests-junit.xml))) + if [ $extra_line_in_junit -gt 0 ]; then + echo "WARNING: Found $extra_line_in_junit too many lines in junit." + fiIs this the cause of
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report
getting a row of 0's for ADL ?
Quoted 8 lines
Quoted 6 lines
Well, the error I had was this one:
"FATAL: Extra content at the end of the document"
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1848598740/test_reportAnd indeed, when I managed to dl the junit.xml, there were the end of the document duplicated many times.
Wouldn't it better to do |sort|uniq to dedup the file?
I don't think XML structure will survive it...
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Re: [XEN PATCH 8/9] CI: Workaround extra content in junit
Quoted 21 lines · Marek Marczykowski-Górecki
Quoted 20 lines · Stefano Stabellini
Quoted 19 lines · Anthony PERARD
Quoted 10 lines · Andrew Cooper
automation/scripts/qubes-x86-64.sh TEST_RESULT=$? · line 306
Quoted 8 lines · Anthony PERARD
if [ -n "$retrieve_xml" ]; then
nc -w 10 "$SUT_ADDR" 8080 > tests-junit.xml </dev/nullautomation/scripts/qubes-x86-64.sh +6
-0+ # Workaround duplicated data been received + sed -i.old '/^<\/testsuites>/q' tests-junit.xml > /dev/null + extra_line_in_junit=$(($(wc -l < tests-junit.xml.old) - $(wc -l < tests-junit.xml))) + if [ $extra_line_in_junit -gt 0 ]; then + echo "WARNING: Found $extra_line_in_junit too many lines in junit." + fiQuoted 3 lines
Is this the cause of
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1849342222/test_report
getting a row of 0's for ADL ?Well, the error I had was this one:
"FATAL: Extra content at the end of the document"
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1848598740/test_report
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
And indeed, when I managed to dl the junit.xml, there were the end of the document duplicated many times.
Wouldn't it better to do |sort|uniq to dedup the file?
I don't think XML structure will survive it...
Ops, good point.
PATCH 9/9 CI: Add timing to junit
In reply to Anthony PERARDFrom: Anthony PERARD <[email protected]>
--- automation/scripts/run-tools-tests | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
automation/scripts/run-tools-tests +4 -1
@@ -18,9 +18,12 @@ for f in "$1"/*; do continue fi echo "Running $f" - printf ' <testcase name="%s">\n' "$f" >> "$xml_out" + time_start=$EPOCHREALTIME "$f" 2>&1 | tee /tmp/out ret=${PIPESTATUS[0]} + time_end=$EPOCHREALTIME + time_test="$(bc <<<"$time_end - $time_start")" + printf ' <testcase name="%s" time="%f">\n' "$f" "$time_test" >> "$xml_out" if [ "$ret" -ne 0 ]; then echo "FAILED: $f" failed+=" $f"
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 9/9] CI: Add timing to junit
Quoted 3 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Signed-off-by Anthony PERARD <[email protected]>
Quoted 9 lines
--- automation/scripts/run-tools-tests | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)automation/scripts/run-tools-tests +0
-0
automation/scripts/run-tools-tests for f in "$1"/*; do · line 26
Quoted 10 lines
automation/scripts/run-tools-tests +4
-1@@ -18,9 +18,12 @@ for f in "$1"/*; do continue fi echo "Running $f" - printf ' <testcase name="%s">\n' "$f" >> "$xml_out" + time_start=$EPOCHREALTIME "$f" 2>&1 | tee /tmp/out ret=${PIPESTATUS[0]} + time_end=$EPOCHREALTIME + time_test="$(bc <<<"$time_end - $time_start")" + printf ' <testcase name="%s" time="%f">\n' "$f" "$time_test" >> "$xml_out"
I'd suggest $time_delta rather than $time_test.
~Andrew
Re: [XEN PATCH 9/9] CI: Add timing to junit
In reply to Anthony PERARDQuoted 12 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/run-tools-tests | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)automation/scripts/run-tools-tests +0
-0
automation/scripts/run-tools-tests for f in "$1"/*; do · line 25
Quoted 9 lines
automation/scripts/run-tools-tests +3
-1@@ -18,9 +18,12 @@ for f in "$1"/*; do continue fi echo "Running $f" - printf ' <testcase name="%s">\n' "$f" >> "$xml_out" + time_start=$EPOCHREALTIME "$f" 2>&1 | tee /tmp/out ret=${PIPESTATUS[0]} + time_end=$EPOCHREALTIME + time_test="$(bc <<<"$time_end - $time_start")"
As it looks like no other scripts need bc at the moment but we already rely on awk (automation/scripts/xilinx-smoke-dom0less-arm64.sh) I'd prefer this version:
time_test="$(awk "BEGIN {print $time_end - $time_start}")"
Quoted 7 lines
automation/scripts/run-tools-tests +1
-0+ printf ' <testcase name="%s" time="%f">\n' "$f" "$time_test" >> "$xml_out" if [ "$ret" -ne 0 ]; then echo "FAILED: $f" failed+=" $f"Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 9/9] CI: Add timing to junit
Quoted 27 lines · Stefano Stabellini
Quoted 12 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/run-tools-tests | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)automation/scripts/run-tools-tests +0
-0automation/scripts/run-tools-tests for f in "$1"/*; do · line 25
Quoted 9 lines
automation/scripts/run-tools-tests +3
-1@@ -18,9 +18,12 @@ for f in "$1"/*; do continue fi echo "Running $f" - printf ' <testcase name="%s">\n' "$f" >> "$xml_out" + time_start=$EPOCHREALTIME "$f" 2>&1 | tee /tmp/out ret=${PIPESTATUS[0]} + time_end=$EPOCHREALTIME + time_test="$(bc <<<"$time_end - $time_start")"As it looks like no other scripts need bc at the moment but we already rely on awk (
automation/scripts/xilinx-smoke-dom0less-arm64.sh) I'd prefer this version:
Quoted 1 line
time_test="$(awk "BEGIN {print $time_end - $time_start}")"
You mean I have to choose between busybox and busybox?
$ ls -l $(which bc awk) lrwxrwxrwx 1 root root 12 Feb 13 23:19 /usr/bin/awk -> /bin/busybox lrwxrwxrwx 1 root root 12 Feb 13 23:19 /usr/bin/bc -> /bin/busybox
:-)
I guess it doesn't really matter.
One difference though:
$ awk "BEGIN {print $time_end - $time_start}"
3.28798
$ bc <<<"$time_end - $time_start"
3.287982awk is less precise, but I guess that doesn't matter as well, gitlab UI isn't going to show the extra digits.
So I guess I can change to use awk instead, just in case for some reason bc isn't present, since awk seems mandatory for many of our scripts.
Thanks,
Signature · 1 line
Anthony PERARD
Re: [XEN PATCH 9/9] CI: Add timing to junit
Quoted 44 lines · Anthony PERARD
Quoted 26 lines · Stefano Stabellini
Quoted 12 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/run-tools-tests | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)automation/scripts/run-tools-tests +0
-0automation/scripts/run-tools-tests for f in "$1"/*; do · line 25
Quoted 9 lines
automation/scripts/run-tools-tests +3
-1@@ -18,9 +18,12 @@ for f in "$1"/*; do continue fi echo "Running $f" - printf ' <testcase name="%s">\n' "$f" >> "$xml_out" + time_start=$EPOCHREALTIME "$f" 2>&1 | tee /tmp/out ret=${PIPESTATUS[0]} + time_end=$EPOCHREALTIME + time_test="$(bc <<<"$time_end - $time_start")"As it looks like no other scripts need bc at the moment but we already rely on awk (
automation/scripts/xilinx-smoke-dom0less-arm64.sh) I'd prefer this version:Quoted 1 line
time_test="$(awk "BEGIN {print $time_end - $time_start}")"
You mean I have to choose between busybox and busybox?
$ ls -l $(which bc awk) lrwxrwxrwx 1 root root 12 Feb 13 23:19 /usr/bin/awk -> /bin/busybox lrwxrwxrwx 1 root root 12 Feb 13 23:19 /usr/bin/bc -> /bin/busybox:-)
I guess it doesn't really matter.
One difference though:
$ awk "BEGIN {print $time_end - $time_start}" 3.28798 $ bc <<<"$time_end - $time_start" 3.287982
Quoted 8 lines
awk is less precise, but I guess that doesn't matter as well, gitlab UI isn't going to show the extra digits.
So I guess I can change to use
awkinstead, just in case for some reasonbcisn't present, sinceawkseems mandatory for many of our scripts.Thanks,
bc is a normal posix utility just like awk is, so there's no change in dependencies caused by this.
Furthermore, it is the right tool for this job in a way that awk isn't. Besides the reduction in precision, see xen/tools/check-endbr.sh for the number of ways we found that awk malfunctions with large numbers.
I firmly suggest continuing to use bc here.
~Andrew
Re: [XEN PATCH 9/9] CI: Add timing to junit
Quoted 48 lines · Andrew Cooper
Quoted 47 lines · Anthony PERARD
Quoted 26 lines · Stefano Stabellini
Quoted 12 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/run-tools-tests | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)automation/scripts/run-tools-tests +0
-0automation/scripts/run-tools-tests for f in "$1"/*; do · line 25
Quoted 9 lines
automation/scripts/run-tools-tests +3
-1@@ -18,9 +18,12 @@ for f in "$1"/*; do continue fi echo "Running $f" - printf ' <testcase name="%s">\n' "$f" >> "$xml_out" + time_start=$EPOCHREALTIME "$f" 2>&1 | tee /tmp/out ret=${PIPESTATUS[0]} + time_end=$EPOCHREALTIME + time_test="$(bc <<<"$time_end - $time_start")"As it looks like no other scripts need bc at the moment but we already rely on awk (
automation/scripts/xilinx-smoke-dom0less-arm64.sh) I'd prefer this version:Quoted 1 line
time_test="$(awk "BEGIN {print $time_end - $time_start}")"
You mean I have to choose between busybox and busybox?
$ ls -l $(which bc awk) lrwxrwxrwx 1 root root 12 Feb 13 23:19 /usr/bin/awk -> /bin/busybox lrwxrwxrwx 1 root root 12 Feb 13 23:19 /usr/bin/bc -> /bin/busybox:-)
I guess it doesn't really matter.
One difference though:
$ awk "BEGIN {print $time_end - $time_start}" 3.28798 $ bc <<<"$time_end - $time_start" 3.287982awk is less precise, but I guess that doesn't matter as well, gitlab UI isn't going to show the extra digits.
Quoted 8 lines
Quoted 5 lines
So I guess I can change to use
awkinstead, just in case for some reasonbcisn't present, sinceawkseems mandatory for many of our scripts.Thanks,
bc is a normal posix utility just like awk is, so there's no change in dependencies caused by this.
Linux requires bc for building, and I _very_ often find systems where it isn't installed by default (by awk is)...
Anyway, that's probably irrelevant in the CI container that has busybox for both.
Quoted 7 lines
Furthermore, it is the right tool for this job in a way that awk isn't. Besides the reduction in precision, see
xen/tools/check-endbr.shfor the number of ways we found that awk malfunctions with large numbers.I firmly suggest continuing to use bc here.
~Andrew
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Re: [XEN PATCH 9/9] CI: Add timing to junit
Quoted 55 lines · Marek Marczykowski-Górecki
Quoted 54 lines · Andrew Cooper
Quoted 52 lines · Anthony PERARD
Quoted 26 lines · Stefano Stabellini
Quoted 12 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Signed-off-by Anthony PERARD <[email protected]>--- automation/scripts/run-tools-tests | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)automation/scripts/run-tools-tests +0
-0automation/scripts/run-tools-tests for f in "$1"/*; do · line 25
Quoted 9 lines
automation/scripts/run-tools-tests +3
-1@@ -18,9 +18,12 @@ for f in "$1"/*; do continue fi echo "Running $f" - printf ' <testcase name="%s">\n' "$f" >> "$xml_out" + time_start=$EPOCHREALTIME "$f" 2>&1 | tee /tmp/out ret=${PIPESTATUS[0]} + time_end=$EPOCHREALTIME + time_test="$(bc <<<"$time_end - $time_start")"As it looks like no other scripts need bc at the moment but we already rely on awk (
automation/scripts/xilinx-smoke-dom0less-arm64.sh) I'd prefer this version:Quoted 1 line
time_test="$(awk "BEGIN {print $time_end - $time_start}")"
You mean I have to choose between busybox and busybox?
$ ls -l $(which bc awk) lrwxrwxrwx 1 root root 12 Feb 13 23:19 /usr/bin/awk -> /bin/busybox lrwxrwxrwx 1 root root 12 Feb 13 23:19 /usr/bin/bc -> /bin/busybox:-)
I guess it doesn't really matter.
One difference though:
$ awk "BEGIN {print $time_end - $time_start}" 3.28798 $ bc <<<"$time_end - $time_start" 3.287982awk is less precise, but I guess that doesn't matter as well, gitlab UI isn't going to show the extra digits.
So I guess I can change to use
awkinstead, just in case for some reasonbcisn't present, sinceawkseems mandatory for many of our scripts.Thanks,
Quoted 7 lines
Quoted 2 lines
bc is a normal posix utility just like awk is, so there's no change in dependencies caused by this.
Linux requires bc for building, and I _very_ often find systems where it isn't installed by default (by awk is)...
Anyway, that's probably irrelevant in the CI container that has busybox for both.
Yes, I see the same. Honestly, I wouldn't mind having a dependecy on bc, it is common enough and available enough, it is just that we are not doing a great job at tracking this type of dependencies in test scripts, so I just thought the less we have the better and in this case there is an easy solution. Anyway, this is not the hill I am hill I am going to die on.