diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-29 14:50:14 -0400 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-29 15:10:53 -0400 |
commit | 9c0b5f1f0b2009ab628400e10c18ec64ede696d8 (patch) | |
tree | 827a1e09e6a7dfe1cf20277e95ec503f1e2fef80 /libdhcp | |
parent | 17ccf19a8fd564a280889503953222ead2b0f44b (diff) |
libdhcp: tests: Inject errors into the tests
Diffstat (limited to 'libdhcp')
-rw-r--r-- | libdhcp/tests/test_client.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libdhcp/tests/test_client.c b/libdhcp/tests/test_client.c index 90efd01..24b3af6 100644 --- a/libdhcp/tests/test_client.c +++ b/libdhcp/tests/test_client.c @@ -24,6 +24,9 @@ LO_IMPLEMENTATION_H(net_packet_conn, struct test_udp, test_udp); LO_IMPLEMENTATION_C(net_packet_conn, struct test_udp, test_udp, static); static ssize_t test_udp_sendto(struct test_udp *LM_UNUSED(self), void *LM_UNUSED(buf), size_t len, struct net_ip4_addr LM_UNUSED(node), uint16_t LM_UNUSED(port)) { + static unsigned cnt = 0; + if (cnt++ % 2 == 0) + return -NET_EOTHER; return len; } @@ -35,8 +38,10 @@ static ssize_t test_udp_recvfrom(struct test_udp *LM_UNUSED(self), void *buf, si const void *resp; size_t resp_len; switch (cnt++) { - case 0: resp = resp_offer; resp_len = sizeof(resp_offer); break; - case 1: resp = resp_ack; resp_len = sizeof(resp_ack); break; + case 0: return -NET_EOTHER; + case 1: resp = resp_offer; resp_len = sizeof(resp_offer); break; + case 2: return -NET_EOTHER; + case 3: resp = resp_ack; resp_len = sizeof(resp_ack); break; default: return -NET_ERECV_TIMEOUT; } test_assert(len >= resp_len); |