[CRIU] Re: [PATCH] zdtm: uptime_grow test

Andrew Vagin avagin at parallels.com
Wed Jun 20 03:34:13 EDT 2012


Ack

On Tue, Jun 19, 2012 at 06:38:33PM +0400, Evgeny Antyshev wrote:
> PSBM-10900
> new testcase important for rebootless update testing:
> we query system timer CLOCK_MONOTONIC continuously
> and fail in case it stepped backwards
> ---
>  test/zdtm/live/static/Makefile      |    2 +
>  test/zdtm/live/static/uptime_grow.c |   42 +++++++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+), 0 deletions(-)
>  create mode 100644 test/zdtm/live/static/uptime_grow.c
> 
> diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
> index a399741..5492d05 100644
> --- a/test/zdtm/live/static/Makefile
> +++ b/test/zdtm/live/static/Makefile
> @@ -46,6 +46,7 @@ TST_NOFILE	=				\
>  		file_fown			\
>  		eventfs00			\
>  		inotify00			\
> +		uptime_grow			\
>  #		jobctl00			\
>  
>  TST_FILE	=				\
> @@ -157,6 +158,7 @@ futex:			override LDFLAGS += -pthread
>  jobctl00:		override LDLIBS += -lutil
>  socket_listen:		override LDLIBS += -lrt
>  socket_aio:		override LDLIBS += -lrt
> +uptime_grow:	override LDLIBS += -lrt
>  unlink_largefile:	override CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
>  inotify_system_nodel:	override CFLAGS += -DNODEL
>  pthread00:		override LDLIBS += -pthread
> diff --git a/test/zdtm/live/static/uptime_grow.c b/test/zdtm/live/static/uptime_grow.c
> new file mode 100644
> index 0000000..c5eff51
> --- /dev/null
> +++ b/test/zdtm/live/static/uptime_grow.c
> @@ -0,0 +1,42 @@
> +#include "zdtmtst.h"
> +
> +const char *test_doc    = "test to ensure that monotonic clock doesn't decrease";
> +const char *test_author = "Evgeny Antysev <eantyshev at parallels.com>";
> +
> +#include <time.h>
> +#include <stdlib.h>
> +
> +# define tv_gt(a, b) \
> +  (((a)->tv_sec == (b)->tv_sec) ? \
> +   ((a)->tv_nsec > (b)->tv_nsec) : \
> +   ((a)->tv_sec > (b)->tv_sec))
> + 
> +int main(int argc, char **argv)
> +{
> +	struct timespec tm_old, tm;
> +	double diff_nsec;
> +	test_init(argc, argv);
> +
> +	if (clock_gettime(CLOCK_MONOTONIC, &tm_old)) {
> +		err("clock_gettime failed: %m\n");
> +		exit(1);
> +	}
> +
> +	test_daemon();
> +
> +	while (test_go()) {
> +		if (clock_gettime(CLOCK_MONOTONIC, &tm)) {
> +			err("clock_gettime failed: %m\n");
> +			exit(1);
> +		}
> +		if (!tv_gt(&tm, &tm_old)) {
> +			diff_nsec = (tm_old.tv_sec - tm.tv_sec) * 1.0E9 +\
> +				(tm_old.tv_nsec - tm.tv_nsec);
> +			fail("clock step backward for %e nsec\n", diff_nsec);
> +			exit(1);
> +		}
> +		tm_old = tm;
> +	}
> +	pass();
> +	return 0;
> +}
> -- 
> 1.6.5.1.1367.gcd48
> 


More information about the CRIU mailing list