tests: Ensure TAP version is printed before other messages
PATCH 1/1 tests: Ensure TAP version is printed before other messages
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST be TAP version <int>. Assuming version 12.
This can be fixed by ensuring we always call g_test_init first in the body of main.
Thanks: Daniel Berrange, for diagnosing the problem
--- tests/qtest/fuzz-lsi53c895a-test.c | 4 ++-- tests/qtest/rtl8139-test.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
tests/qtest/fuzz-lsi53c895a-test.c +2 -2
@@ -112,12 +112,12 @@ static void test_lsi_do_dma_empty_queue(void)int main (int argc,char **argv) { +g_test_init (&argc, &argv,NULL ); +if (!qtest_has_device ("lsi53c895a" )) {return 0 ; } -g_test_init (&argc, &argv,NULL ); -qtest_add_func ("fuzz/lsi53c895a/lsi_do_dma_empty_queue" , test_lsi_do_dma_empty_queue);
tests/qtest/rtl8139-test.c +3 -2
@@ -207,9 +207,10 @@ int main(int argc, char **argv) verbosity_level =atoi (v_env); } -qtest_start ("-device rtl8139" ); -g_test_init (&argc, &argv,NULL ); + +qtest_start ("-device rtl8139" ); +qtest_add_func ("/rtl8139/nop" , nop);qtest_add_func ("/rtl8139/timer" , test_init);
Signature · 1 line
2.39.2
Quoted 10 lines · Richard W.M. Jones
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST beTAP version <int>. Assuming version 12.This can be fixed by ensuring we always call
g_test_initfirst in the body of main.
Quoted 6 lines
Thanks: Daniel Berrange, for diagnosing the problem
Signed-off-by Richard W.M. Jones <[email protected]>--- tests/qtest/fuzz-lsi53c895a-test.c | 4 ++-- tests/qtest/rtl8139-test.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
tests/qtest/fuzz-lsi53c895a-test.c static void test_lsi_do_dma_empty_queue(void) · line 118
Quoted 13 lines
tests/qtest/fuzz-lsi53c895a-test.c +2
-0@@ -112,12 +112,12 @@ static void test_lsi_do_dma_empty_queue(void)int main (int argc,char **argv) { +g_test_init (&argc, &argv,NULL ); +if (!qtest_has_device ("lsi53c895a" )) {return 0 ;
[> }
Quoted 11 lines
tests/qtest/fuzz-lsi53c895a-test.c +0
-2-g_test_init (&argc, &argv,NULL ); -qtest_add_func ("fuzz/lsi53c895a/lsi_do_dma_empty_queue" , test_lsi_do_dma_empty_queue);tests/qtest/rtl8139-test.c +0
-0
tests/qtest/rtl8139-test.c int main(int argc, char **argv) · line 212
Quoted 8 lines
tests/qtest/rtl8139-test.c +2
-2@@ -207,9 +207,10 @@ int main(int argc, char **argv) verbosity_level =atoi (v_env); } -qtest_start ("-device rtl8139" ); -g_test_init (&argc, &argv,NULL ); + +qtest_start ("-device rtl8139" );
As a more general point I find it a little dubious that we spawn QEMU from main() outside the context of the test case. I guess that makes it slightly more efficient since we have one QEMU for both test cases, but it is feels slightly oddball and obviously leads to bugs like this one we see.
Quoted 7 lines
tests/qtest/rtl8139-test.c +1
-0+qtest_add_func ("/rtl8139/nop" , nop);qtest_add_func ("/rtl8139/timer" , test_init);Signature · 1 line
2.39.2
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 7 lines · Richard W.M. Jones
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST beTAP version <int>. Assuming version 12.
Quoted 5 lines
This can be fixed by ensuring we always call
g_test_initfirst in the body of main.Thanks: Daniel Berrange, for diagnosing the problem
Signed-off-by Richard W.M. Jones <[email protected]>
Thanks,
Darren.
Quoted 43 lines
--- tests/qtest/fuzz-lsi53c895a-test.c | 4 ++-- tests/qtest/rtl8139-test.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)tests/qtest/fuzz-lsi53c895a-test.c +2
-2@@ -112,12 +112,12 @@ static void test_lsi_do_dma_empty_queue(void)int main (int argc,char **argv) { +g_test_init (&argc, &argv,NULL ); +if (!qtest_has_device ("lsi53c895a" )) {return 0 ; } -g_test_init (&argc, &argv,NULL ); -qtest_add_func ("fuzz/lsi53c895a/lsi_do_dma_empty_queue" , test_lsi_do_dma_empty_queue);tests/qtest/rtl8139-test.c +3
-2@@ -207,9 +207,10 @@ int main(int argc, char **argv) verbosity_level =atoi (v_env); } -qtest_start ("-device rtl8139" ); -g_test_init (&argc, &argv,NULL ); + +qtest_start ("-device rtl8139" ); +qtest_add_func ("/rtl8139/nop" , nop);qtest_add_func ("/rtl8139/timer" , test_init);Signature · 1 line
2.39.2
Quoted 7 lines · Richard W.M. Jones
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST beTAP version <int>. Assuming version 12.
Quoted 5 lines
This can be fixed by ensuring we always call
g_test_initfirst in the body of main.Thanks: Daniel Berrange, for diagnosing the problem
Signed-off-by Richard W.M. Jones <[email protected]>
Quoted 10 lines · Richard W.M. Jones
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST beTAP version <int>. Assuming version 12.This can be fixed by ensuring we always call
g_test_initfirst in the body of main.
Quoted 6 lines
Thanks: Daniel Berrange, for diagnosing the problem
Signed-off-by Richard W.M. Jones <[email protected]>--- tests/qtest/fuzz-lsi53c895a-test.c | 4 ++-- tests/qtest/rtl8139-test.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
Thanks for tackling this!
Quoted 7 lines · Richard W.M. Jones
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST beTAP version <int>. Assuming version 12.
Quoted 5 lines
This can be fixed by ensuring we always call
g_test_initfirst in the body of main.Thanks: Daniel Berrange, for diagnosing the problem
Signed-off-by Richard W.M. Jones <[email protected]>
Queued to testing/next, thanks.
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 22 lines · Richard W.M. Jones
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST beTAP version <int>. Assuming version 12.This can be fixed by ensuring we always call
g_test_initfirst in the body of main.Thanks: Daniel Berrange, for diagnosing the problem
Signed-off-by Richard W.M. Jones <[email protected]>--- tests/qtest/fuzz-lsi53c895a-test.c | 4 ++-- tests/qtest/rtl8139-test.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)tests/qtest/fuzz-lsi53c895a-test.c +0
-0
tests/qtest/fuzz-lsi53c895a-test.c static void test_lsi_do_dma_empty_queue(void) · line 118
Quoted 7 lines
tests/qtest/fuzz-lsi53c895a-test.c +2
-0@@ -112,12 +112,12 @@ static void test_lsi_do_dma_empty_queue(void)int main (int argc,char **argv) { +g_test_init (&argc, &argv,NULL ); +if (!qtest_has_device ("lsi53c895a" )) {return 0 ;
Could you please double-check that the !lsi53c895a case works fine, too? (just temporarily change it into a "if (1) { ..." statement) ... I'm a little bit afraid that the TAP protocol might be incomplete without the g_test_run() at the end otherwise. If so, you might now need a "goto out" instead of the "return 0" here...
Thomas
Quoted 3 lines
tests/qtest/fuzz-lsi53c895a-test.c +0
-1} -g_test_init (&argc, &argv,NULL );
Quoted 27 lines · Thomas Huth
Quoted 26 lines · Richard W.M. Jones
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST beTAP version <int>. Assuming version 12.This can be fixed by ensuring we always call
g_test_initfirst in the body of main.Thanks: Daniel Berrange, for diagnosing the problem
Signed-off-by Richard W.M. Jones <[email protected]>--- tests/qtest/fuzz-lsi53c895a-test.c | 4 ++-- tests/qtest/rtl8139-test.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)tests/qtest/fuzz-lsi53c895a-test.c +2
-0@@ -112,12 +112,12 @@ static void test_lsi_do_dma_empty_queue(void)int main (int argc,char **argv) { +g_test_init (&argc, &argv,NULL ); +
Quoted 8 lines
tests/qtest/fuzz-lsi53c895a-test.c static void test_lsi_do_dma_empty_queue(void) · line 117
Quoted 2 lines
tests/qtest/fuzz-lsi53c895a-test.c +0
-0if (!qtest_has_device ("lsi53c895a" )) {return 0 ;Could you please double-check that the !lsi53c895a case works fine, too? (just temporarily change it into a "if (1) { ..." statement) ... I'm a little bit afraid that the TAP protocol might be incomplete without the
g_test_run()at the end otherwise. If so, you might now need a "goto out" instead of the "return 0" here...
Applying ...
tests/qtest/fuzz-lsi53c895a-test.c +1 -1
@@ -114,7 +114,7 @@ int main(int argc, char **argv) {g_test_init (&argc, &argv,NULL ); -if (!qtest_has_device ("lsi53c895a" )) { +if (1 ) {return 0 ; }
... and rerunning the tests, everything still passes.
The stdout of the test after this change is:
TAP version 13
# random seed: R02S1c1f371a09fbfdf0dd747f898d55fe97
but apparently this version of TAP doesn't care (perhaps because the number of tests "1..2" is never printed?)
Anyway it doesn't appear to be a problem.
glib2-2.75.3-4.fc39.x86_64
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Thomas Huth
Reviewed-byQuoted 56 lines · Richard W.M. Jones
Quoted 27 lines · Thomas Huth
Quoted 26 lines · Richard W.M. Jones
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST beTAP version <int>. Assuming version 12.This can be fixed by ensuring we always call
g_test_initfirst in the body of main.Thanks: Daniel Berrange, for diagnosing the problem
Signed-off-by Richard W.M. Jones <[email protected]>--- tests/qtest/fuzz-lsi53c895a-test.c | 4 ++-- tests/qtest/rtl8139-test.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)tests/qtest/fuzz-lsi53c895a-test.c +2
-0@@ -112,12 +112,12 @@ static void test_lsi_do_dma_empty_queue(void)int main (int argc,char **argv) { +g_test_init (&argc, &argv,NULL ); +Quoted 8 lines
tests/qtest/fuzz-lsi53c895a-test.c static void test_lsi_do_dma_empty_queue(void) · line 117
Quoted 2 lines
tests/qtest/fuzz-lsi53c895a-test.c +0
-0if (!qtest_has_device ("lsi53c895a" )) {return 0 ;Could you please double-check that the !lsi53c895a case works fine, too? (just temporarily change it into a "if (1) { ..." statement) ... I'm a little bit afraid that the TAP protocol might be incomplete without the
g_test_run()at the end otherwise. If so, you might now need a "goto out" instead of the "return 0" here...Applying ...
tests/qtest/fuzz-lsi53c895a-test.c +1
-1@@ -114,7 +114,7 @@ int main(int argc, char **argv) {g_test_init (&argc, &argv,NULL ); -if (!qtest_has_device ("lsi53c895a" )) { +if (1 ) {return 0 ; }... and rerunning the tests, everything still passes.
The stdout of the test after this change is:
Quoted 7 lines
TAP version 13
# random seed: R02S1c1f371a09fbfdf0dd747f898d55fe97but apparently this version of TAP doesn't care (perhaps because the number of tests "1..2" is never printed?)
Anyway it doesn't appear to be a problem.
Ok, thanks for checking! I just also checked https://testanything.org/tap-version-13-specification.html and it says "The plan is optional", so this should be fine.
Quoted 54 lines · Richard W.M. Jones
Quoted 27 lines · Thomas Huth
Quoted 26 lines · Richard W.M. Jones
These two tests were failing with this error:
stderr:
TAP parsing error: version number must be on the first line
[...]
Unknown TAP version. The first line MUST beTAP version <int>. Assuming version 12.This can be fixed by ensuring we always call
g_test_initfirst in the body of main.Thanks: Daniel Berrange, for diagnosing the problem
Signed-off-by Richard W.M. Jones <[email protected]>--- tests/qtest/fuzz-lsi53c895a-test.c | 4 ++-- tests/qtest/rtl8139-test.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)tests/qtest/fuzz-lsi53c895a-test.c +2
-0@@ -112,12 +112,12 @@ static void test_lsi_do_dma_empty_queue(void)int main (int argc,char **argv) { +g_test_init (&argc, &argv,NULL ); +Quoted 8 lines
tests/qtest/fuzz-lsi53c895a-test.c static void test_lsi_do_dma_empty_queue(void) · line 117
Quoted 2 lines
tests/qtest/fuzz-lsi53c895a-test.c +0
-0if (!qtest_has_device ("lsi53c895a" )) {return 0 ;Could you please double-check that the !lsi53c895a case works fine, too? (just temporarily change it into a "if (1) { ..." statement) ... I'm a little bit afraid that the TAP protocol might be incomplete without the
g_test_run()at the end otherwise. If so, you might now need a "goto out" instead of the "return 0" here...Applying ...
tests/qtest/fuzz-lsi53c895a-test.c +1
-1@@ -114,7 +114,7 @@ int main(int argc, char **argv) {g_test_init (&argc, &argv,NULL ); -if (!qtest_has_device ("lsi53c895a" )) { +if (1 ) {return 0 ; }... and rerunning the tests, everything still passes.
Quoted 7 lines
The stdout of the test after this change is:
TAP version 13
# random seed: R02S1c1f371a09fbfdf0dd747f898d55fe97but apparently this version of TAP doesn't care (perhaps because the number of tests "1..2" is never printed?)
Right, the number of tests cannot be printed by g_test_init as the tests haven't been registered yet. This will only get run in thue g_test_run.
I recall sometime in the past I believe we've seen problems with tests that exit without printing anything, but if that's a problem it would be pre-existing with this test case as written.
The TAP spec:
https://testanything.org/tap-version-13-specification.html
says the test plan (aka the '1..2' bit) is optional:
"The plan is optional but if there is a plan before the
test points it must be the first non-diagnostic line output by the test file."
So having merely the "TAP version 13" should be sufficient, but then earlier glib doesn't print this at all. As I say though, the existing test would already suffer from the problem if it mattered.
Quoted 1 line
Anyway it doesn't appear to be a problem.
Yep, I think we are probably ok.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|