[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 08/13] tests/qtest/e1000e-test: Fabricate ethernet header
From: |
Akihiko Odaki |
Subject: |
[PATCH v2 08/13] tests/qtest/e1000e-test: Fabricate ethernet header |
Date: |
Sat, 14 Jan 2023 13:09:59 +0900 |
e1000e understands ethernet header so fabricate something convincing.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
tests/qtest/e1000e-test.c | 17 +++++++++++------
tests/qtest/libqos/e1000e.h | 2 ++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c
index b63a4d3c91..98706355e3 100644
--- a/tests/qtest/e1000e-test.c
+++ b/tests/qtest/e1000e-test.c
@@ -27,6 +27,7 @@
#include "qemu/osdep.h"
#include "libqtest-single.h"
#include "libqos/pci-pc.h"
+#include "net/eth.h"
#include "qemu/sockets.h"
#include "qemu/iov.h"
#include "qemu/module.h"
@@ -35,9 +36,13 @@
#include "libqos/e1000e.h"
#include "hw/net/e1000_regs.h"
+static const struct eth_header test = {
+ .h_dest = E1000E_ADDRESS,
+ .h_source = E1000E_ADDRESS,
+};
+
static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator
*alloc)
{
- static const char test[] = "TEST";
struct e1000_tx_desc descr;
char buffer[64];
int ret;
@@ -45,7 +50,7 @@ static void e1000e_send_verify(QE1000E *d, int *test_sockets,
QGuestAllocator *a
/* Prepare test data buffer */
uint64_t data = guest_alloc(alloc, sizeof(buffer));
- memwrite(data, test, sizeof(test));
+ memwrite(data, &test, sizeof(test));
/* Prepare TX descriptor */
memset(&descr, 0, sizeof(descr));
@@ -71,7 +76,7 @@ static void e1000e_send_verify(QE1000E *d, int *test_sockets,
QGuestAllocator *a
g_assert_cmpint(ret, == , sizeof(recv_len));
ret = recv(test_sockets[0], buffer, sizeof(buffer), 0);
g_assert_cmpint(ret, ==, sizeof(buffer));
- g_assert_cmpstr(buffer, == , test);
+ g_assert_false(memcmp(buffer, &test, sizeof(test)));
/* Free test data buffer */
guest_free(alloc, data);
@@ -81,14 +86,14 @@ static void e1000e_receive_verify(QE1000E *d, int
*test_sockets, QGuestAllocator
{
union e1000_rx_desc_extended descr;
- char test[] = "TEST";
+ struct eth_header test_iov = test;
int len = htonl(sizeof(test));
struct iovec iov[] = {
{
.iov_base = &len,
.iov_len = sizeof(len),
},{
- .iov_base = test,
+ .iov_base = &test_iov,
.iov_len = sizeof(test),
},
};
@@ -119,7 +124,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_false(memcmp(buffer, &test, sizeof(test)));
/* Free test data buffer */
guest_free(alloc, data);
diff --git a/tests/qtest/libqos/e1000e.h b/tests/qtest/libqos/e1000e.h
index 091ce139da..5e2b201aa7 100644
--- a/tests/qtest/libqos/e1000e.h
+++ b/tests/qtest/libqos/e1000e.h
@@ -25,6 +25,8 @@
#define E1000E_RX0_MSG_ID (0)
#define E1000E_TX0_MSG_ID (1)
+#define E1000E_ADDRESS { 0x52, 0x54, 0x00, 0x12, 0x34, 0x56 }
+
typedef struct QE1000E QE1000E;
typedef struct QE1000E_PCI QE1000E_PCI;
--
2.39.0
- [PATCH v2 00/13] Introduce igb, Akihiko Odaki, 2023/01/13
- [PATCH v2 01/13] hw/net/net_tx_pkt: Introduce net_tx_pkt_get_eth_hdr, Akihiko Odaki, 2023/01/13
- [PATCH v2 02/13] pcie: Introduce pcie_sriov_num_vfs, Akihiko Odaki, 2023/01/13
- [PATCH v2 03/13] e1000: Split header files, Akihiko Odaki, 2023/01/13
- [PATCH v2 04/13] igb: Copy e1000e code, Akihiko Odaki, 2023/01/13
- [PATCH v2 05/13] igb: Rename identifiers, Akihiko Odaki, 2023/01/13
- [PATCH v2 06/13] igb: Build igb, Akihiko Odaki, 2023/01/13
- [PATCH v2 07/13] igb: Transform to 82576 implementation, Akihiko Odaki, 2023/01/13
- [PATCH v2 08/13] tests/qtest/e1000e-test: Fabricate ethernet header,
Akihiko Odaki <=
- [PATCH v2 11/13] tests/qtest/libqos/igb: Transform to igb tests, Akihiko Odaki, 2023/01/13
- [PATCH v2 09/13] tests/qtest/libqos/e1000e: Export macreg functions, Akihiko Odaki, 2023/01/13
- [PATCH v2 10/13] tests/qtest/libqos/igb: Copy e1000e code, Akihiko Odaki, 2023/01/13
- [PATCH v2 12/13] tests/avocado: Add igb test, Akihiko Odaki, 2023/01/13
- [PATCH v2 13/13] docs/system/devices/igb: Add igb documentation, Akihiko Odaki, 2023/01/13
- Re: [PATCH v2 00/13] Introduce igb, Jason Wang, 2023/01/16