diff mbox series

[RFC,11/19] fuzz: add direct send/receive in qtest client

Message ID 20190725032321.12721-12-alxndr@bu.edu (mailing list archive)
State New, archived
Headers show
Series Add virtual device fuzzing support | expand

Commit Message

Alexander Bulekov July 25, 2019, 3:23 a.m. UTC
Directly interact with tests/libqtest.c functions

Signed-off-by: Alexander Oleinik <alxndr@bu.edu>
---
 qtest.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Thomas Huth July 25, 2019, 9:10 a.m. UTC | #1
On 25/07/2019 05.23, Oleinik, Alexander wrote:
> Directly interact with tests/libqtest.c functions
> 
> Signed-off-by: Alexander Oleinik <alxndr@bu.edu>
> ---
>  qtest.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
[...]
> @@ -748,8 +755,11 @@ static void qtest_event(void *opaque, int event)
>          break;
>      }
>  }
> -
> +#ifdef CONFIG_FUZZ
> +void qtest_init_server(const char *qtest_chrdev, const char *qtest_log, Error **errp)
> +#else
>  void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)
> +#endif
>  {
>      Chardev *chr;

Even without your fuzzer series, it's somewhat confusing that we have a
qtest_init() function here that is completely different from the
qtest_init() function in tests/libqtest.c ...
Maybe you could send a separate patch that renames the qtest_init() here
always to qtest_init_server() and change the calling of the function in
vl.c, too?

 Thomas
diff mbox series

Patch

diff --git a/qtest.c b/qtest.c
index 15e27e911f..a6134d3ed0 100644
--- a/qtest.c
+++ b/qtest.c
@@ -31,6 +31,9 @@ 
 #ifdef TARGET_PPC64
 #include "hw/ppc/spapr_rtas.h"
 #endif
+#ifdef CONFIG_FUZZ
+#include "tests/libqtest.h"
+#endif
 
 #define MAX_IRQ 256
 
@@ -231,10 +234,14 @@  static void GCC_FMT_ATTR(1, 2) qtest_log_send(const char *fmt, ...)
 
 static void do_qtest_send(CharBackend *chr, const char *str, size_t len)
 {
+#ifdef CONFIG_FUZZ
+    qtest_client_recv(str, len);
+#else
     qemu_chr_fe_write_all(chr, (uint8_t *)str, len);
     if (qtest_log_fp && qtest_opened) {
         fprintf(qtest_log_fp, "%s", str);
     }
+#endif
 }
 
 static void qtest_send(CharBackend *chr, const char *str)
@@ -748,8 +755,11 @@  static void qtest_event(void *opaque, int event)
         break;
     }
 }
-
+#ifdef CONFIG_FUZZ
+void qtest_init_server(const char *qtest_chrdev, const char *qtest_log, Error **errp)
+#else
 void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)
+#endif
 {
     Chardev *chr;
 
@@ -781,3 +791,10 @@  bool qtest_driver(void)
 {
     return qtest_chr.chr != NULL;
 }
+#ifdef CONFIG_FUZZ
+void qtest_server_recv(GString *inbuf)
+{
+    qtest_process_inbuf(NULL, inbuf);
+}
+#endif
+