tests: introduce basic pci test for virtio-net
PATCH v3 1/2 tests: introduce basic pci test for virtio-net
---
Changes from V2:
- Remove duplicated code of gtest_start()
Changes from V1:
- replace the magic value 12 with a macro
--- tests/Makefile | 2 +- tests/virtio-net-test.c | 185 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 179 insertions(+), 8 deletions(-)
tests/Makefile +1 -1
@@ -381,7 +381,7 @@ tests/wdt_ib700-test$(EXESUF): tests/wdt_ib700-test.o tests/tco-test$(EXESUF): tests/tco-test.o $(libqos-pc-obj-y) tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o $(libqos-virtio-obj-y) -tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o $(libqos-pc-obj-y) +tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o $(libqos-pc-obj-y) $(libqos-virtio-obj-y) tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o $(libqos-pc-obj-y) tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o $(libqos-virtio-obj-y) tests/virtio-9p-test$(EXESUF): tests/virtio-9p-test.o
tests/virtio-net-test.c +178 -7
211 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v3 2/2 tests: test rx recovery from cont
Rx should be recovered after cont.
---
Changes from V2:
- really query status before "cont"
Changes from V1:
- query status before sending cont, this makes sure that the packet were queued.
--- tests/virtio-net-test.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
tests/virtio-net-test.c +52 -0
@@ -140,6 +140,49 @@ static void tx_test(const QVirtioBus *bus, QVirtioDevice *dev, g_assert_cmpstr(buffer, ==, "TEST"); } +static void rx_stop_cont_test (const QVirtioBus *bus,QVirtioDevice *dev, +QGuestAllocator *alloc,QVirtQueue *vq, +int socket) +{ +uint64_t req_addr; +uint32_t free_head; +char test[] ="TEST" ; +char buffer[64 ]; +int len =htonl (sizeof (test)); +struct iovec iov[] = { + { + .iov_base = &len, + .iov_len =sizeof (len), + }, { + .iov_base = test, + .iov_len =sizeof (test), + }, + }; +int ret; + + req_addr =guest_alloc (alloc,64 ); + + free_head =qvirtqueue_add (vq, req_addr,64 , true, false); +qvirtqueue_kick (bus, dev, vq, free_head); + +qmp ("{ 'execute' : 'stop'}" ); + + ret =iov_send (socket, iov,2 ,0 ,sizeof (len) +sizeof (test)); + g_assert_cmpint(ret, ==, sizeof(test) + sizeof(len)); + +/* We could check the status, but this command is more importantly to +* ensure the packet data gets queued in QEMU, before we do 'cont'. +*/ +qmp ("{ 'execute' : 'query-status'}" ); +qmp ("{ 'execute' : 'cont'}" ); + +qvirtio_wait_queue_isr (bus, dev, vq,QVIRTIO_NET_TIMEOUT_US ); +memread (req_addr +VNET_HDR_SIZE , buffer,sizeof (test)); + g_assert_cmpstr(buffer, ==, "TEST"); + +guest_free (alloc, req_addr); +} +static void send_recv_test (const QVirtioBus *bus,QVirtioDevice *dev,QGuestAllocator *alloc,QVirtQueue *rvq,QVirtQueue *tvq,int socket)
@@ -148,6 +191,13 @@ static void send_recv_test(const QVirtioBus *bus, QVirtioDevice *dev,tx_test (bus, dev, alloc, tvq, socket); } +static void stop_cont_test (const QVirtioBus *bus,QVirtioDevice *dev, +QGuestAllocator *alloc,QVirtQueue *rvq, +QVirtQueue *tvq,int socket) +{ +rx_stop_cont_test (bus, dev, alloc, rvq, socket); +} +static void pci_basic (gconstpointer data) {QVirtioPCIDevice *dev;
@@ -205,6 +255,8 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );#ifndef _WIN32qtest_add_data_func ("/virtio/net/pci/basic" , send_recv_test, pci_basic); +qtest_add_data_func ("/virtio/net/pci/rx_stop_cont" , + stop_cont_test, pci_basic);#endif qtest_add_func ("/virtio/net/pci/hotplug" , hotplug);
Signature · 1 line
2.1.4
Quoted 6 lines · Jason Wang
Signed-off-by Jason Wang <[email protected]>---
Changes from V2:
- Remove duplicated code ofgtest_start()
Changes from V1:
- replace the magic value 12 with a macro
Series:
Stefan Hajnoczi
AppliedQuoted 10 lines · Jason Wang
Signed-off-by Jason Wang <[email protected]>---
Changes from V2:
- Remove duplicated code ofgtest_start()
Changes from V1:
- replace the magic value 12 with a macro--- tests/Makefile | 2 +- tests/virtio-net-test.c | 185 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 179 insertions(+), 8 deletions(-)
Thanks, applied to my net-next tree:
https://github.com/stefanha/qemu/commits/net-next
Stefan