[systemd-devel] [PATCH 2/4] libsystemd-network: Add hangcheck timer for DHCP client test
Tom Gundersen
teg at jklm.no
Fri Mar 14 12:05:10 PDT 2014
On Thu, Mar 13, 2014 at 12:01 PM, Patrik Flykt
<patrik.flykt at linux.intel.com> wrote:
> ---
> src/libsystemd-network/test-dhcp-client.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
> index cfc75ae..9509eec 100644
> --- a/src/libsystemd-network/test-dhcp-client.c
> +++ b/src/libsystemd-network/test-dhcp-client.c
> @@ -44,6 +44,15 @@ static bool verbose = false;
> static int test_fd[2];
> static test_callback_recv_t callback_recv;
> static be32_t xid;
> +static sd_event_source *test_hangcheck;
> +
> +static int test_dhcp_hangcheck(sd_event_source *s, uint64_t usec,
> + void *userdata)
> +{
> + assert(false);
I guess this should be assert_se() ?
> +
> + return 0;
> +}
>
> static void test_request_basic(sd_event *e)
> {
> @@ -419,6 +428,7 @@ static int test_addr_acq_recv_discover(size_t size, DHCPMessage *discover)
>
> static void test_addr_acq(sd_event *e)
> {
> + usec_t time_now = now(CLOCK_MONOTONIC);
> sd_dhcp_client *client;
> int res, r;
>
> @@ -440,11 +450,17 @@ static void test_addr_acq(sd_event *e)
>
> callback_recv = test_addr_acq_recv_discover;
>
> + assert_se(sd_event_add_monotonic(e, &test_hangcheck,
> + time_now + 2 * USEC_PER_SEC, 0,
> + test_dhcp_hangcheck, NULL) >= 0);
> +
> res = sd_dhcp_client_start(client);
> assert_se(res == 0 || res == -EINPROGRESS);
>
> sd_event_loop(e);
>
> + test_hangcheck = sd_event_source_unref(test_hangcheck);
> +
> sd_dhcp_client_set_callback(client, NULL, NULL);
> sd_dhcp_client_stop(client);
> sd_dhcp_client_free(client);
> --
> 1.8.5.2
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
More information about the systemd-devel
mailing list