tests/qtest: Only run fuzz-tests when tested devices are available
v2 cover tests/qtest: Only run fuzz-tests when tested devices are available
Some tests/qtest/fuzz-test fail when the device tested is not available in the build. Fix this by only running the test when devices are available.
FWIW Alexander Bulekov suggested an improvement, putting each test in a directory named by the device tested. This series does not cover that.
Supersedes: <[email protected]>
Philippe Mathieu-Daudé (2):
tests/qtest: Only run fuzz-megasas-test if megasas device is available tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi is available
tests/qtest/fuzz-megasas-test.c | 49 +++++++++++++++++++ tests/qtest/fuzz-test.c | 76 ----------------------------- tests/qtest/fuzz-virtio-scsi-test.c | 75 ++++++++++++++++++++++++++++ MAINTAINERS | 2 + tests/qtest/meson.build | 5 +- 5 files changed, 130 insertions(+), 77 deletions(-) create mode 100644 tests/qtest/fuzz-megasas-test.c create mode 100644 tests/qtest/fuzz-virtio-scsi-test.c
Signature · 1 line
2.26.2
PATCH v2 1/2 tests/qtest: Only run fuzz-megasas-test if megasas device is available
This test fails when QEMU is built without the megasas device, restrict it to its availability.
--- tests/qtest/fuzz-megasas-test.c | 49 +++++++++++++++++++++++++++++++++ tests/qtest/fuzz-test.c | 25 ----------------- MAINTAINERS | 1 + tests/qtest/meson.build | 4 ++- 4 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 tests/qtest/fuzz-megasas-test.c
tests/qtest/fuzz-megasas-test.c new file +49 -0
@@ -0,0 +1,49 @@ +/* +* QTest fuzzer-generated testcase for megasas device +* +* Copyright (c) 2020 Li Qiang <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" + +#include "libqos/libqtest.h" + +/* +* This used to trigger the assert in scsi_dma_complete +* https://bugs.launchpad.net/qemu/+bug/1878263 +*/ +static void test_lp1878263_megasas_zero_iov_cnt (void ) +{ +QTestState *s; + + s =qtest_init ("-nographic -monitor none -serial none " +"-M q35 -device megasas -device scsi-cd,drive=null0 " +"-blockdev driver=null-co,read-zeroes=on,node-name=null0" ); +qtest_outl (s,0xcf8 ,0x80001818 ); +qtest_outl (s,0xcfc ,0xc101 ); +qtest_outl (s,0xcf8 ,0x8000181c ); +qtest_outl (s,0xcf8 ,0x80001804 ); +qtest_outw (s,0xcfc ,0x7 ); +qtest_outl (s,0xcf8 ,0x8000186a ); +qtest_writeb (s,0x14 ,0xfe ); +qtest_writeb (s,0x0 ,0x02 ); +qtest_outb (s,0xc1c0 ,0x17 ); +qtest_quit (s); +} + +int main (int argc,char **argv) +{ +const char *arch =qtest_get_arch (); + +g_test_init (&argc, &argv,NULL ); + +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qtest_add_func ("fuzz/test_lp1878263_megasas_zero_iov_cnt" , + test_lp1878263_megasas_zero_iov_cnt); + } + +return g_test_run (); +}
tests/qtest/fuzz-test.c +0 -25
@@ -11,29 +11,6 @@#include "libqos/libqtest.h" -/* -* This used to trigger the assert in scsi_dma_complete -* https://bugs.launchpad.net/qemu/+bug/1878263 -*/ -static void test_lp1878263_megasas_zero_iov_cnt (void ) -{ -QTestState *s; - - s =qtest_init ("-nographic -monitor none -serial none " -"-M q35 -device megasas -device scsi-cd,drive=null0 " -"-blockdev driver=null-co,read-zeroes=on,node-name=null0" ); -qtest_outl (s,0xcf8 ,0x80001818 ); -qtest_outl (s,0xcfc ,0xc101 ); -qtest_outl (s,0xcf8 ,0x8000181c ); -qtest_outl (s,0xcf8 ,0x80001804 ); -qtest_outw (s,0xcfc ,0x7 ); -qtest_outl (s,0xcf8 ,0x8000186a ); -qtest_writeb (s,0x14 ,0xfe ); -qtest_writeb (s,0x0 ,0x02 ); -qtest_outb (s,0xc1c0 ,0x17 ); -qtest_quit (s); -} -static void test_lp1878642_pci_bus_get_irq_level_assert (void ) {QTestState *s;
@@ -104,8 +81,6 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { -qtest_add_func ("fuzz/test_lp1878263_megasas_zero_iov_cnt" , - test_lp1878263_megasas_zero_iov_cnt);qtest_add_func ("fuzz/test_lp1878642_pci_bus_get_irq_level_assert" , test_lp1878642_pci_bus_get_irq_level_assert); qtest_add_func("fuzz/test_mmio_oob_from_memory_region_cache",
MAINTAINERS +1 -0
@@ -1925,6 +1925,7 @@ S: Supported F: hw/scsi/megasas.c F: hw/scsi/mfi.h F: tests/qtest/megasas-test.c +F: tests/qtest/fuzz-megasas-test.c Network packet abstractions M: Dmitry Fleytman <[email protected]>
tests/qtest/meson.build +3 -1
@@ -4,7 +4,9 @@ subdir_done() endif -qtests_generic = [ +qtests_generic = \ + (config_all_devices.has_key('CONFIG_MEGASAS_SCSI_PCI') ? ['fuzz-megasas-test'] : []) + \ + [ 'cdrom-test', 'device-introspect-test', 'machine-none-test',
Signature · 1 line
2.26.2
Re: [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available
Quoted 128 lines · Philippe Mathieu-Daudé
This test fails when QEMU is built without the megasas device, restrict it to its availability.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/qtest/fuzz-megasas-test.c | 49 +++++++++++++++++++++++++++++++++ tests/qtest/fuzz-test.c | 25 ----------------- MAINTAINERS | 1 + tests/qtest/meson.build | 4 ++- 4 files changed, 53 insertions(+), 26 deletions(-)create mode 100644
tests/qtest/fuzz-megasas-test.ctests/qtest/fuzz-megasas-test.c new file +49
-0@@ -0,0 +1,49 @@ +/* +* QTest fuzzer-generated testcase for megasas device +* +* Copyright (c) 2020 Li Qiang <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" + +#include "libqos/libqtest.h" + +/* +* This used to trigger the assert in scsi_dma_complete +* https://bugs.launchpad.net/qemu/+bug/1878263 +*/ +static void test_lp1878263_megasas_zero_iov_cnt (void ) +{ +QTestState *s; + + s =qtest_init ("-nographic -monitor none -serial none " +"-M q35 -device megasas -device scsi-cd,drive=null0 " +"-blockdev driver=null-co,read-zeroes=on,node-name=null0" ); +qtest_outl (s,0xcf8 ,0x80001818 ); +qtest_outl (s,0xcfc ,0xc101 ); +qtest_outl (s,0xcf8 ,0x8000181c ); +qtest_outl (s,0xcf8 ,0x80001804 ); +qtest_outw (s,0xcfc ,0x7 ); +qtest_outl (s,0xcf8 ,0x8000186a ); +qtest_writeb (s,0x14 ,0xfe ); +qtest_writeb (s,0x0 ,0x02 ); +qtest_outb (s,0xc1c0 ,0x17 ); +qtest_quit (s); +} + +int main (int argc,char **argv) +{ +const char *arch =qtest_get_arch (); + +g_test_init (&argc, &argv,NULL ); + +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qtest_add_func ("fuzz/test_lp1878263_megasas_zero_iov_cnt" , + test_lp1878263_megasas_zero_iov_cnt); + } + +return g_test_run (); +}tests/qtest/fuzz-test.c +0
-25@@ -11,29 +11,6 @@#include "libqos/libqtest.h" -/* -* This used to trigger the assert in scsi_dma_complete -* https://bugs.launchpad.net/qemu/+bug/1878263 -*/ -static void test_lp1878263_megasas_zero_iov_cnt (void ) -{ -QTestState *s; - - s =qtest_init ("-nographic -monitor none -serial none " -"-M q35 -device megasas -device scsi-cd,drive=null0 " -"-blockdev driver=null-co,read-zeroes=on,node-name=null0" ); -qtest_outl (s,0xcf8 ,0x80001818 ); -qtest_outl (s,0xcfc ,0xc101 ); -qtest_outl (s,0xcf8 ,0x8000181c ); -qtest_outl (s,0xcf8 ,0x80001804 ); -qtest_outw (s,0xcfc ,0x7 ); -qtest_outl (s,0xcf8 ,0x8000186a ); -qtest_writeb (s,0x14 ,0xfe ); -qtest_writeb (s,0x0 ,0x02 ); -qtest_outb (s,0xc1c0 ,0x17 ); -qtest_quit (s); -} -static void test_lp1878642_pci_bus_get_irq_level_assert (void ) {QTestState *s;@@ -104,8 +81,6 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { -qtest_add_func ("fuzz/test_lp1878263_megasas_zero_iov_cnt" , - test_lp1878263_megasas_zero_iov_cnt);qtest_add_func ("fuzz/test_lp1878642_pci_bus_get_irq_level_assert" , test_lp1878642_pci_bus_get_irq_level_assert); qtest_add_func("fuzz/test_mmio_oob_from_memory_region_cache",MAINTAINERS +1
-0@@ -1925,6 +1925,7 @@ S: Supported F: hw/scsi/megasas.c F: hw/scsi/mfi.h F: tests/qtest/megasas-test.c +F: tests/qtest/fuzz-megasas-test.c Network packet abstractions M: Dmitry Fleytman <[email protected]>tests/qtest/meson.build +0
-0
tests/qtest/meson.build line 12
Quoted 10 lines
tests/qtest/meson.build +3
-1@@ -4,7 +4,9 @@ subdir_done() endif -qtests_generic = [ +qtests_generic = \ + (config_all_devices.has_key('CONFIG_MEGASAS_SCSI_PCI') ? ['fuzz-megasas-test'] : []) + \ + [ 'cdrom-test', 'device-introspect-test', 'machine-none-test',
I assume Alexander will take this patch through his fuzzer branch now? Or shall I take it via the qtest branch?
Thomas
Re: [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available
Quoted 137 lines · Thomas Huth
Quoted 123 lines · Philippe Mathieu-Daudé
This test fails when QEMU is built without the megasas device, restrict it to its availability.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/qtest/fuzz-megasas-test.c | 49 +++++++++++++++++++++++++++++++++ tests/qtest/fuzz-test.c | 25 ----------------- MAINTAINERS | 1 + tests/qtest/meson.build | 4 ++- 4 files changed, 53 insertions(+), 26 deletions(-)create mode 100644
tests/qtest/fuzz-megasas-test.ctests/qtest/fuzz-megasas-test.c new file +49
-0@@ -0,0 +1,49 @@ +/* +* QTest fuzzer-generated testcase for megasas device +* +* Copyright (c) 2020 Li Qiang <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" + +#include "libqos/libqtest.h" + +/* +* This used to trigger the assert in scsi_dma_complete +* https://bugs.launchpad.net/qemu/+bug/1878263 +*/ +static void test_lp1878263_megasas_zero_iov_cnt (void ) +{ +QTestState *s; + + s =qtest_init ("-nographic -monitor none -serial none " +"-M q35 -device megasas -device scsi-cd,drive=null0 " +"-blockdev driver=null-co,read-zeroes=on,node-name=null0" ); +qtest_outl (s,0xcf8 ,0x80001818 ); +qtest_outl (s,0xcfc ,0xc101 ); +qtest_outl (s,0xcf8 ,0x8000181c ); +qtest_outl (s,0xcf8 ,0x80001804 ); +qtest_outw (s,0xcfc ,0x7 ); +qtest_outl (s,0xcf8 ,0x8000186a ); +qtest_writeb (s,0x14 ,0xfe ); +qtest_writeb (s,0x0 ,0x02 ); +qtest_outb (s,0xc1c0 ,0x17 ); +qtest_quit (s); +} + +int main (int argc,char **argv) +{ +const char *arch =qtest_get_arch (); + +g_test_init (&argc, &argv,NULL ); + +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qtest_add_func ("fuzz/test_lp1878263_megasas_zero_iov_cnt" , + test_lp1878263_megasas_zero_iov_cnt); + } + +return g_test_run (); +}tests/qtest/fuzz-test.c +0
-25@@ -11,29 +11,6 @@#include "libqos/libqtest.h" -/* -* This used to trigger the assert in scsi_dma_complete -* https://bugs.launchpad.net/qemu/+bug/1878263 -*/ -static void test_lp1878263_megasas_zero_iov_cnt (void ) -{ -QTestState *s; - - s =qtest_init ("-nographic -monitor none -serial none " -"-M q35 -device megasas -device scsi-cd,drive=null0 " -"-blockdev driver=null-co,read-zeroes=on,node-name=null0" ); -qtest_outl (s,0xcf8 ,0x80001818 ); -qtest_outl (s,0xcfc ,0xc101 ); -qtest_outl (s,0xcf8 ,0x8000181c ); -qtest_outl (s,0xcf8 ,0x80001804 ); -qtest_outw (s,0xcfc ,0x7 ); -qtest_outl (s,0xcf8 ,0x8000186a ); -qtest_writeb (s,0x14 ,0xfe ); -qtest_writeb (s,0x0 ,0x02 ); -qtest_outb (s,0xc1c0 ,0x17 ); -qtest_quit (s); -} -static void test_lp1878642_pci_bus_get_irq_level_assert (void ) {QTestState *s;@@ -104,8 +81,6 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { -qtest_add_func ("fuzz/test_lp1878263_megasas_zero_iov_cnt" , - test_lp1878263_megasas_zero_iov_cnt);qtest_add_func ("fuzz/test_lp1878642_pci_bus_get_irq_level_assert" , test_lp1878642_pci_bus_get_irq_level_assert); qtest_add_func("fuzz/test_mmio_oob_from_memory_region_cache",MAINTAINERS +1
-0@@ -1925,6 +1925,7 @@ S: Supported F: hw/scsi/megasas.c F: hw/scsi/mfi.h F: tests/qtest/megasas-test.c +F: tests/qtest/fuzz-megasas-test.c Network packet abstractions M: Dmitry Fleytman <[email protected]>tests/qtest/meson.build +0
-0tests/qtest/meson.build line 12
Quoted 10 lines
tests/qtest/meson.build +3
-1@@ -4,7 +4,9 @@ subdir_done() endif -qtests_generic = [ +qtests_generic = \ + (config_all_devices.has_key('CONFIG_MEGASAS_SCSI_PCI') ? ['fuzz-megasas-test'] : []) + \ + [ 'cdrom-test', 'device-introspect-test', 'machine-none-test',Reviewed-by Thomas Huth <[email protected]>
Quoted 2 lines
I assume Alexander will take this patch through his fuzzer branch now? Or shall I take it via the qtest branch?
I can take take this through my branch, unless thats somehow inconvenient. -Alex
Quoted 2 lines
Thomas
Re: [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available
Quoted 138 lines · Alexander Bulekov
Quoted 137 lines · Thomas Huth
Quoted 123 lines · Philippe Mathieu-Daudé
This test fails when QEMU is built without the megasas device, restrict it to its availability.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/qtest/fuzz-megasas-test.c | 49 +++++++++++++++++++++++++++++++++ tests/qtest/fuzz-test.c | 25 ----------------- MAINTAINERS | 1 + tests/qtest/meson.build | 4 ++- 4 files changed, 53 insertions(+), 26 deletions(-)create mode 100644
tests/qtest/fuzz-megasas-test.ctests/qtest/fuzz-megasas-test.c new file +49
-0@@ -0,0 +1,49 @@ +/* +* QTest fuzzer-generated testcase for megasas device +* +* Copyright (c) 2020 Li Qiang <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" + +#include "libqos/libqtest.h" + +/* +* This used to trigger the assert in scsi_dma_complete +* https://bugs.launchpad.net/qemu/+bug/1878263 +*/ +static void test_lp1878263_megasas_zero_iov_cnt (void ) +{ +QTestState *s; + + s =qtest_init ("-nographic -monitor none -serial none " +"-M q35 -device megasas -device scsi-cd,drive=null0 " +"-blockdev driver=null-co,read-zeroes=on,node-name=null0" ); +qtest_outl (s,0xcf8 ,0x80001818 ); +qtest_outl (s,0xcfc ,0xc101 ); +qtest_outl (s,0xcf8 ,0x8000181c ); +qtest_outl (s,0xcf8 ,0x80001804 ); +qtest_outw (s,0xcfc ,0x7 ); +qtest_outl (s,0xcf8 ,0x8000186a ); +qtest_writeb (s,0x14 ,0xfe ); +qtest_writeb (s,0x0 ,0x02 ); +qtest_outb (s,0xc1c0 ,0x17 ); +qtest_quit (s); +} + +int main (int argc,char **argv) +{ +const char *arch =qtest_get_arch (); + +g_test_init (&argc, &argv,NULL ); + +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qtest_add_func ("fuzz/test_lp1878263_megasas_zero_iov_cnt" , + test_lp1878263_megasas_zero_iov_cnt); + } + +return g_test_run (); +}tests/qtest/fuzz-test.c +0
-25@@ -11,29 +11,6 @@#include "libqos/libqtest.h" -/* -* This used to trigger the assert in scsi_dma_complete -* https://bugs.launchpad.net/qemu/+bug/1878263 -*/ -static void test_lp1878263_megasas_zero_iov_cnt (void ) -{ -QTestState *s; - - s =qtest_init ("-nographic -monitor none -serial none " -"-M q35 -device megasas -device scsi-cd,drive=null0 " -"-blockdev driver=null-co,read-zeroes=on,node-name=null0" ); -qtest_outl (s,0xcf8 ,0x80001818 ); -qtest_outl (s,0xcfc ,0xc101 ); -qtest_outl (s,0xcf8 ,0x8000181c ); -qtest_outl (s,0xcf8 ,0x80001804 ); -qtest_outw (s,0xcfc ,0x7 ); -qtest_outl (s,0xcf8 ,0x8000186a ); -qtest_writeb (s,0x14 ,0xfe ); -qtest_writeb (s,0x0 ,0x02 ); -qtest_outb (s,0xc1c0 ,0x17 ); -qtest_quit (s); -} -static void test_lp1878642_pci_bus_get_irq_level_assert (void ) {QTestState *s;@@ -104,8 +81,6 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { -qtest_add_func ("fuzz/test_lp1878263_megasas_zero_iov_cnt" , - test_lp1878263_megasas_zero_iov_cnt);qtest_add_func ("fuzz/test_lp1878642_pci_bus_get_irq_level_assert" , test_lp1878642_pci_bus_get_irq_level_assert); qtest_add_func("fuzz/test_mmio_oob_from_memory_region_cache",MAINTAINERS +1
-0@@ -1925,6 +1925,7 @@ S: Supported F: hw/scsi/megasas.c F: hw/scsi/mfi.h F: tests/qtest/megasas-test.c +F: tests/qtest/fuzz-megasas-test.c Network packet abstractions M: Dmitry Fleytman <[email protected]>tests/qtest/meson.build +0
-0tests/qtest/meson.build line 12
Quoted 10 lines
tests/qtest/meson.build +3
-1@@ -4,7 +4,9 @@ subdir_done() endif -qtests_generic = [ +qtests_generic = \ + (config_all_devices.has_key('CONFIG_MEGASAS_SCSI_PCI') ? ['fuzz-megasas-test'] : []) + \ + [ 'cdrom-test', 'device-introspect-test', 'machine-none-test',Reviewed-by Thomas Huth <[email protected]>
Quoted 4 lines
Quoted 2 lines
I assume Alexander will take this patch through his fuzzer branch now? Or shall I take it via the qtest branch?
I can take take this through my branch, unless thats somehow inconvenient.
That's perfectly fine!
Thanks,
Thomas
PATCH v2 2/2 tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi is available
In reply to Philippe Mathieu-DaudéThis test fails when QEMU is built without the virtio-scsi device, restrict it to its availability.
--- tests/qtest/fuzz-test.c | 51 -------------------- tests/qtest/fuzz-virtio-scsi-test.c | 75 +++++++++++++++++++++++++++++ MAINTAINERS | 1 + tests/qtest/meson.build | 1 + 4 files changed, 77 insertions(+), 51 deletions(-) create mode 100644 tests/qtest/fuzz-virtio-scsi-test.c
tests/qtest/fuzz-test.c +0 -51
@@ -25,55 +25,6 @@ static void test_lp1878642_pci_bus_get_irq_level_assert(void)qtest_quit (s); } -/* -* Here a MemoryRegionCache pointed to an MMIO region but had a -* larger size than the underlying region. -*/ -static void test_mmio_oob_from_memory_region_cache (void ) -{ -QTestState *s; - - s =qtest_init ("-M pc-q35-5.2 -display none -m 512M " -"-device virtio-scsi,num_queues=8,addr=03.0 " ); - -qtest_outl (s,0xcf8 ,0x80001811 ); -qtest_outb (s,0xcfc ,0x6e ); -qtest_outl (s,0xcf8 ,0x80001824 ); -qtest_outl (s,0xcf8 ,0x80001813 ); -qtest_outl (s,0xcfc ,0xa080000 ); -qtest_outl (s,0xcf8 ,0x80001802 ); -qtest_outl (s,0xcfc ,0x5a175a63 ); -qtest_outb (s,0x6e08 ,0x9e ); -qtest_writeb (s,0x9f003 ,0xff ); -qtest_writeb (s,0x9f004 ,0x01 ); -qtest_writeb (s,0x9e012 ,0x0e ); -qtest_writeb (s,0x9e01b ,0x0e ); -qtest_writeb (s,0x9f006 ,0x01 ); -qtest_writeb (s,0x9f008 ,0x01 ); -qtest_writeb (s,0x9f00a ,0x01 ); -qtest_writeb (s,0x9f00c ,0x01 ); -qtest_writeb (s,0x9f00e ,0x01 ); -qtest_writeb (s,0x9f010 ,0x01 ); -qtest_writeb (s,0x9f012 ,0x01 ); -qtest_writeb (s,0x9f014 ,0x01 ); -qtest_writeb (s,0x9f016 ,0x01 ); -qtest_writeb (s,0x9f018 ,0x01 ); -qtest_writeb (s,0x9f01a ,0x01 ); -qtest_writeb (s,0x9f01c ,0x01 ); -qtest_writeb (s,0x9f01e ,0x01 ); -qtest_writeb (s,0x9f020 ,0x01 ); -qtest_writeb (s,0x9f022 ,0x01 ); -qtest_writeb (s,0x9f024 ,0x01 ); -qtest_writeb (s,0x9f026 ,0x01 ); -qtest_writeb (s,0x9f028 ,0x01 ); -qtest_writeb (s,0x9f02a ,0x01 ); -qtest_writeb (s,0x9f02c ,0x01 ); -qtest_writeb (s,0x9f02e ,0x01 ); -qtest_writeb (s,0x9f030 ,0x01 ); -qtest_outb (s,0x6e10 ,0x00 ); -qtest_quit (s); -} -int main (int argc,char **argv) {const char *arch =qtest_get_arch ();
@@ -83,8 +34,6 @@ int main(int argc, char **argv)if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) {qtest_add_func ("fuzz/test_lp1878642_pci_bus_get_irq_level_assert" , test_lp1878642_pci_bus_get_irq_level_assert); -qtest_add_func ("fuzz/test_mmio_oob_from_memory_region_cache" , - test_mmio_oob_from_memory_region_cache); }return g_test_run ();
tests/qtest/fuzz-virtio-scsi-test.c new file +75 -0
75 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -1717,6 +1717,7 @@ S: Supported F: include/hw/scsi/* F: hw/scsi/* F: tests/qtest/virtio-scsi-test.c +F: tests/qtest/fuzz-virtio-scsi-test.c T: git https://github.com/bonzini/qemu.git scsi-next SSI
tests/qtest/meson.build +1 -0
@@ -6,6 +6,7 @@ qtests_generic = \ (config_all_devices.has_key('CONFIG_MEGASAS_SCSI_PCI') ? ['fuzz-megasas-test'] : []) + \ + (config_all_devices.has_key('CONFIG_VIRTIO_SCSI') ? ['fuzz-virtio-scsi-test'] : []) + \ [ 'cdrom-test', 'device-introspect-test',
Signature · 1 line
2.26.2
Re: [PATCH v2 2/2] tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi is available
Quoted 181 lines · Philippe Mathieu-Daudé
This test fails when QEMU is built without the virtio-scsi device, restrict it to its availability.
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/qtest/fuzz-test.c | 51 -------------------- tests/qtest/fuzz-virtio-scsi-test.c | 75 +++++++++++++++++++++++++++++ MAINTAINERS | 1 + tests/qtest/meson.build | 1 + 4 files changed, 77 insertions(+), 51 deletions(-)create mode 100644
tests/qtest/fuzz-virtio-scsi-test.ctests/qtest/fuzz-test.c +0
-51@@ -25,55 +25,6 @@ static void test_lp1878642_pci_bus_get_irq_level_assert(void)qtest_quit (s); } -/* -* Here a MemoryRegionCache pointed to an MMIO region but had a -* larger size than the underlying region. -*/ -static void test_mmio_oob_from_memory_region_cache (void ) -{ -QTestState *s; - - s =qtest_init ("-M pc-q35-5.2 -display none -m 512M " -"-device virtio-scsi,num_queues=8,addr=03.0 " ); - -qtest_outl (s,0xcf8 ,0x80001811 ); -qtest_outb (s,0xcfc ,0x6e ); -qtest_outl (s,0xcf8 ,0x80001824 ); -qtest_outl (s,0xcf8 ,0x80001813 ); -qtest_outl (s,0xcfc ,0xa080000 ); -qtest_outl (s,0xcf8 ,0x80001802 ); -qtest_outl (s,0xcfc ,0x5a175a63 ); -qtest_outb (s,0x6e08 ,0x9e ); -qtest_writeb (s,0x9f003 ,0xff ); -qtest_writeb (s,0x9f004 ,0x01 ); -qtest_writeb (s,0x9e012 ,0x0e ); -qtest_writeb (s,0x9e01b ,0x0e ); -qtest_writeb (s,0x9f006 ,0x01 ); -qtest_writeb (s,0x9f008 ,0x01 ); -qtest_writeb (s,0x9f00a ,0x01 ); -qtest_writeb (s,0x9f00c ,0x01 ); -qtest_writeb (s,0x9f00e ,0x01 ); -qtest_writeb (s,0x9f010 ,0x01 ); -qtest_writeb (s,0x9f012 ,0x01 ); -qtest_writeb (s,0x9f014 ,0x01 ); -qtest_writeb (s,0x9f016 ,0x01 ); -qtest_writeb (s,0x9f018 ,0x01 ); -qtest_writeb (s,0x9f01a ,0x01 ); -qtest_writeb (s,0x9f01c ,0x01 ); -qtest_writeb (s,0x9f01e ,0x01 ); -qtest_writeb (s,0x9f020 ,0x01 ); -qtest_writeb (s,0x9f022 ,0x01 ); -qtest_writeb (s,0x9f024 ,0x01 ); -qtest_writeb (s,0x9f026 ,0x01 ); -qtest_writeb (s,0x9f028 ,0x01 ); -qtest_writeb (s,0x9f02a ,0x01 ); -qtest_writeb (s,0x9f02c ,0x01 ); -qtest_writeb (s,0x9f02e ,0x01 ); -qtest_writeb (s,0x9f030 ,0x01 ); -qtest_outb (s,0x6e10 ,0x00 ); -qtest_quit (s); -} -int main (int argc,char **argv) {const char *arch =qtest_get_arch ();@@ -83,8 +34,6 @@ int main(int argc, char **argv)if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) {qtest_add_func ("fuzz/test_lp1878642_pci_bus_get_irq_level_assert" , test_lp1878642_pci_bus_get_irq_level_assert); -qtest_add_func ("fuzz/test_mmio_oob_from_memory_region_cache" , - test_mmio_oob_from_memory_region_cache); }return g_test_run ();tests/qtest/fuzz-virtio-scsi-test.c new file +75
-0@@ -0,0 +1,75 @@ +/* +* QTest fuzzer-generated testcase for virtio-scsi device +* +* Copyright (c) 2020 Li Qiang <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" + +#include "libqos/libqtest.h" + +/* +* Here a MemoryRegionCache pointed to an MMIO region but had a +* larger size than the underlying region. +*/ +static void test_mmio_oob_from_memory_region_cache (void ) +{ +QTestState *s; + + s =qtest_init ("-M pc-q35-5.2 -display none -m 512M " +"-device virtio-scsi,num_queues=8,addr=03.0 " ); + +qtest_outl (s,0xcf8 ,0x80001811 ); +qtest_outb (s,0xcfc ,0x6e ); +qtest_outl (s,0xcf8 ,0x80001824 ); +qtest_outl (s,0xcf8 ,0x80001813 ); +qtest_outl (s,0xcfc ,0xa080000 ); +qtest_outl (s,0xcf8 ,0x80001802 ); +qtest_outl (s,0xcfc ,0x5a175a63 ); +qtest_outb (s,0x6e08 ,0x9e ); +qtest_writeb (s,0x9f003 ,0xff ); +qtest_writeb (s,0x9f004 ,0x01 ); +qtest_writeb (s,0x9e012 ,0x0e ); +qtest_writeb (s,0x9e01b ,0x0e ); +qtest_writeb (s,0x9f006 ,0x01 ); +qtest_writeb (s,0x9f008 ,0x01 ); +qtest_writeb (s,0x9f00a ,0x01 ); +qtest_writeb (s,0x9f00c ,0x01 ); +qtest_writeb (s,0x9f00e ,0x01 ); +qtest_writeb (s,0x9f010 ,0x01 ); +qtest_writeb (s,0x9f012 ,0x01 ); +qtest_writeb (s,0x9f014 ,0x01 ); +qtest_writeb (s,0x9f016 ,0x01 ); +qtest_writeb (s,0x9f018 ,0x01 ); +qtest_writeb (s,0x9f01a ,0x01 ); +qtest_writeb (s,0x9f01c ,0x01 ); +qtest_writeb (s,0x9f01e ,0x01 ); +qtest_writeb (s,0x9f020 ,0x01 ); +qtest_writeb (s,0x9f022 ,0x01 ); +qtest_writeb (s,0x9f024 ,0x01 ); +qtest_writeb (s,0x9f026 ,0x01 ); +qtest_writeb (s,0x9f028 ,0x01 ); +qtest_writeb (s,0x9f02a ,0x01 ); +qtest_writeb (s,0x9f02c ,0x01 ); +qtest_writeb (s,0x9f02e ,0x01 ); +qtest_writeb (s,0x9f030 ,0x01 ); +qtest_outb (s,0x6e10 ,0x00 ); +qtest_quit (s); +} + +int main (int argc,char **argv) +{ +const char *arch =qtest_get_arch (); + +g_test_init (&argc, &argv,NULL ); + +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qtest_add_func ("fuzz/test_mmio_oob_from_memory_region_cache" , + test_mmio_oob_from_memory_region_cache); + } + +return g_test_run (); +}MAINTAINERS +1
-0@@ -1717,6 +1717,7 @@ S: Supported F: include/hw/scsi/* F: hw/scsi/* F: tests/qtest/virtio-scsi-test.c +F: tests/qtest/fuzz-virtio-scsi-test.c T: git https://github.com/bonzini/qemu.git scsi-next SSItests/qtest/meson.build +0
-0
tests/qtest/meson.build line 12
Quoted 7 lines
tests/qtest/meson.build +1
-0@@ -6,6 +6,7 @@ qtests_generic = \ (config_all_devices.has_key('CONFIG_MEGASAS_SCSI_PCI') ? ['fuzz-megasas-test'] : []) + \ + (config_all_devices.has_key('CONFIG_VIRTIO_SCSI') ? ['fuzz-virtio-scsi-test'] : []) + \ [ 'cdrom-test', 'device-introspect-test',
Quoted 3 lines · Philippe Mathieu-Daudé
Some tests/qtest/fuzz-test fail when the device tested is not available in the build. Fix this by only running the test when devices are available.
Forgot, since v1:
- Do not make the testing generic, keep it restricted to x86 (thuth)
Quoted 9 lines
FWIW Alexander Bulekov suggested an improvement, putting each test in a directory named by the device tested. This series does not cover that.
Supersedes: <[email protected]>
Philippe Mathieu-Daudé (2):
tests/qtest: Only run fuzz-megasas-test if megasas device is available tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi is available
[PATCH v2 3/2] MAINTAINERS: Cover fuzzer reproducer tests within 'Device Fuzzing'
In reply to Philippe Mathieu-DaudéWhen we started to commit the fuzzer QTest reproducers to fuzz-test.c in commit d8dd1095019 ("qtest: add fuzz test case"), we forgot to add the corresponding MAINTAINERS entry. Do it now.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -2571,6 +2571,7 @@ R: Stefan Hajnoczi <[email protected]> R: Thomas Huth <[email protected]> S: Maintained F: tests/qtest/fuzz/ +F: tests/qtest/fuzz-*test.c F: scripts/oss-fuzz/ F: docs/devel/fuzzing.rst
Signature · 1 line
2.26.2
Thomas Huth
Reviewed-byRe: [PATCH v2 3/2] MAINTAINERS: Cover fuzzer reproducer tests within 'Device Fuzzing'
Quoted 14 lines · Philippe Mathieu-Daudé
When we started to commit the fuzzer QTest reproducers to
fuzz-test.cin commitd8dd1095019("qtest: add fuzz test case"), we forgot to add the correspondingMAINTAINERSentry. Do it now.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)MAINTAINERS +0
-0
MAINTAINERS R: Stefan Hajnoczi <[email protected]> · line 2576
Quoted 6 lines
MAINTAINERS +1
-0@@ -2571,6 +2571,7 @@ R: Stefan Hajnoczi <[email protected]> R: Thomas Huth <[email protected]> S: Maintained F: tests/qtest/fuzz/ +F: tests/qtest/fuzz-*test.c F: scripts/oss-fuzz/ F: docs/devel/fuzzing.rst