Skip to content

Commit 3c4c041

Browse files
committed
fix statechange test
1 parent 8ca6921 commit 3c4c041

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/mip_test.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,25 @@ static void test_csum(void) {
4141
// UDP and TCP checksum calc funcions use the same basic calls as ipcsum()
4242
}
4343

44+
static bool executed = false;
45+
46+
static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
47+
if (ev == MG_TCPIP_EV_ST_CHG)
48+
ASSERT(*(uint8_t *) ev_data == MG_TCPIP_STATE_READY);
49+
executed = true;
50+
(void) ifp;
51+
}
52+
4453
static void test_statechange(void) {
45-
char tx[1540];
4654
struct mg_tcpip_if iface;
4755
memset(&iface, 0, sizeof(iface));
4856
iface.ip = mg_htonl(0x01020304);
4957
iface.state = MG_TCPIP_STATE_READY;
50-
iface.tx.buf = tx, iface.tx.len = sizeof(tx);
5158
iface.driver = &mg_tcpip_driver_mock;
59+
iface.fn = mif_fn;
5260
onstatechange(&iface);
61+
ASSERT(executed == true);
62+
executed = false;
5363
}
5464

5565
static void ph(struct mg_connection *c, int ev, void *ev_data) {

0 commit comments

Comments
 (0)