mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-25 02:58:54 +00:00
This test checks that monotonic and boottime don't jump after C/R. In ns and uns flavors, the test is started in a separate time namespace with big offsets, so if criu will restore a time namespace incorrectly the test will detect the big delta of clocks values before and after C/R. Signed-off-by: Andrei Vagin <avagin@gmail.com>
47 lines
888 B
C
47 lines
888 B
C
#include <errno.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
|
|
#include "zdtmtst.h"
|
|
|
|
const char *test_doc = "Check monotonic and boot clocks";
|
|
const char *test_author = "Andrei Vagin <avagin@gmail.com";
|
|
|
|
|
|
#define NSEC_PER_SEC 1000000000ULL
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct timespec tss[2], ts;
|
|
int clocks[] = {CLOCK_MONOTONIC, CLOCK_BOOTTIME};
|
|
unsigned long long a, b;
|
|
int i;
|
|
|
|
test_init(argc, argv);
|
|
|
|
for (i = 0; i < 2; i++)
|
|
clock_gettime(clocks[i], &tss[i]);
|
|
|
|
test_daemon();
|
|
test_waitsig();
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
clock_gettime(clocks[i], &ts);
|
|
|
|
a = ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
|
|
b = tss[i].tv_sec * NSEC_PER_SEC + tss[i].tv_nsec;
|
|
if (a < b) {
|
|
fail("%d: %lld %lld", clocks[i], a, b);
|
|
return 1;
|
|
}
|
|
if (a > b + 60 * 60 * NSEC_PER_SEC) {
|
|
fail("%d: %lld %lld", clocks[i], a, b);
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
pass();
|
|
|
|
return 0;
|
|
}
|