[igt-dev] [PATCH i-g-t 1/2] runner: Add support for aborting on network failure

Arkadiusz Hiler arkadiusz.hiler at intel.com
Tue Dec 11 13:25:28 UTC 2018


On Mon, Dec 10, 2018 at 03:41:55PM +0200, Petri Latvala wrote:
> diff --git a/runner/executor.c b/runner/executor.c
> index 54c530b7..bb0fc772 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -1,6 +1,10 @@
>  #include <errno.h>
>  #include <fcntl.h>
> +#include <glib.h>
>  #include <linux/watchdog.h>
> +#if HAVE_OPING +#include <oping.h>
> +#endif
>  #include <signal.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> @@ -108,6 +112,104 @@ static void ping_watchdogs(void)
>  	}
>  }
>  
> +#if HAVE_OPING
> +static pingobj_t *pingobj = NULL;
> +#endif
> +
> +static void load_ping_config(void)
> +{
> +#if HAVE_OPING
> +	char *key_file_env = NULL;
> +	char *key_file_loc = NULL;
> +	GError *error = NULL;
> +	GKeyFile *key_file = NULL;
> +	const char *ping_hostname;
> +	double timeout = 2.0; /* Fair dice roll */
> +
> +	if (pingobj)
> +		return;
> +
> +	/* Determine igt config path */
> +	key_file_env = getenv("IGT_CONFIG_PATH");
> +	if (key_file_env) {
> +		key_file_loc = key_file_env;
> +	} else {
> +		key_file_loc = malloc(100);
> +		snprintf(key_file_loc, 100, "%s/.igtrc", g_get_home_dir());
> +	}
> +
> +	/* Load igt config file */
> +	key_file = g_key_file_new();
> +	g_key_file_load_from_file(key_file, key_file_loc,
> +				  G_KEY_FILE_NONE, &error);
> +	if (error && error->code == G_KEY_FILE_ERROR) {
> +		g_error_free(error);
> +		key_file = NULL;
> +
> +		goto out;
> +	}
> +
> +	g_clear_error(&error);
> +
> +	ping_hostname =
> +		g_key_file_get_string(key_file, "DUT",
> +				      "PingHostName", &error);
> +
> +	g_clear_error(&error);
> +
> +	if (!ping_hostname)
> +		return;
> +
> +	pingobj = ping_construct();
> +	if (ping_host_add(pingobj, ping_hostname)) {
> +		fprintf(stderr,
> +			"abort on ping: Cannot add configured hostname\n");
> +		ping_destroy(pingobj);
> +		pingobj = NULL;
> +		return;
> +	}
> +
> +	ping_setopt(pingobj, PING_OPT_TIMEOUT, &timeout);
> +
> +out:
> +	if (!key_file_env && key_file_loc)
> +		free(key_file_loc);
> +	g_key_file_free(key_file);
> +#endif
> +}

I think that having an option to set the host through a cmdline
switch/ENV variable can be useful, especially for the CI. The .igtrc is
perfect for testing in a limiteds scope, but rolling out updated
configuration to 100s of hosts is a file form is rather cumbersome.

Also, it feels like it's about a time to start writing man pages for the
runner. Any takers? ;-)

-Arek


More information about the igt-dev mailing list