Skip to content

Commit

Permalink
test-dhcp-server: Gracefully handle the network being down
Browse files Browse the repository at this point in the history
(cherry picked from commit 4cf7a676af9a79ff418227d8ff488dfca6f243ab)
(cherry picked from commit 2e52cf1df7f4a874331dcf607e0f4329ffb20bcd)
  • Loading branch information
DaanDeMeyer authored and bluca committed Sep 10, 2024
1 parent 4d4513c commit db1d9bf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libsystemd-network/test-dhcp-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static void test_message_handler(void) {
.s_addr = htobe32(INADDR_LOOPBACK + 42),
};
static uint8_t static_lease_client_id[7] = {0x01, 'A', 'B', 'C', 'D', 'E', 'G' };
int r;

log_debug("/* %s */", __func__);

Expand All @@ -137,7 +138,10 @@ static void test_message_handler(void) {
assert_se(sd_dhcp_server_attach_event(server, NULL, 0) >= 0);
assert_se(sd_dhcp_server_start(server) >= 0);

assert_se(dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test), NULL) == DHCP_OFFER);
r = dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test), NULL);
if (r == -ENETDOWN)
return (void) log_tests_skipped("Network is not available");
assert_se(r == DHCP_OFFER);

test.end = 0;
/* TODO, shouldn't this fail? */
Expand Down

0 comments on commit db1d9bf

Please sign in to comment.