[LTP] [PATCH v2] copy_file_range03: comparing timestamp in tst_timespec_diff

Cyril Hrubis chrubis@suse.cz
Mon Sep 6 10:59:55 CEST 2021


Hi!
> -	updated_timestamp = get_timestamp(fd_dest);
> +	timestamp2 = get_timestamp(fd_dest);
>  
> -	if (timestamp == updated_timestamp)
> +	diff = tst_timespec_diff(timestamp1, timestamp2);
> +
> +	if (!diff.tv_sec && !diff.tv_nsec)
>  		tst_brk(TFAIL, "copy_file_range did not update timestamp.");

So as we changed the code to sleep for 1.5 sec I guess that we can
expect the difference to be at least 1 second because:

- the minimal granularity is 1s in which case we will get exactly 1s in
  the diff

- if the granularity is greater, we will get a bit more than 1s

So I would go for something as:

	long long diff_us = tst_timespec_diff_us(timestamp2, timestamp1);

	if (diff_us >= 1000000 && diff_us <= 2000000)
		tst_res(TPASS, "...");

Which expects that the difference between timestamps is in a sane range
not that it just have been changed.

>  	tst_res(TPASS, "copy_file_range sucessfully updated the timestamp");
> -- 
> 2.31.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list