[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 12/17] net/announce: Expand test for stopping self an
From: |
Jason Wang |
Subject: |
[Qemu-devel] [PULL 12/17] net/announce: Expand test for stopping self announce |
Date: |
Tue, 2 Jul 2019 10:31:24 +0800 |
From: "Dr. David Alan Gilbert" <address@hidden>
Expand self-announce test to check we can stop an announce timer.
We set it up to send 300 packets, but after we receive
the first one we tell it to stop.
We error if:
a) We receive more than 30 of the packets
b) We're still receiving packets after a lot longer than the
30 seconds should have arrived
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
---
tests/virtio-net-test.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 54 insertions(+), 3 deletions(-)
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 663cf7e..7aa9622 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -184,21 +184,72 @@ static void announce_self(void *obj, void *data,
QGuestAllocator *t_alloc)
QDict *rsp;
int ret;
uint16_t *proto = (uint16_t *)&buffer[12];
+ size_t total_received = 0;
+ uint64_t start, now, last_rxt, deadline;
+ /* Send a set of packets over a few second period */
rsp = qmp("{ 'execute' : 'announce-self', "
" 'arguments': {"
- " 'initial': 50, 'max': 550,"
- " 'rounds': 10, 'step': 50 } }");
+ " 'initial': 20, 'max': 100,"
+ " 'rounds': 300, 'step': 10, 'id': 'bob' } }");
assert(!qdict_haskey(rsp, "error"));
qobject_unref(rsp);
- /* Catch the packet and make sure it's a RARP */
+ /* Catch the first packet and make sure it's a RARP */
ret = qemu_recv(sv[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
ret = qemu_recv(sv[0], buffer, len, 0);
g_assert_cmpint(*proto, ==, htons(ETH_P_RARP));
+
+ /*
+ * Stop the announcment by settings rounds to 0 on the
+ * existing timer.
+ */
+ rsp = qmp("{ 'execute' : 'announce-self', "
+ " 'arguments': {"
+ " 'initial': 20, 'max': 100,"
+ " 'rounds': 0, 'step': 10, 'id': 'bob' } }");
+ assert(!qdict_haskey(rsp, "error"));
+ qobject_unref(rsp);
+
+ /* Now make sure the packets stop */
+
+ /* Times are in us */
+ start = g_get_monotonic_time();
+ /* 30 packets, max gap 100ms, * 4 for wiggle */
+ deadline = start + 1000 * (100 * 30 * 4);
+ last_rxt = start;
+
+ while (true) {
+ int saved_err;
+ ret = qemu_recv(sv[0], buffer, 60, MSG_DONTWAIT);
+ saved_err = errno;
+ now = g_get_monotonic_time();
+ g_assert_cmpint(now, <, deadline);
+
+ if (ret >= 0) {
+ if (ret) {
+ last_rxt = now;
+ }
+ total_received += ret;
+
+ /* Check it's not spewing loads */
+ g_assert_cmpint(total_received, <, 60 * 30 * 2);
+ } else {
+ g_assert_cmpint(saved_err, ==, EAGAIN);
+
+ /* 400ms, i.e. 4 worst case gaps */
+ if ((now - last_rxt) > (1000 * 100 * 4)) {
+ /* Nothings arrived for a while - must have stopped */
+ break;
+ };
+
+ /* 100ms */
+ g_usleep(1000 * 100);
+ }
+ };
}
static void virtio_net_test_cleanup(void *sockets)
--
2.5.0
- [Qemu-devel] [PULL 06/17] net: use g_strsplit() for parsing host address and port, (continued)
- [Qemu-devel] [PULL 06/17] net: use g_strsplit() for parsing host address and port, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 07/17] net: remove unused get_str_sep() function, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 03/17] ftgmac100: do not link to netdev, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 08/17] net/announce: Allow optional list of interfaces, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 01/17] MAINTAINERS: Add qemu-bridge-helper.c to "Network device backends", Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 02/17] qemu-bridge-helper: Document known shortcomings, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 09/17] net/announce: Add HMP optional interface list, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 05/17] net: avoid using variable length array in net_client_init(), Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 10/17] net/announce: Add optional ID, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 11/17] net/announce: Add HMP optional ID, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 12/17] net/announce: Expand test for stopping self announce,
Jason Wang <=
- [Qemu-devel] [PULL 13/17] COLO-compare: Add new parameter to communicate with remote colo-frame, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 14/17] COLO-compare: Add remote notification chardev handler frame, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 15/17] COLO-compare: Make the compare_chr_send() can send notification message., Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 16/17] COLO-compare: Add colo-compare remote notify support, Jason Wang, 2019/07/01
- [Qemu-devel] [PULL 17/17] migration/colo.c: Add missed filter notify for Xen COLO., Jason Wang, 2019/07/01
- Re: [Qemu-devel] [PULL 00/17] Net patches, Peter Maydell, 2019/07/02