Commit d25f5348 authored by Evgeny Antyshev's avatar Evgeny Antyshev Committed by Pavel Emelyanov

zdtm: uptime_grow test

new testcase important for rebootless update testing:
we query system timer CLOCK_MONOTONIC continuously
and fail in case it stepped backwards
Signed-off-by: 's avatarEvgeny Antyshev <eantyshev@parallels.com>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 606ad446
...@@ -46,6 +46,7 @@ TST_NOFILE = \ ...@@ -46,6 +46,7 @@ TST_NOFILE = \
file_fown \ file_fown \
eventfs00 \ eventfs00 \
inotify00 \ inotify00 \
uptime_grow \
# jobctl00 \ # jobctl00 \
TST_FILE = \ TST_FILE = \
...@@ -158,6 +159,7 @@ futex: override LDFLAGS += -pthread ...@@ -158,6 +159,7 @@ futex: override LDFLAGS += -pthread
jobctl00: override LDLIBS += -lutil jobctl00: override LDLIBS += -lutil
socket_listen: override LDLIBS += -lrt socket_listen: override LDLIBS += -lrt
socket_aio: 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 unlink_largefile: override CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
inotify_system_nodel: override CFLAGS += -DNODEL inotify_system_nodel: override CFLAGS += -DNODEL
pthread00: override LDLIBS += -pthread pthread00: override LDLIBS += -pthread
......
#include "zdtmtst.h"
const char *test_doc = "test to ensure that monotonic clock doesn't decrease";
const char *test_author = "Evgeny Antysev <eantyshev@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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment