From: Thomas Huth <thuth@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Akihiko Odaki <akihiko.odaki@daynix.com>
Subject: [PULL 14/23] tests/qtest/e1000e-test: De-duplicate constants
Date: Wed, 14 Dec 2022 11:09:02 +0100 [thread overview]
Message-ID: <20221214100911.165291-15-thuth@redhat.com> (raw)
In-Reply-To: <20221214100911.165291-1-thuth@redhat.com>
From: Akihiko Odaki <akihiko.odaki@daynix.com>
De-duplicate constants found in e1000e_send_verify() and
e1000e_receive_verify() to avoid mismatch and improve readability.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20221110114426.65951-1-akihiko.odaki@daynix.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/e1000e-test.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c
index 08adc5226d..3fc92046be 100644
--- a/tests/qtest/e1000e-test.c
+++ b/tests/qtest/e1000e-test.c
@@ -37,15 +37,15 @@
static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator *alloc)
{
+ static const char test[] = "TEST";
struct e1000_tx_desc descr;
- static const int data_len = 64;
char buffer[64];
int ret;
uint32_t recv_len;
/* Prepare test data buffer */
- uint64_t data = guest_alloc(alloc, data_len);
- memwrite(data, "TEST", 5);
+ uint64_t data = guest_alloc(alloc, sizeof(buffer));
+ memwrite(data, test, sizeof(test));
/* Prepare TX descriptor */
memset(&descr, 0, sizeof(descr));
@@ -54,7 +54,7 @@ static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator *a
E1000_TXD_CMD_EOP |
E1000_TXD_CMD_DEXT |
E1000_TXD_DTYP_D |
- data_len);
+ sizeof(buffer));
/* Put descriptor to the ring */
e1000e_tx_ring_push(d, &descr);
@@ -69,9 +69,9 @@ static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator *a
/* Check data sent to the backend */
ret = recv(test_sockets[0], &recv_len, sizeof(recv_len), 0);
g_assert_cmpint(ret, == , sizeof(recv_len));
- ret = recv(test_sockets[0], buffer, 64, 0);
- g_assert_cmpint(ret, >=, 5);
- g_assert_cmpstr(buffer, == , "TEST");
+ ret = recv(test_sockets[0], buffer, sizeof(buffer), 0);
+ g_assert_cmpint(ret, ==, sizeof(buffer));
+ g_assert_cmpstr(buffer, == , test);
/* Free test data buffer */
guest_free(alloc, data);
@@ -93,7 +93,6 @@ static void e1000e_receive_verify(QE1000E *d, int *test_sockets, QGuestAllocator
},
};
- static const int data_len = 64;
char buffer[64];
int ret;
@@ -102,7 +101,7 @@ static void e1000e_receive_verify(QE1000E *d, int *test_sockets, QGuestAllocator
g_assert_cmpint(ret, == , sizeof(test) + sizeof(len));
/* Prepare test data buffer */
- uint64_t data = guest_alloc(alloc, data_len);
+ uint64_t data = guest_alloc(alloc, sizeof(buffer));
/* Prepare RX descriptor */
memset(&descr, 0, sizeof(descr));
@@ -120,7 +119,7 @@ static void e1000e_receive_verify(QE1000E *d, int *test_sockets, QGuestAllocator
/* Check data sent to the backend */
memread(data, buffer, sizeof(buffer));
- g_assert_cmpstr(buffer, == , "TEST");
+ g_assert_cmpstr(buffer, == , test);
/* Free test data buffer */
guest_free(alloc, data);
--
2.31.1
next prev parent reply other threads:[~2022-12-14 10:34 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 10:08 [PULL 00/23] First batch of s390x, qtest, CI and misc patches for 8.0 Thomas Huth
2022-12-14 10:08 ` [PULL 01/23] s390x/pci: coalesce unmap operations Thomas Huth
2022-12-14 10:08 ` [PULL 02/23] s390x/pci: shrink DMA aperture to be bound by vfio DMA limit Thomas Huth
2022-12-14 10:08 ` [PULL 03/23] s390x/pci: reset ISM passthrough devices on shutdown and system reset Thomas Huth
2022-12-14 10:08 ` [PULL 04/23] target/s390x/tcg/mem_helper: Test the right bits in psw_key_valid() Thomas Huth
2022-12-14 10:08 ` [PULL 05/23] target/s390x: The MVCP and MVCS instructions are not privileged Thomas Huth
2022-12-14 10:08 ` [PULL 06/23] monitor/misc: Remove superfluous include statements Thomas Huth
2022-12-14 10:08 ` [PULL 07/23] scripts/make-release: Add a simple help text for the script Thomas Huth
2022-12-14 10:08 ` [PULL 08/23] scripts/make-release: Only clone single branches to speed up " Thomas Huth
2022-12-14 10:08 ` [PULL 09/23] util/qemu-config: Fix "query-command-line-options" to provide the right values Thomas Huth
2022-12-14 10:08 ` [PULL 10/23] util/oslib-win32: Remove obsolete reference to g_poll code Thomas Huth
2022-12-14 10:08 ` [PULL 11/23] MAINTAINERS: Add documentation files to the corresponding sections Thomas Huth
2022-12-14 10:09 ` [PULL 12/23] hw: Include the VMWare devices only in the x86 targets Thomas Huth
2022-12-14 10:09 ` [PULL 13/23] tests/qtest/libqos/e1000e: Remove "other" interrupts Thomas Huth
2022-12-14 10:09 ` Thomas Huth [this message]
2022-12-14 10:09 ` [PULL 15/23] tests/qtest/libqos/e1000e: Correctly group register accesses Thomas Huth
2022-12-14 10:09 ` [PULL 16/23] .gitlab-ci.d/windows.yml: Unify the prerequisite packages Thomas Huth
2022-12-14 10:09 ` [PULL 17/23] .gitlab-ci.d/windows.yml: Keep 64-bit and 32-bit build scripts consistent Thomas Huth
2022-12-14 10:09 ` [PULL 18/23] .gitlab-ci.d/windows.yml: Exclude qTests from 64-bit CI job for now Thomas Huth
2022-12-14 10:09 ` [PULL 19/23] tests/qtest: Enable qtest build on Windows Thomas Huth
2022-12-14 10:09 ` [PULL 20/23] FreeBSD: Upgrade to 12.4 release Thomas Huth
2022-12-14 10:09 ` [PULL 21/23] gitlab-ci: Check building ppc64 without TCG Thomas Huth
2022-12-14 10:09 ` [PULL 22/23] .gitlab/issue_templates: Move suggestions into comments Thomas Huth
2022-12-14 10:09 ` [PULL 23/23] tests/qtest/vhost-user-blk-test: don't abort all qtests on missing envar Thomas Huth
2022-12-15 13:38 ` [PULL 00/23] First batch of s390x, qtest, CI and misc patches for 8.0 Peter Maydell
2022-12-15 14:14 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221214100911.165291-15-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).