Re: [i-g-t,v1,1/2] runner: Create results after each tests end

"Knop, Ryszard" <[email protected]>
Newsgroups org.freedesktop.lists.igt-dev
Message-ID <[email protected]>
On Mon, 2026-07-20 at 18:15 +0200, Kamil Konieczny wrote:
> Sometimes it is desireable to have results present after an
> execution of each test, so if any unexpected reboot happen, there
> is at least result with already executed ones. Before creating
> new results.json, previous one from test before is saved into
> results.old file.
> 
> This will have one drawback of not containing any info about last
> test which causes sudden machine reboot.
> 
> Signed-off-by: Kamil Konieczny <[email protected]>
> ---
>  runner/executor.c  | 50 ++++++++++++++++++++++++++++++++++++++++++----
>  runner/resultgen.c |  6 +++++-
>  2 files changed, 51 insertions(+), 5 deletions(-)
> 
> diff --git a/runner/executor.c b/runner/executor.c
> index a8907c575..b204fdffc 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -41,6 +41,7 @@
>  #include "executor.h"
>  #include "kmemleak.h"
>  #include "output_strings.h"
> +#include "resultgen.h"
>  #include "runnercomms.h"
>  
>  #define KMSG_HEADER "[IGT] "
> @@ -2466,6 +2467,40 @@ static int open_comms_if_valid(int resdirfd, size_t testidx)
>  	return -1;
>  }
>  
> +static void write_endtime(int resdirfd, double a_time)
> +{
> +	int timefd = openat(resdirfd, "endtime.txt", O_CREAT | O_WRONLY | O_EXCL, 0666);
> +
> +	if (timefd >= 0) {
> +		dprintf(timefd, "%f\n", a_time);
> +		close(timefd);
> +	}
> +}
> +
> +static bool generate_results_with_endtime(int resdirfd, struct settings *settings)

The real purpose of this function is to regenerate results after each
individual tests on the next patch - how about renaming this to
generate_results_post_test or something like that? (End times could be
written in all result generation paths except dry runs.)

> +{
> +	char *results_path = settings->results_path;
> +	double beg_time = timeofday_double();
> +	double end_time;
> +	bool ret;
> +
> +	remove_file(resdirfd, "results.bak");
> +	renameat(resdirfd, "results.json", resdirfd, "results.bak");
> +
> +	write_endtime(resdirfd, beg_time);
> +	ret = generate_results_path(results_path);
> +	if (settings->sync)
> +		fsync(resdirfd);
> +
> +	end_time = timeofday_double();
> +	if (settings->log_level >= LOG_LEVEL_NORMAL) {
> +		outf("generating results took: %.6ffs\n", end_time - beg_time);
> +		fflush(stdout);
> +	}
> +
> +	return ret;
> +}
> +
>  bool execute(struct execute_state *state,
>  	     struct settings *settings,
>  	     struct job_list *job_list)
> @@ -2718,8 +2753,18 @@ bool execute(struct execute_state *state,
>  			if (!initialize_execute_state_from_resume(resdirfd, state, settings, job_list))
>  				return false;
>  			state->time_left = time_left;
> +			/* it should check option, also measure time taken */
> +			if (!generate_results_with_endtime(resdirfd, settings))
> +				return false;
> +
>  			return execute(state, settings, job_list);
>  		}
> +
> +		/* it should check option, also measure time taken */
> +		if (!generate_results_with_endtime(resdirfd, settings)) {
> +			status = false;
> +			break;
> +		}
>  	}
>  
>  	/* Collect facts after the last test runs */
> @@ -2731,10 +2776,7 @@ bool execute(struct execute_state *state,
>  				     settings->kmemleak_each, settings->sync))
>  			errf("Failed to collect kmemleak logs after the last test\n");
>  
> -	if ((timefd = openat(resdirfd, "endtime.txt", O_CREAT | O_WRONLY | O_EXCL, 0666)) >= 0) {
> -		dprintf(timefd, "%f\n", timeofday_double());
> -		close(timefd);
> -	}
> +	write_endtime(resdirfd, timeofday_double());
>  
>   end:
>  	if (settings->enable_code_coverage && !settings->cov_results_per_test) {
> diff --git a/runner/resultgen.c b/runner/resultgen.c
> index 1ee167fb0..f5a91f542 100644
> --- a/runner/resultgen.c
> +++ b/runner/resultgen.c
> @@ -2555,9 +2555,13 @@ bool generate_results(int dirfd)
>  bool generate_results_path(char *resultspath)
>  {
>  	int dirfd = open(resultspath, O_DIRECTORY | O_RDONLY);
> +	bool ret;
>  
>  	if (dirfd < 0)
>  		return false;
>  
> -	return generate_results(dirfd);
> +	ret = generate_results(dirfd);
> +	close(dirfd);
> +
> +	return ret;
>  }

Thanks, Ryszard
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.