#include "tests/qtest/libqtest.h"
#include "tests/qtest/libqos/virtio-net.h"
#include "fuzz.h"
-#include "fork_fuzz.h"
#include "qos_fuzz.h"
}
}
-static void virtio_net_fork_fuzz(QTestState *s,
- const unsigned char *Data, size_t Size)
-{
- if (fork() == 0) {
- virtio_net_fuzz_multi(s, Data, Size, false);
- flush_events(s);
- _Exit(0);
- } else {
- flush_events(s);
- wait(NULL);
- }
-}
-static void virtio_net_fork_fuzz_check_used(QTestState *s,
+static void virtio_net_fuzz_check_used(QTestState *s,
const unsigned char *Data, size_t Size)
{
- if (fork() == 0) {
- virtio_net_fuzz_multi(s, Data, Size, true);
- flush_events(s);
- _Exit(0);
- } else {
- flush_events(s);
- wait(NULL);
- }
+ virtio_net_fuzz_multi(s, Data, Size, true);
+ flush_events(s);
+ fuzz_reset(s);
}
static void virtio_net_pre_fuzz(QTestState *s)
{
qos_init_path(s);
- counter_shm_init();
}
static void *virtio_net_test_setup_socket(GString *cmd_line, void *arg)
return arg;
}
-static void *virtio_net_test_setup_user(GString *cmd_line, void *arg)
-{
- g_string_append_printf(cmd_line, " -netdev user,id=hs0 ");
- return arg;
-}
-
static void register_virtio_net_fuzz_targets(void)
{
- fuzz_add_qos_target(&(FuzzTarget){
- .name = "virtio-net-socket",
- .description = "Fuzz the virtio-net virtual queues. Fuzz incoming "
- "traffic using the socket backend",
- .pre_fuzz = &virtio_net_pre_fuzz,
- .fuzz = virtio_net_fork_fuzz,},
- "virtio-net",
- &(QOSGraphTestOptions){.before = virtio_net_test_setup_socket}
- );
fuzz_add_qos_target(&(FuzzTarget){
.name = "virtio-net-socket-check-used",
"descriptors to be used. Timeout may indicate improperly handled "
"input",
.pre_fuzz = &virtio_net_pre_fuzz,
- .fuzz = virtio_net_fork_fuzz_check_used,},
+ .fuzz = virtio_net_fuzz_check_used,},
"virtio-net",
&(QOSGraphTestOptions){.before = virtio_net_test_setup_socket}
);
- fuzz_add_qos_target(&(FuzzTarget){
- .name = "virtio-net-slirp",
- .description = "Fuzz the virtio-net virtual queues with the slirp "
- " backend. Warning: May result in network traffic emitted from the "
- " process. Run in an isolated network environment.",
- .pre_fuzz = &virtio_net_pre_fuzz,
- .fuzz = virtio_net_fork_fuzz,},
- "virtio-net",
- &(QOSGraphTestOptions){.before = virtio_net_test_setup_user}
- );
}
fuzz_target_init(register_virtio_net_fuzz_targets);