All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available
@ 2021-01-26 11:16 Philippe Mathieu-Daudé
  2021-01-26 11:16 ` [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-26 11:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Laurent Vivier, Hannes Reinecke, qemu-block,
	Thomas Huth, Paolo Bonzini, 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.

FWIW Alexander Bulekov suggested an improvement, putting each
test in a directory named by the device tested. This series
does not cover that.

Supersedes: <20210115150936.3333282-1-philmd@redhat.com>

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

-- 
2.26.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available
  2021-01-26 11:16 [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available Philippe Mathieu-Daudé
@ 2021-01-26 11:16 ` Philippe Mathieu-Daudé
  2021-01-26 17:51   ` Thomas Huth
  2021-01-26 11:16 ` [PATCH v2 2/2] tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi " Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-26 11:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Laurent Vivier, Hannes Reinecke, qemu-block,
	Thomas Huth, Paolo Bonzini, 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é <philmd@redhat.com>
---
 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

diff --git a/tests/qtest/fuzz-megasas-test.c b/tests/qtest/fuzz-megasas-test.c
new file mode 100644
index 00000000000..940a76bf25a
--- /dev/null
+++ b/tests/qtest/fuzz-megasas-test.c
@@ -0,0 +1,49 @@
+/*
+ * QTest fuzzer-generated testcase for megasas device
+ *
+ * Copyright (c) 2020 Li Qiang <liq3ea@gmail.com>
+ *
+ * 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();
+}
diff --git a/tests/qtest/fuzz-test.c b/tests/qtest/fuzz-test.c
index cdb1100a0b8..6188fbb8e96 100644
--- a/tests/qtest/fuzz-test.c
+++ b/tests/qtest/fuzz-test.c
@@ -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",
diff --git a/MAINTAINERS b/MAINTAINERS
index 34359a99b8e..44cd74b03cd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <dmitry.fleytman@gmail.com>
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 16d04625b8b..85682d0dfce 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -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',
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/2] tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi is available
  2021-01-26 11:16 [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available Philippe Mathieu-Daudé
  2021-01-26 11:16 ` [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available Philippe Mathieu-Daudé
@ 2021-01-26 11:16 ` Philippe Mathieu-Daudé
  2021-01-26 17:52   ` Thomas Huth
  2021-01-26 11:20 ` [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available Philippe Mathieu-Daudé
  2021-01-26 11:28 ` [PATCH v2 3/2] MAINTAINERS: Cover fuzzer reproducer tests within 'Device Fuzzing' Philippe Mathieu-Daudé
  3 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-26 11:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Laurent Vivier, Hannes Reinecke, qemu-block,
	Michael S . Tsirkin, Thomas Huth, Paolo Bonzini,
	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 <mst@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 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

diff --git a/tests/qtest/fuzz-test.c b/tests/qtest/fuzz-test.c
index 6188fbb8e96..d112798afe3 100644
--- a/tests/qtest/fuzz-test.c
+++ b/tests/qtest/fuzz-test.c
@@ -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();
diff --git a/tests/qtest/fuzz-virtio-scsi-test.c b/tests/qtest/fuzz-virtio-scsi-test.c
new file mode 100644
index 00000000000..aaf6d10e189
--- /dev/null
+++ b/tests/qtest/fuzz-virtio-scsi-test.c
@@ -0,0 +1,75 @@
+/*
+ * QTest fuzzer-generated testcase for virtio-scsi device
+ *
+ * Copyright (c) 2020 Li Qiang <liq3ea@gmail.com>
+ *
+ * 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();
+}
diff --git a/MAINTAINERS b/MAINTAINERS
index 44cd74b03cd..48c0ec41e93 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 85682d0dfce..f2090296597 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -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',
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available
  2021-01-26 11:16 [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available Philippe Mathieu-Daudé
  2021-01-26 11:16 ` [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available Philippe Mathieu-Daudé
  2021-01-26 11:16 ` [PATCH v2 2/2] tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi " Philippe Mathieu-Daudé
@ 2021-01-26 11:20 ` Philippe Mathieu-Daudé
  2021-01-26 11:28 ` [PATCH v2 3/2] MAINTAINERS: Cover fuzzer reproducer tests within 'Device Fuzzing' Philippe Mathieu-Daudé
  3 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-26 11:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Laurent Vivier, Hannes Reinecke, qemu-block,
	Thomas Huth, Paolo Bonzini

On 1/26/21 12:16 PM, Philippe Mathieu-Daudé wrote:
> 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)

> FWIW Alexander Bulekov suggested an improvement, putting each
> test in a directory named by the device tested. This series
> does not cover that.
> 
> Supersedes: <20210115150936.3333282-1-philmd@redhat.com>
> 
> 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



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 3/2] MAINTAINERS: Cover fuzzer reproducer tests within 'Device Fuzzing'
  2021-01-26 11:16 [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2021-01-26 11:20 ` [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available Philippe Mathieu-Daudé
@ 2021-01-26 11:28 ` Philippe Mathieu-Daudé
  2021-01-26 17:56   ` Thomas Huth
  3 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-26 11:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, Li Qiang, Alexander Bulekov, Bandan Das,
	Paolo Bonzini, 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.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index e275c81fd49..1b88753b325 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2571,6 +2571,7 @@ R: Stefan Hajnoczi <stefanha@redhat.com>
 R: Thomas Huth <thuth@redhat.com>
 S: Maintained
 F: tests/qtest/fuzz/
+F: tests/qtest/fuzz-*test.c
 F: scripts/oss-fuzz/
 F: docs/devel/fuzzing.rst
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available
  2021-01-26 11:16 ` [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available Philippe Mathieu-Daudé
@ 2021-01-26 17:51   ` Thomas Huth
  2021-01-26 18:01     ` Alexander Bulekov
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Huth @ 2021-01-26 17:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Alexander Bulekov
  Cc: Fam Zheng, Paolo Bonzini, Hannes Reinecke, Laurent Vivier, qemu-block

On 26/01/2021 12.16, Philippe Mathieu-Daudé wrote:
> This test fails when QEMU is built without the megasas device,
> restrict it to its availability.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   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
> 
> diff --git a/tests/qtest/fuzz-megasas-test.c b/tests/qtest/fuzz-megasas-test.c
> new file mode 100644
> index 00000000000..940a76bf25a
> --- /dev/null
> +++ b/tests/qtest/fuzz-megasas-test.c
> @@ -0,0 +1,49 @@
> +/*
> + * QTest fuzzer-generated testcase for megasas device
> + *
> + * Copyright (c) 2020 Li Qiang <liq3ea@gmail.com>
> + *
> + * 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();
> +}
> diff --git a/tests/qtest/fuzz-test.c b/tests/qtest/fuzz-test.c
> index cdb1100a0b8..6188fbb8e96 100644
> --- a/tests/qtest/fuzz-test.c
> +++ b/tests/qtest/fuzz-test.c
> @@ -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",
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 34359a99b8e..44cd74b03cd 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -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 <dmitry.fleytman@gmail.com>
> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> index 16d04625b8b..85682d0dfce 100644
> --- a/tests/qtest/meson.build
> +++ b/tests/qtest/meson.build
> @@ -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 <thuth@redhat.com>

I assume Alexander will take this patch through his fuzzer branch now? Or 
shall I take it via the qtest branch?

  Thomas



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi is available
  2021-01-26 11:16 ` [PATCH v2 2/2] tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi " Philippe Mathieu-Daudé
@ 2021-01-26 17:52   ` Thomas Huth
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2021-01-26 17:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Alexander Bulekov
  Cc: Fam Zheng, Laurent Vivier, Hannes Reinecke, qemu-block,
	Michael S . Tsirkin, Paolo Bonzini

On 26/01/2021 12.16, Philippe Mathieu-Daudé wrote:
> This test fails when QEMU is built without the virtio-scsi device,
> restrict it to its availability.
> 
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   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
> 
> diff --git a/tests/qtest/fuzz-test.c b/tests/qtest/fuzz-test.c
> index 6188fbb8e96..d112798afe3 100644
> --- a/tests/qtest/fuzz-test.c
> +++ b/tests/qtest/fuzz-test.c
> @@ -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();
> diff --git a/tests/qtest/fuzz-virtio-scsi-test.c b/tests/qtest/fuzz-virtio-scsi-test.c
> new file mode 100644
> index 00000000000..aaf6d10e189
> --- /dev/null
> +++ b/tests/qtest/fuzz-virtio-scsi-test.c
> @@ -0,0 +1,75 @@
> +/*
> + * QTest fuzzer-generated testcase for virtio-scsi device
> + *
> + * Copyright (c) 2020 Li Qiang <liq3ea@gmail.com>
> + *
> + * 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();
> +}
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 44cd74b03cd..48c0ec41e93 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -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
> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> index 85682d0dfce..f2090296597 100644
> --- a/tests/qtest/meson.build
> +++ b/tests/qtest/meson.build
> @@ -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',
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 3/2] MAINTAINERS: Cover fuzzer reproducer tests within 'Device Fuzzing'
  2021-01-26 11:28 ` [PATCH v2 3/2] MAINTAINERS: Cover fuzzer reproducer tests within 'Device Fuzzing' Philippe Mathieu-Daudé
@ 2021-01-26 17:56   ` Thomas Huth
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2021-01-26 17:56 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Alexander Bulekov, Bandan Das, Li Qiang, Paolo Bonzini

On 26/01/2021 12.28, Philippe Mathieu-Daudé wrote:
> 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.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   MAINTAINERS | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e275c81fd49..1b88753b325 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -2571,6 +2571,7 @@ R: Stefan Hajnoczi <stefanha@redhat.com>
>   R: Thomas Huth <thuth@redhat.com>
>   S: Maintained
>   F: tests/qtest/fuzz/
> +F: tests/qtest/fuzz-*test.c
>   F: scripts/oss-fuzz/
>   F: docs/devel/fuzzing.rst

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available
  2021-01-26 17:51   ` Thomas Huth
@ 2021-01-26 18:01     ` Alexander Bulekov
  2021-01-26 18:12       ` Thomas Huth
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Bulekov @ 2021-01-26 18:01 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Fam Zheng, Laurent Vivier, Hannes Reinecke, qemu-block,
	qemu-devel, Paolo Bonzini, Philippe Mathieu-Daudé

On 210126 1851, Thomas Huth wrote:
> On 26/01/2021 12.16, Philippe Mathieu-Daudé wrote:
> > This test fails when QEMU is built without the megasas device,
> > restrict it to its availability.
> > 
> > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > ---
> >   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
> > 
> > diff --git a/tests/qtest/fuzz-megasas-test.c b/tests/qtest/fuzz-megasas-test.c
> > new file mode 100644
> > index 00000000000..940a76bf25a
> > --- /dev/null
> > +++ b/tests/qtest/fuzz-megasas-test.c
> > @@ -0,0 +1,49 @@
> > +/*
> > + * QTest fuzzer-generated testcase for megasas device
> > + *
> > + * Copyright (c) 2020 Li Qiang <liq3ea@gmail.com>
> > + *
> > + * 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();
> > +}
> > diff --git a/tests/qtest/fuzz-test.c b/tests/qtest/fuzz-test.c
> > index cdb1100a0b8..6188fbb8e96 100644
> > --- a/tests/qtest/fuzz-test.c
> > +++ b/tests/qtest/fuzz-test.c
> > @@ -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",
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 34359a99b8e..44cd74b03cd 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -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 <dmitry.fleytman@gmail.com>
> > diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> > index 16d04625b8b..85682d0dfce 100644
> > --- a/tests/qtest/meson.build
> > +++ b/tests/qtest/meson.build
> > @@ -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 <thuth@redhat.com>
> 
> 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

>  Thomas
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available
  2021-01-26 18:01     ` Alexander Bulekov
@ 2021-01-26 18:12       ` Thomas Huth
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2021-01-26 18:12 UTC (permalink / raw)
  To: Alexander Bulekov
  Cc: Fam Zheng, Laurent Vivier, Hannes Reinecke, qemu-block,
	qemu-devel, Paolo Bonzini, Philippe Mathieu-Daudé

On 26/01/2021 19.01, Alexander Bulekov wrote:
> On 210126 1851, Thomas Huth wrote:
>> On 26/01/2021 12.16, Philippe Mathieu-Daudé wrote:
>>> This test fails when QEMU is built without the megasas device,
>>> restrict it to its availability.
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> ---
>>>    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
>>>
>>> diff --git a/tests/qtest/fuzz-megasas-test.c b/tests/qtest/fuzz-megasas-test.c
>>> new file mode 100644
>>> index 00000000000..940a76bf25a
>>> --- /dev/null
>>> +++ b/tests/qtest/fuzz-megasas-test.c
>>> @@ -0,0 +1,49 @@
>>> +/*
>>> + * QTest fuzzer-generated testcase for megasas device
>>> + *
>>> + * Copyright (c) 2020 Li Qiang <liq3ea@gmail.com>
>>> + *
>>> + * 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();
>>> +}
>>> diff --git a/tests/qtest/fuzz-test.c b/tests/qtest/fuzz-test.c
>>> index cdb1100a0b8..6188fbb8e96 100644
>>> --- a/tests/qtest/fuzz-test.c
>>> +++ b/tests/qtest/fuzz-test.c
>>> @@ -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",
>>> diff --git a/MAINTAINERS b/MAINTAINERS
>>> index 34359a99b8e..44cd74b03cd 100644
>>> --- a/MAINTAINERS
>>> +++ b/MAINTAINERS
>>> @@ -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 <dmitry.fleytman@gmail.com>
>>> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
>>> index 16d04625b8b..85682d0dfce 100644
>>> --- a/tests/qtest/meson.build
>>> +++ b/tests/qtest/meson.build
>>> @@ -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 <thuth@redhat.com>
>>
>> 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



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-01-26 18:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 11:16 [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available Philippe Mathieu-Daudé
2021-01-26 11:16 ` [PATCH v2 1/2] tests/qtest: Only run fuzz-megasas-test if megasas device is available Philippe Mathieu-Daudé
2021-01-26 17:51   ` Thomas Huth
2021-01-26 18:01     ` Alexander Bulekov
2021-01-26 18:12       ` Thomas Huth
2021-01-26 11:16 ` [PATCH v2 2/2] tests/qtest: Only run fuzz-virtio-scsi when virtio-scsi " Philippe Mathieu-Daudé
2021-01-26 17:52   ` Thomas Huth
2021-01-26 11:20 ` [PATCH v2 0/2] tests/qtest: Only run fuzz-tests when tested devices are available Philippe Mathieu-Daudé
2021-01-26 11:28 ` [PATCH v2 3/2] MAINTAINERS: Cover fuzzer reproducer tests within 'Device Fuzzing' Philippe Mathieu-Daudé
2021-01-26 17:56   ` Thomas Huth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.